Description
Is there some equivalent to AutoGen's reflect_on_tool_use=False
? That is: Some way for an agent to use the output of one of its tools as its own output, without needing another roundtrip to the LLM?
Worked example:
# Untested code, just illustrative
class LoremModel(BaseModel):
paragraph: str
@function_tool
def generate_lorem(n: int) -> List[LoremModel]:
'''Generate `n` paragraphs of lorem ipsum'''
# omitted
agent = Agent(
name='Lorem Agent',
tools=[generate_lorem],
output_type=List[LoremModel],
)
await Runner.run(agent, 'Generate 1000 paragraphs of lorem ipsum')
I believe the way this works is:
- Prompt gets sent up to the LLM
- LLM responds requesting invocation of
generate_lorem(1000)
- We execute that function and now have 1000 paragraphs of lorem ipsum in memory
- We send these 1000 paragraphs back up to the LLM
- The LLM generates a final response to the user prompt, which is just those same paragraphs of lorem ipsum again.
In practice we already have our answer after step 3, but then have this extra roundtrip in steps 4&5, which can get expensive in terms of both tokens and time if the output from our tool is large.
Is there functionality or design pattern to work around this? I think it would really help push the composability of agents even further than you already have with this SDK!
Real world usecase: I have an agent whose goal it is to retrieve a chunky piece of content. It has ~5 tools at its disposal. The "main" tool actually retrieves the data, the other tools help the agent determine the correct parameters with which to invoke the main tool. I would like to then use this "data retrieval agent" inside other agents which can then use this dataset to do interesting things.
I can work around this by making my "data retrieval agent" only return the correct parameters with which to call the main tool, and leave the actual retrieval to other agents, but then it feels like my agent isn't encapsulating a nice isolated chunk of work.
Love the library so far, thanks for your work!