invoke
Runs another agent inside this agent and returns the other agent's return value. Together with search, invoke is how deep agents and orchestrators are built.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
agent | dynamic string | Name of the agent to invoke. | |
inputs | dynamic dict | Inputs passed to the invoked agent. | |
sharePrompts | boolean | false | Share the prompts from the calling agent. |
Result
The value that the invoked agent's main function returns with return. Anything the invoked agent writes with output or progress is streamed to the user as the invoked agent runs, exactly as if the user had run that agent directly.
Prompts and state
The invoked agent runs in the same conversation. The invoked agent sees the same conv. variables and its own agent. variables. By default the invoked agent gets a fresh prompt, isolated from the caller's prompt. Set sharePrompts to let the invoked agent continue the caller's prompt instead. Sharing is wrong inside a tool function, because the caller's prompt is in the middle of a call there.
Example
"invoke": {
"agent": "hr_helper",
"inputs": { "query": "{ f'How many vacation days does {employee} have left?' }" }
},
"var": { "vacation": "{ result }" }Rules
- The agent name may be an expression. Use an expression to invoke a
searchresult. A literal name is checked at validation time: the agent must exist. - An agent cannot invoke itself, nor any agent that is already running in the chain that led here. A literal invocation also protects the invoked agent from being deleted while this agent refers to it.
- If the invoked agent pauses on
ask, the whole chain pauses. The user's answers resume the invoked agent. - If the invoked agent fails with
fail, this command raises an error with the same message. invokeis not allowed inside aforblock or in error handling, nor in any function called from those places.

