Skip to content

fix(fleet-agent): agent next claims with a 4-hour lease (#12618) - #12690

Merged
dezren39 merged 2 commits into
mainfrom
archer-lane-ai2/12618-agent-next-lease
Nov 22, 2026
Merged

dezren39 merged 2 commits into
mainfrom
archer-lane-ai2/12618-agent-next-lease

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What

fleet agent next now takes its queue claim with an explicit lease — --lease-seconds 14400 (AGENT_CLAIM_LEASE_SECONDS, 4 hours) — and the task it hands the worker names that lease: a lease_seconds field plus the deadline stated in the instructions.

Why (#12618)

Agent-next built its claim with no --lease-seconds, so every claim silently carried the queue's 2700s (45-minute) default. Lane work runs 1–3 hours and nothing in the agent-next flow heartbeats, so the lease lapsed mid-task: expire_leases returned the task to the queue, it was re-served to the next caller, and the worker's fleet queue complete was refused as "not claimed by archer". Completions were recorded through queue cancel instead (no claimed-by guard) — the uncertified-delivery shape epic #1233's criterion 2 is written against. Lane AI's drill record on #12618 (comment 7085601397) established there is no identity mismatch: a live claim completes fine; only the lapsed one refuses.

The lease size: 4 hours covers the observed 1–3h lane-work range with headroom and stays well inside the queue's one-day maximum (LEASE_SECONDS_MAX 86400). Client-side claim parameters only — the broker is unchanged, no redeploy.

Tests (failing first)

New oracle test a_queue_claim_carries_the_agent_lease_and_the_handout_names_it pins the claim argv and the hand-out; the existing pin in an_empty_mailbox_falls_to_a_queue_claim is updated. On the tests-only commit (71415a0): 80 passed, 2 failed — exactly those two, the recorded claim argv showing no --lease-seconds. With the fix (laptop, nix develop .#fleet, build lock):

  • cargo test --locked -p fleet-agent --lib → 82 passed, 0 failed
  • cargo test --locked -p fleet-queue --lib --features client,queue-broker → 467 passed, 0 failed

Drill (the built binary, scratch queue scratch-lane-ai2-12618)

  • Task 21080 claimed through the new agent next: hand-out carries lease_seconds: 14400 and names it in the instructions; the row's lease span is exactly 14400s (claimed 2026-11-22T22:13:15Z, lease_until 2026-11-23T02:13:15Z). fleet queue complete by the claiming worker then landed (rc=0) with a verified disposition + evidence reference; the broker's earlier gate refusals on that task confirmed "the task remains claimed" — the claimed-by guard recognized the worker throughout.
  • Control, task 21082 claimed with --lease-seconds 5: after the lapse and a sweep, completion was refused with broker exit 5 — "lane-ai2-drill's lease expired … and the task went back to the queue" — the fleet: queue complete cannot close tasks claimed via fleet agent next (claim worker identity mismatch) #12618 shape, reproduced on demand.

What the drill does not wait out: a completion at hour 2. That follows from the row's recorded lease_until (+14400s) and the broker expiring only leases past it, both observed above.

Closes #12618


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

Failing-first oracle for the #12618 fix: a claim taken by
fleet agent next must carry --lease-seconds 14400 explicitly
(never the queue 2700s default that evaporates mid-task), and
the handed-out task must name the lease. Updates the existing
claim-argv pin in an_empty_mailbox_falls_to_a_queue_claim.
fleet agent next built its queue claim with no --lease-seconds,
so every claim carried the queue default lease of 2700s
(45 minutes). Agent work runs 1-3 hours and nothing in the
agent-next flow heartbeats, so the lease lapsed mid-task:
expire_leases returned the task to the queue, it was re-served
to the next caller, and the workers complete was refused as
not claimed. Completions were recorded through queue cancel
instead, which has no claimed-by guard (epic #1233 criterion 2
is written against exactly that).

The claim now carries --lease-seconds 14400 explicitly
(AGENT_CLAIM_LEASE_SECONDS: four hours covers the observed
1-3h range with headroom, inside the queues one-day maximum),
and the handed-out task names the lease: a lease_seconds field
plus the deadline stated in its instructions. Client-side
claim parameters only; the broker is unchanged.
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 22:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 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-22T22:16:52.553347Z 6506c66 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 364eee3 into main Nov 22, 2026
1 check passed
@dezren39
dezren39 deleted the archer-lane-ai2/12618-agent-next-lease branch November 22, 2026 22:15
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

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.

fleet: queue complete cannot close tasks claimed via fleet agent next (claim worker identity mismatch)

1 participant