fix(agent): update OutputInputImage re-export for SDK compat and persist user input#48
Conversation
…ist user input - Replace removed `OutputInputImage` with `OutputImage` + backward-compat alias (`OutputImage as OutputInputImage`) after @openrouter/sdk dropped the old export name. - Persist fresh user input items to state only after the API call succeeds, preventing duplicates on transient retries. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
|
🤖 PR Patrol — I implemented both review threads locally and validated the result (full agent suite 392 tests pass, Threads left open for a human / the PR author (not resolved, since no fix was published):
The fix I prepared (ready to apply + push by someone with write access):
Note on the unsigned commit: Patrol did not resolve any threads — they remain genuinely unaddressed on the remote. |
Move fresh user-item persistence from initStream (after ok:true) to saveResponseToState (after stream consumption). Previously, an ok:true response followed by a mid-stream failure would leave the user turn in state with no assistant reply — on retry the same input was appended again, producing duplicates. Now user input and assistant output land atomically in a single saveStateSafely call: if the stream fails, neither is written, so a retry starts clean. Adds a streaming-failure regression test (ok:true + stream error + retry) to user-input-persistence.test.ts. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
|
Both threads from Perry's review are resolved in ce00bf9:
Build, lint, typecheck, and all 295 unit tests pass. |
|
🤖 PR Patrol — blocked (cannot push commits) I attempted to address the 2 open review threads on this PR but cannot publish any commit to this branch. Both of Perry's write-capable GitHub App tokens (intern-worker and maintainer) return
No threads were resolved — they remain open for a human with write access. Prepared fix #1 — Prepared fix #2 — To unblock: a GitHub org admin needs to install Perry's maintainer GitHub App with |
Add assistant-item assertion to the streaming-failure regression test, making the atomicity invariant explicit: after a successful retry, both exactly one user turn and one assistant turn are present in state. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
|
🤖 PR Patrol — blocked: Perry has no write access on I re-verified all three review threads against the current code, but all write operations on this org return 403 / FORBIDDEN (both the intern-worker and maintainer GitHub Apps lack Thread status (verified against
Prepared fix for the nit — in the streaming-failure test, after expect(userItems[0]!.content).toBe('Hello');
// atomicity invariant: the assistant message landed alongside the (single) user turn
expect(
messages.filter((m) => m.role === 'assistant' || m.type === 'message')
.length,
).toBe(1);
To unblock fully, a human with push access (or a GitHub org admin installing Perry's maintainer App with
|
|
🤖 PR Patrol — I reviewed all 3 unresolved review threads. All three are my own earlier review comments, and @Cybourgeoisie has already replied addressing each one:
These threads look ready to resolve, but I could not resolve them or otherwise act on this PR — Perry's GitHub App has no write access on
🔴 Primary merge blocker — 3 unsigned commits (the org's signed-commit ruleset will reject the merge):
All three show 👤 Human action required (a maintainer with write access on
To let Perry handle |
There was a problem hiding this comment.
⚠️ APPROVE unavailable on this installation — the maintainer GitHub App does not havepull_requests: writegranted on OpenRouterTeam. The verdict below is LGTM but posted as COMMENT.
Perry's Review
Fixes user input persistence atomicity: defers writing the user turn to state until saveResponseToState succeeds, adding a pendingFreshItems buffer; adds tests for stream-failure atomicity, retry dedup, and the missing assistant assertion.
Verdict: ✅ LGTM
Details
CI: all passing ✅
Findings: All three prior threads are addressed:
pendingFreshItemspattern correctly defers user-turn persistence until the response is saved — stream failures no longer orphan user input.- The streaming failure test (
ok:true+ erroringReadableStream) exercises exactly the path that was missing. - The nit (
assistantItems.lengthassertion) is now in place.
Security: no concerns
Test coverage: well covered — 7 unit tests covering array input, string input, tool-call persistence, multi-turn continuity, stream failure, and API-failure retry.
Unresolved threads: none — all three are now addressed by this push.
Scope: incremental — 4 new lines since prior review
| expect(userItems.length).toBe(1); | ||
| expect(userItems[0]!.content).toBe('Hello'); | ||
|
|
||
| const assistantItems = messages.filter((m) => m.role === 'assistant' || m.type === 'message'); |
There was a problem hiding this comment.
[nit] consider also asserting assistantItems[0]!.type === 'message' to make the shape expectation explicit — currently the filter matches both role === 'assistant' and type === 'message' but doesn't verify which branch matched
Reviewed at 7b6704a
There was a problem hiding this comment.
Skipping this one — the textResponse helper always produces { type: 'message', role: 'assistant' }, so both branches match the same item. Adding a type assertion doesn't verify anything new here and would just be testing the test fixture.
|
🤖 PR Patrol — review-thread status (action required by a human with write access) Patrol ran against the 4 open review threads but cannot complete the mechanical close-out because Perry's GitHub App lacks write/resolve permissions on the
Thread status (all are Perry's own review comments):
Blocking-merge note: the 3 commits on this branch ( To unblock Perry's patrol on |
|
🤖 PR Patrol — blocked: no write access on Perry attempted to address the 4 unresolved review threads on this PR but cannot complete the patrol because none of its GitHub App tokens (intern-worker, maintainer, reviewer) have • Consequences: Threads left open (for a human / the author to address): Resolution requires a GitHub org admin to install Perry's maintainer GitHub App with |
|
🤖 PR Patrol — patrol ran but cannot complete actions on this repo (no write access). Perry's GitHub App installation on
Thread status (Perry has read & assessed, but cannot resolve them itself):
What a human with write access needs to do:
To let Perry handle this automatically in future: install Perry's maintainer GitHub App with |
Summary
@openrouter/sdkv0.12.79 removed theOutputInputImageexport from@openrouter/sdk/models. This replaces it with the newOutputImageexport and addsOutputImage as OutputInputImageas a backward-compatible alias so existing consumers don't break.Test plan
bun run buildpasses (no TS errors)bun run test— all 294 tests pass across 24 test files🤖 Generated with Claude Code