Skip to content

fix(edge-worker): suppress ede_diagnostic error on first-stop interrupt (CYPACK-1352)#1346

Open
cyrusagent wants to merge 2 commits into
mainfrom
cypack-1352
Open

fix(edge-worker): suppress ede_diagnostic error on first-stop interrupt (CYPACK-1352)#1346
cyrusagent wants to merge 2 commits into
mainfrom
cypack-1352

Conversation

@cyrusagent

@cyrusagent cyrusagent commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

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:

[ede_diagnostic] result_type=user last_content_type=n/a stop_reason=tool_use

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 calls runner.interrupt() (abort the current turn, keep the session alive) instead of stop().

The pre-warm-session flow set a stop-request flag (requestSessionStop) so AgentSessionManager.completeSession() swallowed any error result. The new first-stop interrupt branch in EdgeWorker.handleStopSignal() never set a flag, so when the SDK surfaced the aborted turn as an error_during_execution result containing [ede_diagnostic] ..., consumeStopRequest() returned false and addResultEntry() posted it as a visible error.

For warm sessions, interrupt() does not throw (the keepSessionWarm loop stays alive), so the diagnostic arrives purely as a result message — fixing the completeSession path is sufficient. (Two prior fixes for this exact issue existed on the agent-sessions-warmup and cypack-1129 branches but were never merged to main; this ports the cleaner edge-worker-level approach.)

Fix

  • Add requestSessionInterrupt() / consumeInterruptRequest() to AgentSessionManager (mirrors the existing stop-request mechanism).
  • EdgeWorker.handleStopSignal() marks the session as interrupted before calling interrupt().
  • 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

  • New unit test in AgentSessionManager.stop-session.test.ts asserts that after requestSessionInterrupt, an is_error ede_diagnostic result 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

…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.
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