Chapter 45: Computer-Use Context Management
A screenshot budget is not one number. Text observations, browser screenshots, and user-provided images have different value and must have different lifecycles.
Public-source snapshot: implementation details are examples from public Kocoro
origin/mainat commit4ec6772, reviewed 2026-07-27. Re-check constants against current source.
45.1 Why Computer Use Expands Context So Quickly
A browser loop can add a DOM snapshot, accessibility tree, screenshot, and model response on every step. Resending all prior observations makes prompt cost grow with the full history even though the next action usually depends on the current page.
One global image limit is unsafe. A batch-vision task may need many user images, while a browser Agent normally needs only the latest viewport. Text observations require a separate sliding window because they are not image blocks.
45.2 Four Independent Controls
| Control | Snapshot default | Purpose |
|---|---|---|
| Text observation window | 3 | Keep recent browser/GUI text at full fidelity |
| Per-observation text cap | 24,000 runes | Bound one oversized DOM or page snapshot |
| Browser screenshot retention | 1 | Keep the current viewport, stub older GUI screenshots |
| Global image-message ceiling | 50 | Protect long non-browser vision and batch-image tasks |
These values are workload choices, not universal constants. The architecture matters: each control owns one failure mode, preserves tool_use_id pairing, inserts an explicit placeholder, and is idempotent so repeated filtering does not keep changing the prompt prefix.
45.3 Lifecycle and Verification
Prompt pruning does not imply deletion of the backing screenshot file. Context assembly, audit retention, local cleanup, and user-upload ownership are separate policies. The model should also be told when content was removed or truncated; silent loss makes later reasoning impossible to audit.
45.4 Implementation Checklist
- Separate browser/GUI observations from user uploads and ordinary tool output.
- Preserve the newest actionable state and explicit truncation markers.
- Test nested image blocks, multilingual rune limits, idempotency, and cache stability.
- Tune budgets from real task success and token traces, not from a single demo.
45.5 Takeaway
Computer-use context management is an observation policy: retain what can still change the next action, summarize or stub stale state, and keep unrelated image workloads under their own budget.