The messages array is where the context lives
Every model call sends the entire list. Slot height is drawn to token weight (~chars/4). Real 21-message run.
cool
file/log bulk
tool args bloat
messages at turn 21
passed verbatim to the model
50.5k chars
messages = [
[0] user · task
81
[1] model · tool_call read_file
59
[2] tool · ack (queued)
78
[3] user · <read_file> body
14.5k
role=user · hot slot
[4] model · tool_call read_file
49
[5] tool · ack (queued)
79
[6] user · <read_file> body
6.9k
role=user · hot slot
[7] model · tool_call execute
63
[8] tool · pytest traceback
3.4k
role=tool · hot slot
[9] model · tool_call edit_file
2.6k
[10] tool · ack
25
[11] model · tool_call write_file
15.0k
role=model · hot slot
[12] tool · ack
49
[13] model · tool_call execute
63
[14] tool · pytest pass
311
[15] model · summary
92
[16] user · follow-up
60
[17] model · tool_call read_file
49
[18] tool · ack (queued)
79
[19] user · <read_file> body
6.9k
role=user · hot slot
[20] model · working
70
]
messages after wrap_generate
prefix compacted; [15:] keep window verbatim
9.1k chars
messages = [
[0] user · task
81
[1] model · tool_call read_file
59
[2] tool · ack (queued)
78
[3] user · <read_file> body
153
[4] model · tool_call read_file
49
[5] tool · ack (queued)
79
[6] user · <read_file> body
152
[7] model · tool_call execute
63
[8] tool · pytest traceback
152
[9] model · tool_call edit_file
372
[10] tool · ack
25
[11] model · tool_call write_file
222
[12] tool · ack
49
[13] model · tool_call execute
63
[14] tool · pytest pass
311
[15] model · summary
92
[16] user · follow-up
60
[17] model · tool_call read_file
49
[18] tool · ack (queued)
79
[19] user · <read_file> body
6.9k
role=user · hot slot
[20] model · working
70
]
→
wrap_generate
await ai.generate(messages=messages, ...)
all 21 slots ride along on every subsequent call until compaction shrinks the prefix
Hot zones: messages[3], [6], [8], [9], [11], [19] hold most of the ~12k tokens. Compaction targets the prefix; the tail stays verbatim.
Summarization (not shown) replaces a large prefix with one handoff message when usage crosses 85% of budget.