Skip to content

feat(ai): streaming agent loop (AI-037a)#326

Merged
mrviduus merged 1 commit into
mainfrom
ai-037a-agent-streaming
Jun 14, 2026
Merged

feat(ai): streaming agent loop (AI-037a)#326
mrviduus merged 1 commit into
mainfrom
ai-037a-agent-streaming

Conversation

@mrviduus

Copy link
Copy Markdown
Owner

Phase 6 AI-037, slice a — the loop streams its steps so the reader can watch the agent work. The SSE endpoint + run persistence + GET /me/studybuddy/runs/{id} are slice b.

Changes

  • AgentLoop.StreamAsync — yields an AgentEvent per step as it happens (llm_response / tool_result), then a terminal Done event carrying the final AgentResult. RunAsync is now built on top of it (consumes to the Done result), so non-streaming callers (the AI-039 eval) are unchanged: behaviour is identical, and budget exhaustion still throws AgentBudgetExhaustedException (with its partial transcript) after the steps have streamed.
  • AgentEvent (Ai.Agents) — a step-or-result union (OfStep / Done, exactly one non-null).
  • StudyBuddyAgent.StreamAsync — same prompt / tools / $0.05 budget as RunAsync; both share one BuildAgentInput.

Verification

  • AgentLoop.StreamAsync: step events in order then a single terminal Done (last event); budget exhaustion streams the partial steps to the consumer then throws, with no Done event.
  • StudyBuddyAgent.StreamAsync: config threading → step + Done.
  • All 8 prior AgentLoop/StudyBuddy tests still green (RunAsync unchanged externally). Full TextStack.UnitTests (270) green; dotnet format clean.

🤖 Generated with Claude Code

AgentLoop.StreamAsync yields an AgentEvent per step as it happens, then a
terminal Done event with the final AgentResult; RunAsync is rebuilt on top
(behaviour identical, budget exhaustion still throws with its transcript).
StudyBuddyAgent.StreamAsync streams with the same config. The SSE endpoint +
persistence + GET run are AI-037b.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mrviduus mrviduus merged commit ceaef6c into main Jun 14, 2026
5 checks passed
@mrviduus mrviduus deleted the ai-037a-agent-streaming branch June 14, 2026 23:52
mrviduus added a commit that referenced this pull request Jun 15, 2026
A scheduled health check landing inside the ~25-min deploy window saw the API
container restarting (connection-refused / brief 5xx) and false-failed: the
smoke checks used only '--retry 2' with no delay (~3s of retry). Unified all
checks onto one retry policy (--retry 5 --retry-delay 15 --retry-all-errors
--retry-connrefused, ~75s) so a deploy restart is ridden out instead of paging.
Prod was verified healthy at fix time; the 00:10 failure was mid-deploy of #326.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant