Skip to content

chore: item redispatch: explicit assignee_agent should release the old agent's live claim (parity with item update) - #780

Merged
getappz merged 2 commits into
masterfrom
task/598-item-redispatch-explicit-assignee-agent
Sep 20, 2026
Merged

getappz merged 2 commits into
masterfrom
task/598-item-redispatch-explicit-assignee-agent

Conversation

@getappz

@getappz getappz commented Sep 20, 2026 •

Copy link
Copy Markdown
Owner

item action=redispatch assignee_agent=<other> now releases the old agent's live claim, the same way item action=update does. It passes its tests. I haven't committed anything.

  • Fix: in item_redispatch (src/mcp_server/item.rs), when the caller passes assignee_agent explicitly, it now calls reassignment_releases_claim with the resulting assignee. This runs before the dispatchable check, so the item reports dispatchable=true right away instead of waiting out the 4h TTL. I renamed the outer assignee_agent variable to req_assignee because the match arm shadows it.
  • What stays the same: a redispatch with no explicit assignee still leaves the claim alone, because the assignee doesn't change. Handing off to the same agent (ignoring the :instance suffix) also keeps the claim, matching update. agentflare_backend::item::redispatch is untouched; it deliberately doesn't touch the claim ledger.
  • Tests: I added two in src/mcp_server/tests/action_tests.rs. One redispatches to claude-code while opencode:dead-job holds a claim, and checks the claim is gone and dispatchable=true. The other redispatches to opencode while opencode:live-job holds a claim, and checks the claim survives.
  • Results: cargo fmt --check is clean. cargo test --bin agentflare redispatch gives 6 passed. cargo test --bin agentflare item_ gave 307 passed and 1 failed: pm_tests::pm_health_matches_item_health_for_the_same_params. That test passes when run alone (1 passed), and I didn't investigate why it failed in the larger run. My change doesn't touch the health code.

Concern: redispatch and the release are two separate steps, not one transaction, the same as in item_update. A failure between them would leave the item re-armed with the old claim still in place, which is the current behaviour anyway.

Existing quirk: a same-agent redispatch still reports dispatchable=false, since the dispatchable check compares the full owner string (opencode:live-job) against the bare agent name (opencode). The existing test item_redispatch_reports_dispatch_blocked_when_a_live_claim_remains relies on this. I left it alone, and it may deserve its own item.


Opened by claude-code on flared:c997d745ae66 for item #598 via agentflare.

Summary by CodeRabbit

  • Bug Fixes
    • Redispatching an item to a different explicitly assigned agent now releases the previous agent’s claim.
    • Items redispatched to a different agent are correctly reported as available for dispatch.
    • Redispatching to the same agent continues to preserve the existing claim.

…agent's live claim, the same way `item action=update` does. It passes its tests. I haven't committed anything.

- **Fix:** in `item_redispatch` (`src/mcp_server/item.rs`), when the caller passes `assignee_agent` explicitly, it now calls `reassignment_releases_claim` with the resulting assignee. This runs before the `dispatchable` check, so the item reports `dispatchable=true` right away instead of waiting out the 4h TTL. I renamed the outer `assignee_agent` variable to `req_assignee` because the match arm shadows it.
- **What stays the same:** a redispatch with no explicit assignee still leaves the claim alone, because the assignee doesn't change. Handing off to the same agent (ignoring the `:instance` suffix) also keeps the claim, matching `update`. `agentflare_backend::item::redispatch` is untouched; it deliberately doesn't touch the claim ledger.
- **Tests:** I added two in `src/mcp_server/tests/action_tests.rs`. One redispatches to `claude-code` while `opencode:dead-job` holds a claim, and checks the claim is gone and `dispatchable=true`. The other redispatches to `opencode` while `opencode:live-job` holds a claim, and checks the claim survives.
- **Results:** `cargo fmt --check` is clean. `cargo test --bin agentflare redispatch` gives 6 passed. `cargo test --bin agentflare item_` gave 307 passed and 1 failed: `pm_tests::pm_health_matches_item_health_for_the_same_params`. That test passes when run alone (1 passed), and I didn't investigate why it failed in the larger run. My change doesn't touch the health code.

**Concern:** `redispatch` and the release are two separate steps, not one transaction, the same as in `item_update`. A failure between them would leave the item re-armed with the old claim still in place, which is the current behaviour anyway.

**Existing quirk:** a same-agent redispatch still reports `dispatchable=false`, since the `dispatchable` check compares the full owner string (`opencode:live-job`) against the bare agent name (`opencode`). The existing test `item_redispatch_reports_dispatch_blocked_when_a_live_claim_remains` relies on this. I left it alone, and it may deserve its own item.
@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration

Configuration used: Repository: getappz/agentflare/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 566a2301-4a94-4ddb-a126-9a719760a9b8

📥 Commits

Reviewing files that changed from the base of the PR and between 0500137 and 605d8bb.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: getappz/agentflare/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 98e70257-75ff-4d1f-b82d-22074d828df6

📥 Commits

Reviewing files that changed from the base of the PR and between 2bd8646 and 0500137.

📒 Files selected for processing (2)
  • src/mcp_server/item.rs
  • src/mcp_server/tests/action_tests.rs

Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


📝 Walkthrough

Walkthrough

Changes

Redispatch claim handling

Layer / File(s) Summary
Claim-aware redispatch behavior
src/mcp_server/item.rs, src/mcp_server/tests/action_tests.rs
item_redispatch passes the requested assignee to the backend. An explicit change of assignee releases the previous claim. Tests verify that a different assignee makes the item dispatchable and that the same assignee preserves the claim.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: releasing the old agent's live claim when redispatch uses an explicit assignee_agent. It is specific and related to the changeset.
Description check ✅ Passed The description explains the change, preserved behavior, implementation details, tests, known test failure, risk, and backward compatibility. It does not use the template headings or checkboxes, and i…
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@getappz

getappz commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

Claiming self-repair for flared:c997d745ae66.

@getappz

getappz commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

supervisor — CI self-repair dispatched

Failing checks: hakari, CI Green.

Please investigate and push a fix.

job: 8ifYZXgsEBJPZDNLwO4qr

@getappz

getappz commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

supervisor — CI green

Checks are passing again.

@getappz
getappz merged commit 3502d66 into master Sep 20, 2026
16 checks passed
@getappz
getappz deleted the task/598-item-redispatch-explicit-assignee-agent branch September 20, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant