magi-code 0.102.2

Repository-aware CLI coding agent for terminal work
Documentation
<!-- Generated by generate-agent-docs; preserve verified project-specific guidance when regenerating. -->
# Context guide

Parent: [source guide](../AGENTS.md).

Reconstructs provider conversations from session history and estimates request budgets.

## Where to look

| Change | Owner |
| --- | --- |
| Context types/event visibility | `../context.rs` |
| Ordered turns and compaction cutoff | `replay.rs`, `replay/builder.rs` |
| Incomplete-stream recovery | `replay/recovery.rs` |
| In-memory replay reuse | `replay_cache.rs` |
| Local token projection | `tokens.rs` |
| Profiling-only cache material/workloads | `profiling/cache_material.rs`, `profiling/` |

## Local contracts

- Replay filtering is separate from tolerant JSONL parsing in `../sessions/read.rs`. Local events/reasoning summaries are not ordinary provider messages.
- Reconstruct ordered turns and matched calls/results, not flat payload lists. Preserve failed/cancelled assistant text from terminal records.
- Apply shared prompt-injection projection before output compaction. Match later `ToolResultAssessment` by unique result ID/session/call/enforcement, allowing background events between records. Require complete coverage and matching redacted stored bytes/hash; withhold pending or unmatched enforced output. Assessment warnings stay local.
- Replay `reasoning_selection` immediately before its user message, including partial turns. Compaction cutoff resets baseline with retained prefix.
- Checkpoint `execution_effects` follows model summary as separate bounded evidence. Do not reconstruct checkpoint prefix from later results or infer no writes from clean final diff.
- `ConversationReplayCache` validates session identity, generation, file stamps and content digest; file size alone cannot establish reuse.
- Cache-material serialization lives under `profiling/` only. Normal runs neither read nor write disk conversation snapshots; leave existing snapshots untouched.
- Token estimates are not observed usage; keep projection changes aligned with agent request construction.
- `tokens.rs` uses `magi_tokenizer::count_ordinary` for supported Codex `o200k_base` models, preserving pre-tokenization and treating special-token strings as ordinary text. Other models/providers use the character-count fallback. Preserve fixed overhead and fallback provenance; offline measurement rejects unsupported models. Tables are embedded at build time, with no runtime initialization or download.