Commit 13a21c7
Strip heavy fields from LLM-facing result data (#4886)
Goal is basically to make sure that the agent can actually see all
relevant data when calling report_result. To not pollute its context
window, we clamp the return content, but previously the return content
also included the source bank, for example.
CLAUDE:
## Summary
- Strip `_source_bank`, `research`, and `provenance_and_notes` fields
from LLM-facing result data while keeping them in `structuredContent`
(widget)
- Update `clamp_page_to_budget` to estimate tokens on stripped records,
matching what the LLM actually receives
These fields contain full citation databases and research notes (25-30k
chars per row). For a 7-row agent task, this caused the token budget
(10k) to clamp results from 7 rows down to 1-4, producing messages like
"I can only see 1 of the 7 rows". After stripping: ~16k tokens → ~1k
tokens (94% reduction). Users still see all fields in the viz pane.
## Test plan
- [ ] Run an agent task with 7+ rows and verify all rows appear in the
LLM response (no "I can only see X of Y" message for small datasets)
- [ ] Verify research notes and citations are still visible in the viz
pane widget
- [ ] Verify CSV download still contains all fields
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sourced from commit 63d0ba0dabf0374e982f89b41daddd5465db11cf1 parent 71efe48 commit 13a21c7
2 files changed
Lines changed: 19 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
60 | 71 | | |
61 | 72 | | |
62 | 73 | | |
63 | 74 | | |
64 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
65 | 78 | | |
66 | 79 | | |
67 | 80 | | |
68 | 81 | | |
69 | 82 | | |
70 | 83 | | |
71 | | - | |
| 84 | + | |
72 | 85 | | |
73 | 86 | | |
74 | 87 | | |
| |||
188 | 201 | | |
189 | 202 | | |
190 | 203 | | |
191 | | - | |
192 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
193 | 207 | | |
194 | 208 | | |
195 | 209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
859 | 859 | | |
860 | 860 | | |
861 | 861 | | |
862 | | - | |
| 862 | + | |
863 | 863 | | |
864 | 864 | | |
865 | 865 | | |
| |||
0 commit comments