Skip to content

fix: resume active runs for job notifications#784

Merged
SamSaffron merged 1 commit into
SamSaffron:mainfrom
sam-saffron-jarvis:feat/queue-agent-notify-resume
Jun 9, 2026
Merged

fix: resume active runs for job notifications#784
SamSaffron merged 1 commit into
SamSaffron:mainfrom
sam-saffron-jarvis:feat/queue-agent-notify-resume

Conversation

@sam-saffron-jarvis

@sam-saffron-jarvis sam-saffron-jarvis commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

What

Finishes the queue_agent notify_when_done web behavior for both active and idle loaded sessions.

Two cases were broken/underspecified:

  1. Active web session: if a queued job finished while the origin session was streaming final prose, the notification interjection could be queued but left pending because the engine reached a text-only terminal turn and emitted done.
  2. Idle loaded web session: if the origin response had already ended, there was no stream to interject into; the old path only appended a transcript note, so nothing continued.

This PR now handles both:

  • active session → queue an internal AutoContinue notification interjection and continue at text-only turn boundaries
  • idle but loaded web session → start a detached response run with the job notification as the next user message, so the assistant actually reacts
  • unloaded/missing runtime → keep the safe store-only assistant notification fallback
  • normal user interjections remain pending/cancellable
  • FIFO is preserved: normal user interjections block later auto-continue job notices from jumping the queue

Why

notify_when_done should mean “tell the originating conversation and let it carry on,” not “leave a note somewhere and hope the human notices.” Waiting is the bad path; notification should be the good path.

Review notes

Reviewed with claude-bin:opus-max. I folded in the correctness nits before opening/pushing:

  • limited auto-continue to the pure text-only path, avoiding unregistered/passthrough client tool-call abandonment
  • removed the precheck/drain TOCTOU by draining once and branching on the result
  • avoided converting a last-turn completion into MaxTurnsExceededError; if no turn budget remains, the notice stays pending and the current response completes
  • added FIFO-blocking coverage
  • added loaded-idle-session coverage proving a continuation response run is started and persists user notice + assistant response

Verification

go test ./internal/llm -run 'Interjection_(NoToolCalls|AutoContinue)'
go test ./cmd -run 'JobsV2Notify|Interrupt|Interjection'
go build ./...
go test ./...

@sam-saffron-jarvis sam-saffron-jarvis force-pushed the feat/queue-agent-notify-resume branch from d19aa8a to a10891f Compare June 9, 2026 05:21
@SamSaffron SamSaffron merged commit cea0021 into SamSaffron:main Jun 9, 2026
1 check passed
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.

2 participants