Orchestrator example #149
-
@KennyVaneetvelde Hello. First of all thanks for the awesome agentic-framework. I am looking to use atomic-agents to create an orchestration example. Let me explain the scenario Flow (my expectatation) Can you validate if this is the sequence of steps? I am unable to understand the link between the agent and tool. How do i call the tool from the agent and send back response up the ladder. Any clarifications are welcome |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey, that's a great question! Your understanding of the flow is spot on. That sequence is exactly the kind of powerful, multi-step reasoning you can build with You've hit on the core design principle of the framework: Agents decide, your code executes. The "missing link" you're looking for isn't inside the agent itself. An agent's primary job is to receive input and use the model to output a structured response that follows a specific Pydantic schema. It's your application logic that takes this structured output and then calls the appropriate tool. The tool's output is then fed back to an agent (either the same one or a different one) to be processed into a final answer. The First, the agent's job is to decide the tool. The agent's Here's the class OrchestratorOutputSchema(BaseIOSchema):
"""Combined output schema for the Orchestrator Agent. Contains the tool to use and its parameters."""
tool: str = Field(..., description="The tool to use: 'search' or 'calculator'")
tool_parameters: Union[SearxNGSearchToolInputSchema, CalculatorToolInputSchema] = Field(
..., description="The parameters for the selected tool"
) When you run this agent, it doesn't execute the tool. It just populates this As an aside, we don't strictly need the Then, your application executes the tool. Your main application code receives this def execute_tool(
searxng_tool: SearxNGSearchTool, calculator_tool: CalculatorTool, orchestrator_output: OrchestratorOutputSchema
) -> Union[SearxNGSearchToolOutputSchema, CalculatorToolOutputSchema]:
if orchestrator_output.tool == "search":
return searxng_tool.run(orchestrator_output.tool_parameters)
elif orchestrator_output.tool == "calculator":
return calculator_tool.run(orchestrator_output.tool_parameters)
else:
raise ValueError(f"Unknown tool: {orchestrator_output.tool}") Finally, the tool output is fed back to the agent to get a polished, natural language response. Notice how the main loop in
Here's the code from # ... after running the tool and getting the `response`
orchestrator_agent.output_schema = FinalAnswerSchema
orchestrator_agent.memory.add_message("system", response)
final_answer = orchestrator_agent.run(input_schema)
console.print(f"\n[bold blue]Final Answer:[/bold blue] {final_answer.final_answer}") The The flow looks like this:
This pattern perfectly matches your expectation of agents calling other agents (or rather, the output of one agent being the input for the next) and then ultimately calling tools. The "ladder" is the main application loop that passes the data from one step to the next. Your intuition is correct! The framework is designed for you to implement this orchestration logic in your main application code, giving you full control over the flow. The |
Beta Was this translation helpful? Give feedback.
Hey, that's a great question! Your understanding of the flow is spot on. That sequence is exactly the kind of powerful, multi-step reasoning you can build with
atomic-agents
.You've hit on the core design principle of the framework: Agents decide, your code executes.
The "missing link" you're looking for isn't inside the agent itself. An agent's primary job is to receive input and use the model to output a structured response that follows a specific Pydantic schema. It's your application logic that takes this structured output and then calls the appropriate tool. The tool's output is then fed back to an agent (either the same one or a different one) to be processed into a final answer.
The
…