Repository navigation
Stream agent investigate turn by turn - #39
Conversation
The loop is now a generator of turns and tool calls; investigate() drains it. The command streams one event per turn and per call, then the saved record, so a watcher sees the agent work as it happens. --no-stream returns all events in one envelope. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01APTdZZw8Jw9PQF4TD55wMv
The error line of a streamed agent investigate holds no data: the record is the event of kind investigation just before it. The exit code's description and suggestion still sent the reader to data.investigation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep both Unreleased entries; the stream's entry names rc38's line shape. The tests read bare event lines with _seq and the _summary end line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@romamo Decision needed: the stream can lose the investigation record. Should #39 merge before that's fixed? Review result: MERGE AFTER SMALL FIX, with one regression left open. Pushed to the branch as fast-forwards, with no rewrite:
The regression. Start
Reply here with a number or your own answer; shipmill takes this up on the tick after your reply. |
Since agent investigate streams (PR #39), a reader closing stdout mid-run left the decisions the model proposed without the investigation that made them, and the command exited 0: treaty closes the handler's generator on a broken pipe and ends a stream that delivered an event with exit 0. investigation_events now returns the investigation so far, ended with the new status stopped, when it is closed, and the handler saves it before re-raising GeneratorExit, so nothing more reaches the dead stdout. treaty gives the handler no say in the exit code of a closed output, so the handler sets cloudfall.app.stream_stopped and cloudfall.cli turns treaty's 0 or 141 into 94 INVESTIGATION_STOPPED. A signal or a timeout keeps its own exit code; --no-stream is unchanged. Fixes #44 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
investigation_events()is the loop as a generator ofTurn(the model's words, how many tools it called) andCalled(the step and the tool's result);investigate()drains it, unchanged for callersagent investigateis a treaty streaming command: one line per turn, one per call (effect: createdwhen it wrote a decision), the saved record last (kind: investigation), then the end line withmeta.effects.--no-streamgives every event in one envelope; failures still end the stream with exit 92 or 93, after the saved recordWhy
The hosted hackathon demo shows the agent working as it happens. It also makes the CLI watchable.
Contract change
agent investigateis unreleased, so its output changes before anyone depends on it: the record moved fromdata.investigationto thekind: investigationevent.Checks
uv run pytest: 396 passed (CLI tests read the stream; a new test checks the order turn, call, turn, investigation and the end line)uv run ruff check .,uv run mypy: clean🤖 Generated with Claude Code
https://claude.ai/code/session_01APTdZZw8Jw9PQF4TD55wMv