-
Notifications
You must be signed in to change notification settings - Fork 440
feat(hooks): elide repeated read-only tool results instead of re-sending them #3940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dwin-gharibi
wants to merge
13
commits into
docker:main
Choose a base branch
from
dwin-gharibi:feat/tool-result-cache
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f3fa133
feat(pkg/runtime/toolexec/dispatcher.go): adding up readonly tool cac…
dwin-gharibi 7f5659f
feat(pkg/hooks/builtins/elide_repeated_tool_results.go): adding up th…
dwin-gharibi eaf0fa3
test(pkg/hooks/builtins/elide_repeated_tool_results_test.go): adding …
dwin-gharibi f35b877
feat(hooks): expose tool category and read-only hint on every tool event
dwin-gharibi 7b2414c
fix(hooks): scope elision to what it can deliver, and drop state when…
dwin-gharibi 8673190
test(hooks): cover the limit_large interaction and context rebuilds
dwin-gharibi aa49c67
docs(hooks): document elide_repeated_tool_results
dwin-gharibi f6a1397
Merge remote-tracking branch 'upstream/main' into feat/tool-result-cache
dwin-gharibi 449a33e
Merge remote-tracking branch 'upstream/main' into feat/tool-result-cache
dwin-gharibi 63593a7
fix(hooks): send tool_category and tool_read_only on permission_request
dwin-gharibi b10947d
fix(hooks): ask limit_large_tool_results whether its rewrite would win
dwin-gharibi 6232582
fix(hooks): wire the elide cleanup legs from the transform opt-in
dwin-gharibi 8545844
docs(hooks): correct the elide builtin's categories and effective range
dwin-gharibi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #!/usr/bin/env docker-agent run | ||
| # | ||
| # Opt in to eliding repeated read-only tool results. | ||
| # | ||
| # When a read-only tool returns output byte-for-byte identical to what the model | ||
| # already saw for the same arguments in this session, the payload is replaced | ||
| # with a one-line marker instead of being repeated. An agent that re-reads the | ||
| # same file across turns pays for it once. | ||
| # | ||
| # This is NOT a cache: the tool always runs and its fresh output is what gets | ||
| # hashed, so a changed file can never be served stale. The saving is in tokens, | ||
| # not latency. | ||
| # | ||
| # Whether the marker is good for model behaviour is unmeasured — some models may | ||
| # re-request the file anyway — which is why this is opt-in rather than on by | ||
| # default. | ||
|
|
||
| agents: | ||
| root: | ||
| model: claude | ||
| description: An agent that does not pay twice for the same file. | ||
| instruction: | | ||
| You are a helpful assistant working in a code repository. | ||
| Read files as you need them. | ||
| toolsets: | ||
| - type: filesystem | ||
| hooks: | ||
| # This entry is the whole opt-in. The builtin also needs its state | ||
| # dropped on session_end, after_compaction and session_start — compaction | ||
| # and a context reset remove the very messages a fingerprint stands for, | ||
| # and keeping it would tell the model "nothing has changed" about bytes it | ||
| # can no longer see. Those three legs are wired automatically from this | ||
| # one, so they are part of the feature rather than something to remember. | ||
| # Writing them out by hand is harmless: identical entries are deduplicated. | ||
| tool_response_transform: | ||
| - matcher: "*" | ||
| hooks: | ||
| - type: builtin | ||
| command: elide_repeated_tool_results | ||
|
|
||
| models: | ||
| claude: | ||
| provider: anthropic | ||
| model: claude-sonnet-4-5 |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.