feat: Add tool result offloading#11849
Draft
sjrl wants to merge 8 commits into
Draft
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Proposed Changes:
Added tool result offloading for the
Agentvia the newhaystack.hooks.tool_result_offloadingmodule.ToolResultOffloadHookis anafter_toolhook that writes selected tool results to aToolResultStoreandreplaces them in the conversation with a compact pointer (reference plus a short preview), so the next LLM call
sees a reference instead of the full result. This helps manage the context window and is a step towards letting an
Agent operate on offloaded results with follow-up tools (e.g. a bash tool reading the referenced files).
Configure what gets offloaded, per tool, via
offload_strategies:"*"to anOffloadPolicy. More specific keys win over"*"; a tool with no matching key is not offloaded.AlwaysOffload,NeverOffload, andOffloadOverChars(threshold)(offload when the resultexceeds a character threshold).
OffloadPolicyprotocol (it provides defaultto_dict/from_dict, so astateless policy only needs a
should_offloadmethod).Choose where results are stored:
FileSystemToolResultStorewrites results to the local file system.ToolResultStoreprotocol to target other backends.hook_context.What is offloaded:
before_toolhuman-in-the-loop rejections)are left in context.
A warning is logged when a non-text result has a matching offload policy.
How did you test it?
Added new tests.
Notes for the reviewer
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.