feat(tool-context): compact large tool results before replay#30980
Open
energypantry wants to merge 1 commit into
Open
feat(tool-context): compact large tool results before replay#30980energypantry wants to merge 1 commit into
energypantry wants to merge 1 commit into
Conversation
Collaborator
Author
|
Thanks for the pointer. I reviewed #29454 and #28098. I agree this overlaps with the same tool-result/context-pressure problem space. My intent with this PR was to propose a smaller insertion-time, context-only compaction path that keeps user-visible/log output raw while reducing only the message replayed into model context. If maintainers prefer the #29454 opt-in raw-storage direction or the #28098 plugin direction, I’m happy to adapt this PR, close it, or extract any useful tests/config/docs into whichever implementation you want to consolidate around. |
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.
Fixes #415
Refs #513
What does this PR do?
This PR adds insertion-time tool result compaction so large tool outputs are reduced before they are appended back into the model conversation. The goal is to keep recent tool calls useful without letting raw HTML, long terminal output, or large JSON/file payloads dominate the next prompt before normal context compression has a chance to run.
The approach is deterministic and cache-friendly: it compacts only the tool-result message being appended, leaves TUI/log callbacks on the raw tool result, and avoids LLM summaries or external vector storage.
Related Issue
Fixes #415
Refs #513
Type of Change
Changes Made
agent/tool_context_policy.pywith deterministic compaction for terminal, file, web/HTML, JSON, and generic tool results.make_tool_result_message().tool_contextdefaults tohermes_cli/config.pyandcli-config.yaml.example.website/docs/user-guide/configuration.md.tests/agent/test_tool_context_policy.py.How to Test
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
N/A
Screenshots / Logs
Focused tests: