Characters an assistant content block occupies once it is back in the prompt.
(b)
| 87 | |
| 88 | /** Characters an assistant content block occupies once it is back in the prompt. */ |
| 89 | function assistantBlockChars(b) { |
| 90 | if (b.type === 'text') return (b.text || '').length; |
| 91 | if (b.type === 'thinking') return (b.thinking || '').length; |
| 92 | if (b.type === 'tool_use') return JSON.stringify(b.input ?? {}).length + (b.name || '').length; |
| 93 | return JSON.stringify(b).length; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Parse one session (its segment files, in order) into tool + occupancy stats. |