fix(edge-worker): suppress ede_diagnostic error on first-stop interrupt (CYPACK-1352)#1346
Open
cyrusagent wants to merge 2 commits into
Open
fix(edge-worker): suppress ede_diagnostic error on first-stop interrupt (CYPACK-1352)#1346cyrusagent wants to merge 2 commits into
cyrusagent wants to merge 2 commits into
Conversation
…pt (CYPACK-1352) First-stop on a warm session calls runner.interrupt() to abort the current turn while keeping the session alive. The SDK surfaces the aborted turn as an error_during_execution result containing "[ede_diagnostic] ..." text, which completeSession was posting to Linear as a spurious "An error occurred" activity. Introduce requestSessionInterrupt()/consumeInterruptRequest() (mirroring the existing stop-request mechanism). EdgeWorker marks the session as interrupted before calling interrupt(); completeSession swallows the matching error result and keeps the session Active so the next prompt resumes normally.
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.
Summary
Fixes CYPACK-1352. When a user sends a single stop to interrupt Cyrus mid-turn, Linear showed a spurious red An error occurred activity containing internal SDK diagnostic text:
Root cause (what changed)
PR #1109 (
a7be6096, "warm sessions, interrupt-on-stop, and buffered response posting") introduced a two-phase stop: the first stop on a warm session now callsrunner.interrupt()(abort the current turn, keep the session alive) instead ofstop().The pre-warm-session flow set a stop-request flag (
requestSessionStop) soAgentSessionManager.completeSession()swallowed any error result. The new first-stop interrupt branch inEdgeWorker.handleStopSignal()never set a flag, so when the SDK surfaced the aborted turn as anerror_during_executionresultcontaining[ede_diagnostic] ...,consumeStopRequest()returnedfalseandaddResultEntry()posted it as a visible error.For warm sessions,
interrupt()does not throw (thekeepSessionWarmloop stays alive), so the diagnostic arrives purely as aresultmessage — fixing thecompleteSessionpath is sufficient. (Two prior fixes for this exact issue existed on theagent-sessions-warmupandcypack-1129branches but were never merged tomain; this ports the cleaner edge-worker-level approach.)Fix
requestSessionInterrupt()/consumeInterruptRequest()toAgentSessionManager(mirrors the existing stop-request mechanism).EdgeWorker.handleStopSignal()marks the session as interrupted before callinginterrupt().completeSession()checks the interrupt flag first: if set, it swallows the error result and keeps the session Active (no status change) so the next prompt resumes normally. The interrupt acknowledgment ("Interrupted by …") is still posted.Testing
AgentSessionManager.stop-session.test.tsasserts that afterrequestSessionInterrupt, anis_errorede_diagnosticresult posts no error activity and leaves the session non-Error.pnpm --filter cyrus-edge-worker test→ 729 passed.pnpm typecheck(full monorepo) → clean.🤖 Generated with Claude Code