tool-call proactive hints: detect throwaway heredoc waste#69
Merged
Conversation
Session mining found 9K+ throwaway inline scripts (~2.3M wasted tokens) across 300 real sessions. Top waste: Linear API heredocs (1,632x), GCloud heredocs (2,264x), JSON processing (775x). New intervention: detect when agent writes a heredoc for an operation that has an existing repo tool, and append a "better alternative" hint to the tool_result. Fires once per hint ID per session (deduped). Patterns: linear query/mutation, gcloud logging/deploy, json->jq, subprocess->direct shell. Part of the waste taxonomy: - 55% of wasted tokens are Linear + GCloud heredocs - Same 2-3 operations repeated 4000+ times across sessions - A single reusable tool/extension for each would eliminate most waste
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.
Summary
New "proactive hint" channel: detect when the agent writes throwaway heredoc scripts for operations that have existing repo tools.
The problem (mined from 300 real Pi sessions)
2.3M wasted tokens ($35 at codex rates)linear_consolidation.pyexistsThe fix
Detect reinvention patterns on
tool_calland inject "better alternative" hints ontool_result:pants run scripts:linear_consolidation -- dumppants run sophon/scripts:triage_prod_logsjqWaste taxonomy (from session mining)
Testing
28 test files, 164 tests pass. New test file:
tests/tool-call-hints.test.ts.