ai icon indicating copy to clipboard operation
ai copied to clipboard

Agents/Tool Calling: Pass data to subsequent steps without showing it to the LLM (return of execute())

Open williamlmao opened this issue 8 months ago • 2 comments

Feature Description

Right now when you return data from execute within a tool, that data is included in the next request to the LLM.

It would be nice if we were able to return some data that could be accessed in following steps or outside of the agent loop, that is nicely tied to a specific step.

Currently this is possible by keeping external state, but it's kind of ugly.

This is especially important if you have larger data that the LLM does not need to see.

Use Cases

Tool 2 requires variables/state determined in Tool 1, but the LLM does not need to see that data.

Additional context

I'm not sure what the right design for this would be, but think it could be nice for the return type of execute to have two fields:

{ exposed: hidden: }

exposed goes to the LLM (like how it does currently) and hidden: does not. Can use a type guard to make this backwards compatible, if these keys are not seen then we just treat it the same way it is now.

williamlmao avatar Apr 08 '25 21:04 williamlmao

I'm running into a similar use case, maybe it would be better to use the ai's provider package directly? I couldn't find any other issue with this specific problem

leocabeza avatar Apr 09 '25 03:04 leocabeza

Same use case here, any other solutions?

thiagomconte avatar Apr 23 '25 12:04 thiagomconte