Repository navigation
Commit c2c187d
committed
fix(server): handoff budget estimates stored history in tokens, not bytes
When a provider reports no usage, T3 estimated the native session's
occupancy by counting every stored history byte as one token. About
100 KB of history (around 30k real tokens) then looked full against a
128k window, and switching back replaced the agent's native session with
a fresh one carrying only a bounded handoff.
Estimate that occupancy at ceil(UTF-8 bytes / 4), the same rule Codex
uses for its own count. The new turn and imported history keep their
pessimistic byte counts.
Fixes #23142
AI-assisted; verified with the tests and tools listed above.1 parent 3273abd commit c2c187d
3 files changed
Lines changed: 9 additions & 3 deletions
File tree
- apps/server/src/orchestration-v2
- testkit
- packages/provider-core/src/server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
998 | 999 | | |
999 | 1000 | | |
1000 | 1001 | | |
1001 | | - | |
| 1002 | + | |
1002 | 1003 | | |
1003 | 1004 | | |
1004 | 1005 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
513 | | - | |
| 513 | + | |
514 | 514 | | |
515 | 515 | | |
516 | 516 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
99 | 104 | | |
100 | 105 | | |
101 | 106 | | |
| |||
0 commit comments