コンテンツにスキップ

Agent loop and sessions

このコンテンツはまだ日本語訳がありません。

The command-line interface (CLI) parses arguments, resolves configuration and providers, creates a session, streams model events, dispatches tools, and renders the resulting entries.

user message
-> cli.ts parse argv, resolve config and providers
-> session factory create or resume the session
-> provider stream AssistantMessageEvent deltas
-> tool dispatch execute, append result, loop
-> session JSONL append-only record
-> renderer view of the appended state

Start at packages/coding-agent/src/cli.ts, follow the session factory and event handlers, then inspect the persisted JSON Lines (JSONL) rather than relying only on terminal rendering. Provider and tool tests should assert the event sequence that caused the visible result.

Compaction transforms older conversation context before the next model turn; it does not rewrite the original session evidence. Test both the summary and subsequent message construction.

Trace a normal response, a tool-producing response, and an aborted response separately. Each path must append events in causal order, settle an active provider or tool only once, and leave a resumable leaf. To test compaction, force the configured threshold, capture the summary entry, resume from that leaf, and verify that the next model input includes the summary while the original JSONL entries remain readable. Rendering assertions belong after these state assertions because the TUI can repaint without changing the durable graph.