You're correct that your function's response is fed back. `runWithTools` calls `env.AI.run` multiple

You're correct that your function's response is fed back.
runWithTools
calls
env.AI.run
multiple times, and tool calls + tool responses are added to a temporary copy of the message history. The final response is (re)generated by calling
env.AI.run
one last time without passing any
tools
array.

So you'd have to modify
runWithTools
or write your own to get the behavior you want. The implementation is (IMHO) kinda difficult to follow, though. I've written a tiny version (https://gist.github.com/Raylight-PWL/7487b4210e593e00fffcab4f7abe0189#file-3_runwithtoolsx-js) that might be easier, since the part about "embedded" is written as a separate usable component ("runEmbedded") and sounds close to what you want.
Was this page helpful?