You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Context
By default, the outputs of tools are sent to the LLM again. The LLM gets
to read the outputs, and produce a new response. There are cases where
this is not desired:
1. Every tool results in another round trip, and sometimes the output of
the tool is enough.
2. If you force tool use (via model settings `tool_choice=required`),
then the agent will just infinite loop.
This enables you to have different behavior, e.g. use the first tool
output as the final output, or write a custom function to process tool
results and potentially produce an output.
## Test plan
Added new tests and ran existing tests
Also added examples.
Closes#117
Supplying a list of tools doesn't always mean the LLM will use a tool. You can force tool use by setting [`ModelSettings.tool_choice`][agents.model_settings.ModelSettings.tool_choice]. Valid values are:
137
+
138
+
1.`auto`, which allows the LLM to decide whether or not to use a tool.
139
+
2.`required`, which requires the LLM to use a tool (but it can intelligently decide which tool).
140
+
3.`none`, which requires the LLM to _not_ use a tool.
141
+
4. Setting a specific string e.g. `my_tool`, which requires the LLM to use that specific tool.
142
+
143
+
!!! note
144
+
145
+
If requiring tool use, you should consider setting [`Agent.tool_use_behavior`] to stop the Agent from running when a tool output is produced. Otherwise, the Agent might run in an infinite loop, where the LLM produces a tool call , and the tool result is sent to the LLM, and this infinite loops because the LLM is always forced to use a tool.
0 commit comments