Skip to content

feat(opencode-claimant): retry error-stopped queue sessions - #12879

Merged
dezren39 merged 1 commit into
mainfrom
codex/agent-next-10-1656-ac2
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
codex/agent-next-10-1656-ac2

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

  • classify terminal error outcomes on bound queue sessions as error-stopped with task/queue/issue/repo binding
  • after an expired lease, delete the failed session and compare-clear the binding so the next claimant fire retries through the task's recorded route/failover ladder
  • record the recovery action and binding in the claimant fire log; count retry interventions separately

Refs #1656
Refs #2140

Evidence

  • python3 -m unittest pm-stack/opencode-claimant/test_babysitter.py pm-stack/opencode-claimant/test_nudges.py — 47 tests passed
  • TestSupervisionStep — 12 tests passed, including expired error-stopped requeue and compare-and-clear ordering
  • python3 -m py_compile pm-stack/opencode-claimant/babysitter.py pm-stack/opencode-claimant/nudges.py pm-stack/opencode-claimant/claimant.py
  • git diff --check
  • The complete claimant file includes live-fire tests that require the local OpenCode HTTP endpoint; that endpoint was unavailable, so those tests were not used as slice evidence.

Merge Danger

Low. Recovery is gated on a verified terminal error, an expired task lease, successful session deletion, and the existing atomic compare-and-clear queue bind. Unknown session/lease state remains fail-closed.


See it in action
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 23, 2026 04:22
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 08eda9d6-2c60-47a9-99c0-b9e781966e17
Commits

Reviewing files that changed from the base of the PR and between 4c01d04 and d41a9ee.

Files selected for processing: 6

  • pm-stack/opencode-claimant/babysitter.py
  • pm-stack/opencode-claimant/claimant.py
  • pm-stack/opencode-claimant/nudges.py
  • pm-stack/opencode-claimant/test_babysitter.py
  • pm-stack/opencode-claimant/test_claimant.py
  • pm-stack/opencode-claimant/test_nudges.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T04:25:58.799944Z d41a9ee PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit 8429ed8 into main Nov 23, 2026
2 checks passed
@dezren39
dezren39 deleted the codex/agent-next-10-1656-ac2 branch November 23, 2026 04:24

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d41a9ee61f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +547 to +548
"--launched-by",
LAUNCHED_BY_RECOVERY_ERROR_STOPPED,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Implement backend recovery support before using the new marker

For an expired-lease error session, this deletes the session and then sends a recovery marker that neither checked-in backend supports. The CLI forwards launched_by unchanged to /bind; its help describes bind as “Binds a worker to a task” (client/support.rs:245). The Turso implementation in pkgs/fleet/crates/fleet-queue/src/turso_queue/lifecycle.rs:1272-1287 rejects expired leases and never compare-clears bindings, while migration-0026.sql:77-80 recognizes only the two older recovery markers. Consequently, the new recovery path deletes the session but leaves its queue binding intact instead of making the task retryable. Add the corresponding atomic backend recovery operation before invoking this marker.

Useful? React with 👍 / 👎.

Comment on lines +653 to +660
error_outcome = _session_error_outcome(_session)
if error_outcome:
# A terminal provider/session error is safe to retry
# only after the lease has expired; until then the
# owning worker may still be reconciling it.
lease_ms = poll.parse_lease_ms(task.get("lease_until"))
if lease_ms is None or lease_ms > now_ms:
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Check authoritative activity before recovering error sessions

When a session resumes after an error, its stored outcome can remain error-valued while it is actively executing; poll.py:475-488 explicitly handles this by letting active-set membership override terminal markers. This new branch ignores the fetched active_ids and authorizes deletion as soon as the task lease expires, so it can delete a running resumed session and even terminally fail its task when attempts are exhausted. Preserve the authoritative activity check, including failing closed when activity cannot be read, before treating the stored error outcome as terminal.

Useful? React with 👍 / 👎.

Comment on lines +290 to 292
queue = [a for a in planned if a["kind"] in ("retry", "nudge", "escalate")]
queue.sort(key=lambda a: (a.get("nudges_sent") or 0, a["session_id"]))
overflow_ids = {id(a) for a in queue[MAX_QUEUE_INTERVENTIONS_PER_ROUND:]}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep non-actionable retries out of the stall intervention cap

With ten bound error sessions whose leases are still live or unreadable, supervision leaves them bound, but these new retry actions consume all ten intervention slots. The production call in claimant.py:1927-1932 never supplies recover_error, so those actions always fail and re-plan; because retry actions omit nudges_sent, they also sort ahead of every stalled session already nudged once. Consequently, real second nudges and escalations remain deferred on every fire while those error sessions persist, even though no retry intervention occurs. Exclude these non-actionable retries from the shared cap or otherwise prevent them from repeatedly displacing executable stall interventions.

Useful? React with 👍 / 👎.

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