Repository navigation
agy-cli 0.1.114: a reply cut after its tool round goes on from its prefill, not a 400 (#1319) - #1461
Open
wangbingnan136 wants to merge 1 commit into
Conversation
…efill, not a 400 (magpie-community#1319) magpie's continuation of a cut reply, and a client's retry that keeps what it got of it, end with user(tool_result), assistant(text or thinking). validateBody turned that away with a 400 magpie doesn't read as a prefill refusal, so the turn died. It is now served as an interrupted tool turn: a call the session still waits on gets its result and the prefill carrier is the next prompt (steerInSession), otherwise the round is replayed with its results and the carrier. Drops are logged as prefill_tail.
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.
Refs #1319 (its second problem and first suggestion: the "live tool_result + assistant prefill tail" dead end).
Summary
In an agent loop (Codex → magpie → agy-cli), a reply that is cut after a tool round comes back to the bridge ending
… user(tool_result), assistant(text | thinking):continuation.request, yetone/magpieinternal/gateway/continuation.go);⚠ The stream was interrupted…text).validateBodyturned that shape away with a 400 whose text doesn't match magpie's prefill-refusal pattern (prefill.go), so magpie neither falls back nor appends a user turn, and the turn dies. Typing "continue" works only because it puts a user message last.The pieces to serve it already exist (interrupted tool turns,
steerInSession, replay, the prefill carrier); this connects them:Evidence
Seen in production: 8 of these 400s over 4 Codex sessions on one machine. Each time, a long request (4–16 min) was cut mid-reply, by a turn timeout,
Unknown model ID, or an upstream stream error, and the client's retry 0.2–0.7 s later got the same 400.New
test/prefill-tool-result.mjs(fake agy, viatestkit.mjs):400 !== 200,agy bridge: a request combining a live tool_result with an assistant prefill tail is not supportedAfter: pass
tool_result+ prefill → the MCP call getsREAL_RESULT_42, same agy process, next prompt has the carrier and the fragment, not the answered result againtest/prefill.mjs: the old "rejects tool_result + prefill" assertion now asserts it validates.bun test ./agy-cli.test.mjs: everything passes excepttest/usage.mjs, which fails the same way on unmodifiedmainon this machine (3 s timeouts in the region-refusal quota cases, flaky in number).bun scripts/check.mjsandbun scripts/bumped.mjs upstream/main: pass.Merge Danger
Door: two-way. Nothing is stored, and reverting brings the 400 back.
AGY_BRIDGE_PREFILL=0still restores the stock reject for every prefill.Blast Radius: narrow. Only requests that used to be a 400 take the new branch: a tool round followed by a text-only or thinking-only assistant tail. Every other request takes the same path as before. On these requests, a live session is steered (it keeps its prompt cache) or the round is replayed into a fresh session, the existing "safe, self-healing" degrade.
Not in this PR: #1319's turn timeout on long silent tool-call generation, and the session lost on
timeoutTurn.Version: 0.1.113 → 0.1.114.