Skip to content

Commit f185dfa

Browse files
authored
docs: document tool execution concurrency (#3164)
1 parent c5ebf80 commit f185dfa

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

docs/running_agents.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,37 @@ Use `RunConfig` to override behavior for a single run without changing each agen
152152
- [`workflow_name`][agents.run.RunConfig.workflow_name], [`trace_id`][agents.run.RunConfig.trace_id], [`group_id`][agents.run.RunConfig.group_id]: Sets the tracing workflow name, trace ID and trace group ID for the run. We recommend at least setting `workflow_name`. The group ID is an optional field that lets you link traces across multiple runs.
153153
- [`trace_metadata`][agents.run.RunConfig.trace_metadata]: Metadata to include on all traces.
154154

155-
##### Tool approval and tool error behavior
155+
##### Tool execution, approval, and tool error behavior
156156

157+
- [`tool_execution`][agents.run.RunConfig.tool_execution]: Configure SDK-side execution behavior for local tool calls, such as limiting how many function tools run at once.
157158
- [`tool_error_formatter`][agents.run.RunConfig.tool_error_formatter]: Customize the model-visible message when a tool call is rejected during approval flows.
158159

159160
Nested handoffs are available as an opt-in beta. Enable the collapsed-transcript behavior by passing `RunConfig(nest_handoff_history=True)` or set `handoff(..., nest_handoff_history=True)` to turn it on for a specific handoff. If you prefer to keep the raw transcript (the default), leave the flag unset or provide a `handoff_input_filter` (or `handoff_history_mapper`) that forwards the conversation exactly as you need. To change the wrapper text used in the generated summary without writing a custom mapper, call [`set_conversation_history_wrappers`][agents.handoffs.set_conversation_history_wrappers] (and [`reset_conversation_history_wrappers`][agents.handoffs.reset_conversation_history_wrappers] to restore the defaults).
160161

161162
#### Run config details
162163

164+
##### `tool_execution`
165+
166+
Use `tool_execution` when you want the SDK to limit local function-tool concurrency for a run.
167+
168+
```python
169+
from agents import Agent, RunConfig, Runner, ToolExecutionConfig
170+
171+
agent = Agent(name="Assistant", tools=[...])
172+
173+
result = await Runner.run(
174+
agent,
175+
"Run the required tool calls.",
176+
run_config=RunConfig(
177+
tool_execution=ToolExecutionConfig(max_function_tool_concurrency=2),
178+
),
179+
)
180+
```
181+
182+
`max_function_tool_concurrency=None` preserves the default behavior: when a model emits multiple function tool calls in a turn, the SDK starts all emitted local function tool calls. Set an integer value to cap how many of those local function tools run at once.
183+
184+
This is separate from provider-side [`ModelSettings.parallel_tool_calls`][agents.model_settings.ModelSettings.parallel_tool_calls]. `parallel_tool_calls` controls whether the model is allowed to emit multiple tool calls in a single response. `tool_execution.max_function_tool_concurrency` controls how the SDK executes local function tool calls after the model has emitted them.
185+
163186
##### `tool_error_formatter`
164187

165188
Use `tool_error_formatter` to customize the message that is returned to the model when a tool call is rejected in an approval flow.

0 commit comments

Comments
 (0)