Commit ac0af56
authored
fix(agent): stop resume hydration from overfilling the context window
Cold-resume JSONL hydration selected up to 800k estimated tokens of
history at 4 chars/token, but JSON-heavy tool payloads tokenize at
~2.5-3 chars/token, so the rebuilt transcript could exceed the model's
real context window before the run even started. Because the hydrated
messages carry zero usage metadata, the SDK cannot auto-compact ahead
of the first API call, and every request (including compaction itself)
fails with "prompt is too long", permanently bricking the task on
every subsequent resume.
Estimate at 3 chars/token and target roughly half the window
(400k estimated for 1M-context models, 80k for 200k), leaving room
for the system prompt, tools, skills, and the resumed run's own work.
Generated-By: PostHog Code
Task-Id: c6065620-5694-4478-a20a-fec4ccde8f1a1 parent 886d163 commit ac0af56
1 file changed
Lines changed: 12 additions & 3 deletions
Lines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
245 | | - | |
246 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
247 | 256 | | |
248 | 257 | | |
249 | 258 | | |
| |||
0 commit comments