Repository navigation
[EPIC-V][LOU-V8] AgentSession.stream() streams a session turn and persists it on done - #78
Merged
Merged
Conversation
…sists it on done
session.stream(input, { signal }) returns the same AgentRun as agent.stream().
It queues behind earlier calls, loads history, builds send()'s message list,
streams the turn, and records it exactly as send() does before delivering
run.done. Aborted or failed runs leave the transcript unchanged; an approval
pause is saved up to the pause and resumes via approvals.resolve().
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016bY29ibQgv3MDdjAbUT4YR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
AgentSession.stream(input, { signal? })returns anAgentRun(same type asagent.stream()).SessionStreamRunnertype next toSessionRunner;createAgent()'ssession()wiring passes(input, signal) => AgentExecutor.stream(executeOptions(input, signal)), reusing the existing stream implementation.src/session/sessionStream.ts: the handle wraps the inner run (the session must queue and load history before a run exists) under its ownrunId, and deliversrun.doneonly after the turn has been recorded.createAgentApprovals.session()binds a paused streamed turn to its session (onapproval.requestedand on the awaiting-approval result), soagent.approvals.resolve()continues it viacontinueTurn.Why
Epic V parity gap: sessions could only
send(), so a multi-turn conversation could not be streamed (audit lists "Sessions (multi-turn)" as a warning).Acceptance criteria
stream()loads history, builds the same provider-valid message list assend(), streams, and records the user message and run output through the samerecord()path assend()(same ordering rules, same awaiting-approval handling,continueTurnafterapprovals.resolve()).send(): an aborted run (signal, or leaving the loop early while the run is unfinished) or a failed run persists nothing; documented in the JSDoc and docs/sessions.md.SessionStreamRunneradded;createAgent.tsedited only in thesession()wiring (3-line diff).mockModel: ordered events withtext.deltas andrun.done, store holds the turn atrun.done, secondstream()sees history (and mixes withsend()), abort by signal, early loop exit, failed run, load/save failures, approval pause resumed viaapprovals.resolve(), resolve called fromapproval.requested.How verified
npx tsc --noEmit: passnpm run lint: 0 errors, 433 warnings (none in the changed files)npm run test:types: no errorsnpx vitest run: 138 files passed, 2031 tests passed, 3 skippednpm run build && npm run build --workspace=packages/create-loushy-agent: passnpm run docs:verify-snippets -- --skip-build: all 93 snippets type-check, 6 also runnpm run docs:llms:check: passnpm run test:coverage: 138 files, 2031 passed (one earlier run had a load-flaky pid-file test in NodeWorkspace.test.ts, which passes in isolation and on re-run);npm run fallow: exit 0, no dead code, the only clone group is the existing AnthropicProvider/OpenAIProvider one🤖 Generated with Claude Code
https://claude.ai/code/session_016bY29ibQgv3MDdjAbUT4YR
Generated by Claude Code