Commit graph

5 commits

Author SHA1 Message Date
Austin Schaefer
f53fcbd937 refactor: extract the streamed-text draining loop into its own module
write_text_stream() in the new stream.rs doesn't touch anything specific
to write_report (topic, findings, the agent) — it just drains a
MultiTurnStreamItem stream, writes each text chunk to a caller-provided
writer, and returns the accumulated string. Pulling it out lets it be
covered by unit tests against a mocked stream and an in-memory writer,
independent of a live model.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-17 12:37:11 +02:00
Austin Schaefer
b12f156a1b simplify: match the streamed Text item without destructuring its fields
No destructuring needed since only .text is used; matching the whole
Text struct and drops the now-unused rig::message::Text import.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-17 12:30:21 +02:00
Austin Schaefer
4f32dd83d6 perf: lock stdout once for the whole report stream, not per chunk
print!/println! each acquire stdout's lock internally; doing that per
streamed chunk in a tight loop adds needless contention. Lock once up
front and write!/writeln! through the held handle instead — which also
means the trailing newline must go through that same handle rather than
println!, since re-locking from the same thread would deadlock.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-17 12:20:35 +02:00
Austin Schaefer
469b7cf8c6 simplify: use print! + flush for streamed chunks, not an explicit stdout lock
print! already locks stdout per call, so the manual lock()/write!() was
extra ceremony over what the flush actually needed. Matches rig's own
cli_chatbot streaming example more closely.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-17 12:19:08 +02:00
Austin Schaefer
55f4f7eeb3 feat: stream the report to the terminal as the writer generates it
Wires up starter.rs -> core.rs (CLI parsing and observability init moved
into core, main.rs left as a thin entry point) and switches the report
phase from Agent::prompt to rig's stream_prompt, printing each text
delta to stdout as it arrives instead of waiting for the full response.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-17 12:17:26 +02:00
Renamed from deep_research/src/starter.rs (Browse further)