Repository navigation
Conversation
Rewrite all 17 tool description files in terse style to cut
per-message system prompt overhead. Estimated savings: ~6,250
tokens per message (33,163 → 11,302 chars), compounding across
multi-turn sessions.
Preserves:
- All git safety rules (amend conditions, force-push guards,
no-secrets, no -i flags, no empty commits, no-Task-during-commit)
- All placeholders (${os}, ${shell}, ${chaining}, ${maxLines},
${maxBytes}, {{year}}, ${directory})
- apply_patch format block (Begin/End Patch, Add/Update/Delete
File, Move to, + prefix rule)
- 9 LSP operations + required params
- 4 todo states + one-in-progress rule
- Read-before-Edit requirement
- GitHub URL → gh routing
Retains behavioral anchors:
- bash.txt: workdir and quoting good/bad examples, parallel call
example
- edit.txt: concrete oldString prefix example (42: const x = 1 →
strip '42: ')
- read.txt: foo\n → 1: foo\n format anchor
- todowrite.txt: 3 compressed examples (use multi-feature, use
discover-scope, skip trivial)
- task.txt: proactive code-reviewer pattern
Per-file cut:
bash.txt: 9288 → 2821 (70%)
todowrite.txt: 8845 → 1701 (81%)
task.txt: 3732 → 1041 (72%)
edit.txt: 1369 → 674 (51%)
read.txt: 1158 → 581 (50%)
apply_patch.txt: 1098 → 669 (39%)
lsp.txt: 1040 → 515 (50%)
websearch.txt: 976 → 443 (55%)
codesearch.txt: 802 → 348 (57%)
webfetch.txt: 750 → 247 (67%)
grep.txt: 689 → 359 (48%)
question.txt: 657 → 394 (40%)
write.txt: 623 → 290 (53%)
plan-enter.txt: 613 → 406 (34%)
plan-exit.txt: 579 → 318 (45%)
glob.txt: 545 → 234 (57%)
skill.txt: 399 → 261 (35%)
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
@MartinWie when do we expect this to land and which version will it be available? the token usage is insane! Also is there a way to override these tools in current versions while this is being delivered? |
|
@mohammadidinani atm not expecting this to land at all, but let's see if someone reviews and approves my PR, I am not an official maintainer, but thought about applying because I like the tool, let's see. Here is the related issue I opened -> #11995 But you can check out this branch locally and build the binary yourself, maybe also merge in this one here -> #24210 It adds a "/context" command to give you some insight into what really fills your context. I also have one PR in the pipeline that let's users view the full context of a message, to have full transparency on the context they send to providers. |
|
would love to see this merge seems like an obvious win and pretty important for local models that have tight constraints on context |
|
Any update on this? Seems desperately needed. With heavier models this is really killing the flow of things. |
|
with 3.7k open issues, probably nobody is reading this |
Issue for this PR
Refs #11995
Type of change
What does this PR do?
Condenses all 17 tool description files in
packages/opencode/src/tool/*.txtinto a terser style to cut system-prompt token overhead. These files are imported as raw strings and injected into every LLM turn's tool descriptions — per @DrDexter6000's analysis in #11995 they are NOT cacheable, so every character costs tokens on every request.Why the changes work:
.txtfiles are loaded viaimport DESCRIPTION from "./bash.txt"(same pattern in task.ts, apply_patch.ts, todo.ts, websearch.ts, etc.) and injected into the model's tool schema. Nothing parses them as structured data — the model reads them as natural-language instructions. Shorter, denser wording preserves instruction-following while reducing token cost.${os},${shell},${chaining},${maxLines},${maxBytes},${directory},{{year}}) use.replaceAll/.replacewhich are no-ops if the placeholder key is absent — so presence in the text is what matters, and all keys were preserved where originally used.42: const x = 1→ strip prefix example inedit.txtprevents a common failure mode where the model includes theN:line prefix inoldString.Impact:
Per-file breakdown (largest first):
What's preserved:
-iflags, no empty commits, no Task/TodoWrite during commit, unclear-intent-ask-first, GitHub URL →ghrouting)+prefix rule)Behavioral anchors retained (after a second review pass that judged the first cut too aggressive):
bash.txt: workdir and path-quoting good/bad pairs, parallel call exampleedit.txt:42: const x = 1→ strip42:prefix exampleread.txt:foo\n→1: foo\nformat anchortodowrite.txt: 3 compressed examples (use multi-feature, use discover-scope-then-list, skip trivial)task.txt: proactive code-reviewer patternWhat was dropped:
<reasoning>blocks after each todowrite exampleHow did you verify your code works?
rgacrosspackages/opencode/src/tool/..txtfiles are consumed only as raw strings byimportstatements in adjacent.tsfiles — no schema parsing, no format-sensitive consumers..txtcontent only..tsconsumers untouched.Screenshots / recordings
N/A — no UI change.
Checklist