Commit 4812d9b
fix: reduce context bloat and surface observation masks after pruning
Three generic context efficiency improvements:
1. Surface `observation_mask` for pruned tool outputs in `toModelMessages`
instead of opaque "[Old tool result content cleared]". The mask was
already computed by `SessionCompaction.prune()` but never used —
gives the model post-compaction awareness of what it previously read.
2. Remove dead `<directories>` block from `SystemPrompt.environment()`.
The tree was permanently disabled via `&& false`, leaving an empty
XML tag wasting ~30 tokens per API call.
3. Compact skill descriptions in tool schema from 4-line XML per skill
to single-line `<skill name="...">description</skill>`. Drops unused
`<location>` URLs. Cuts skill listing size by ~60%.
Includes 8 e2e tests validating all three changes without mocking.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 053e635 commit 4812d9b
5 files changed
Lines changed: 545 additions & 23 deletions
File tree
- packages/opencode
- src
- session
- tool
- test
- session
- tool
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
634 | 634 | | |
635 | 635 | | |
636 | 636 | | |
637 | | - | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
638 | 640 | | |
639 | 641 | | |
640 | 642 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
4 | 2 | | |
5 | 3 | | |
| |||
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 39 | | |
52 | 40 | | |
53 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
45 | 41 | | |
46 | 42 | | |
47 | 43 | | |
| |||
0 commit comments