My team is building a distributed platform for teams to build and deploy agents. We are running into a design challenge in the case when an agent needs to define transformation logic for a specific tool’s inputs and/or outputs.
Let me focus on response truncation as a specific example of transforming the tool response.
Say we have the following:
- A shared
ToolLoopWorkflowthat specific agents can execute as a child workflow, passing it a prompt and a list of available tool definitions. This workflow will sequentially call an LLM and then the selected tools, in a loop. - A shared tool,
getReallyLongData, that returns a big JSON object that’s too big to put into an LLM. The workflow runs the tool by executed an activity (already defined on a remote machine). - A
DataAnalystAgentWorkflowthat callsToolLoopWorkflowas a child workflow, passinggetReallyLongDataas one of the available tools.
Since the response of getReallyLongData is too big to put directly into an LLM, my DataAnalystAgentWorkflow wants to inject a custom truncate_response() function that takes the output of getReallyLongData and returns a truncated string representation that can be fed into the LLM. That way, when ToolLoopWorkflow calls getReallyLongData, the response is run through truncate_response() before being passed back to the LLM.
The problem? I can’t pass truncate_response() to the workflow because it’s code, and I can’t inject it into the getReallyLongData tool activity’s logic because it’s a shared tool that’s defined in another project.
Is there something wrong with our approach? We’ve looked at defining hooks with Interceptors, but are not confident that’s how they’re intended to be used. Do we have to get rid of ToolLoopWorkflow and duplicate that logic for every workflow agent that needs that functionality?
Any pointers appreciated!