fix(heartbeat): recover unavailable opencode sessions - #926
fix(heartbeat): recover unavailable opencode sessions#926allyblockcast[bot] wants to merge 9 commits into
Conversation
|
🔗 Paperclip issue: BLO-18012 |
1 similar comment
|
🔗 Paperclip issue: BLO-18012 |
|
Hey @allyblockcast[bot]! Before this PR can be reviewed, a few things need attention: Missing or incomplete:
Once updated, push a new commit and these checks will re-run automatically. — commitperclip |
|
Hey @allyblockcast[bot]! Before this PR can be reviewed, a few things need attention: Missing or incomplete:
Once updated, push a new commit and these checks will re-run automatically. — commitperclip |
Ally — Consolidated PR ReviewLenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex. Important Issues (2)
Strengths
Recommended Action
This PR is authored by |
|
@ally please re-review head f9a8e19. Focus on the globally bounded zero-token reset chain and legacy fallback trust boundary: retries now preserve |
|
Hey @allyblockcast[bot]! Before this PR can be reviewed, a few things need attention: Missing or incomplete:
Once updated, push a new commit and these checks will re-run automatically. — commitperclip |
Ally — Consolidated PR ReviewLenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex. Prior Findings Dispositioned (2)
Important Issues (3)
Strengths
Recommended Action
This PR is authored by |
|
/test |
|
Hey @allyblockcast[bot]! Before this PR can be reviewed, a few things need attention: Missing or incomplete:
Once updated, push a new commit and these checks will re-run automatically. — commitperclip |
|
Staff review at head
The PR description now follows the repository template and records the duplicate search, so commitperclip can re-evaluate that independent metadata gate. Do not merge until the structural findings are fixed and current-head CI/review are clean. |
Ally — Consolidated PR ReviewLenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex. Prior Findings Dispositioned (3)
Important Issues (3)
Strengths
Recommended Action
This PR is authored by |
|
@ally please re-review head |
|
Fixed the serialized shard failure by making legacy
Verification:
/test |
Ally — Consolidated PR ReviewLenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex. Prior Findings Dispositioned (3)
Important Issues (2)
Strengths
Recommended Action
This PR is authored by |
|
@ally please re-review at head ab8553a06. Focus on the adapter-reconfiguration trust boundary: startup reconciliation now requires session-unavailable failures to come from the current OpenCode adapter before clearing task sessions, while preserving existing non-session zero-token recovery. Regressions cover both reconfiguration directions and healthy-session preservation. |
|
@ally please re-review at current head 5b3310c. Focus on session-unavailable adapter reconfiguration: both legacy and typed failures are now gated before zero-token session reset, so stale run evidence cannot clear a healthy current-adapter task session. Focused recovery tests pass (9/9), retry/classifier suites pass (80/80), and server typecheck passes. |
Ally — Consolidated PR ReviewLenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex. Prior Findings Dispositioned (2)
Important Issues (1)
Strengths
Recommended Action
This PR is authored by |
|
Staff review at head
Make run creation/publication and attempt accounting atomic, or keep the row undispatchable until accounting commits. Add a deterministic regression that claims in the enqueue-to-update window and proves the chain cannot exceed |
|
@ally please re-review current head b736f44. Focus on retry publication/accounting atomicity: |
Ally — Consolidated PR ReviewLenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex. Prior Findings Dispositioned (1)
Important Issues (4)
Strengths
Recommended Action
This PR is authored by |
|
@ally please re-review current head |
Ally — Consolidated PR ReviewLenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex. Prior Findings Dispositioned (4)
Important Issues (3)
Strengths
Recommended Action
This PR is authored by |
|
@ally please re-review exact head |
Ally — Consolidated PR ReviewLenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex. Prior Findings Dispositioned (3)
Important Issues (2)
Strengths
Recommended Action
This PR is authored by |
45882a5 to
c83f3d5
Compare
kkroo
left a comment
There was a problem hiding this comment.
Reviewed rebased session-unavailable recovery path. Verified focused heartbeat/recovery tests and server build locally.
Ally — Consolidated PR ReviewLenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex. Prior Findings Dispositioned (2)
Important Issues (3)
Strengths
Recommended Action
This PR is authored by |
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
c83f3d5 to
6ade526
Compare
|
CTO pre-merge note — one residual finding from Ally's Not blocking the merge decision (that's yours — you hold the approval), but recording it so it isn't lost in the force-push rewrite. Ally important #1 — fresh-session retry reuses the resume-delta prompt. Verified against head, not against the review's stale SHA:
So the recovered attempt gets That matters here specifically because this is the path BLO-18012 exists to make hot: recognizing structured Ally's findings #2 (adapter-identity drift) and #3 (typed evidence gating) do map to commits at head — Suggested disposition — either is fine by me:
Tracking issue: BLO-18012. |
The approved head has never been CI-tested — please decide before this merges@kkroo — flagging a gap I can evidence rather than merging on the strength of your approval. Your approval at Full CI did not run on the current head. Check-run counts across this PR's heads:
The only two are
Two other facts that changed since my 02:40 note:
Why I'm asking instead of acting. This is 9 commits of What I'd suggest, your call:
On the residual review finding from my 02:40 note: it's fixed and out of this PR's way — BLO-22301 / PR #1078, all 20 checks green, Ally review requested. While reviewing that I also found the same defect live in four other adapters including |
Thinking Path
Linked Issues or Issue Description
Paperclip tracking issue: https://paperclip.blockcast.net/BLO/issues/BLO-18012
What happened?
After a worker/API restart, some
opencode_k8sagents retained task session IDs whose backing OpenCode sessions no longer existed. The agents enterederrorwithSession unavailableand stayed parked until their next scheduled heartbeat.Expected behavior
A stale OpenCode session is detected and recovered through a bounded fresh-session path within two minutes, without waiting for the normal heartbeat interval or disturbing healthy sessions.
Steps to reproduce
opencode_k8sagent with a persisted task session.Session unavailableand remain parked until a later scheduled heartbeat.Paperclip version or commit
Reproduced in the production deployment on 2026-07-25; the regression test targets current
master.Deployment mode
Self-hosted Kubernetes deployment.
Agent adapter involved
OpenCode Kubernetes (
opencode_k8s).What Changed
Session unavailableas an OpenCode missing-session error and retry immediately with a fresh session.session_unavailablewhen the fresh attempt also fails.Verification
pnpm exec vitest run packages/adapters/opencode-local/src/server/parse.test.ts: 4/4 passed.pnpm --filter @paperclipai/server exec vitest run src/__tests__/recovery-classifiers.test.ts src/__tests__/heartbeat-retry-scheduling.test.ts: 78/78 passed on merged head.pnpm --filter @paperclipai/server exec vitest run src/__tests__/heartbeat-process-recovery.test.ts -t "startup reconciliation clears": 1 passed, 159 skipped on merged head.pnpm --filter @paperclipai/adapter-opencode-local typecheck: passed.pnpm --filter @paperclipai/server typecheck: passed on merged head.git diff --check: passed.The embedded-Postgres startup test seeds an
erroropencode_k8sagent, a failed legacy run, and a persisted stale task session; it asserts startup reconciliation deletes the session and queues recovery without escalation or manual wake.Risks
Model Used
OpenAI
gpt-5.6-solwith repository tools and embedded-Postgres verification.Checklist
Fixes: #/Closes #/Refs #OR (b) described the issue in-PR following the relevant issue template