Skip to content
Discussion options

You must be logged in to vote

The Rig way to model this is to make the subagent a tool.

Rig already implements Tool for Agent<M>, so an agent can be passed directly into another agent with .tool(sub_agent). When the parent agent calls that tool, Rig awaits the subagent's prompt(...) call and uses the subagent's final answer as the tool result.

That means the current turn stays running automatically. You do not need to return a task handle or manually check whether the subagent has finished.

There is an existing example in the repo: examples/agent_with_agent_tool.rs.

The key part is:

let calculator_agent = openai_client
    .agent(providers::openai::GPT_4O)
    .preamble("You are a calculator...")
    .tool(Adder)
    .t…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@liukaizheng
Comment options

Answer selected by liukaizheng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants