Repository navigation
fix(item): release must not erase a reassignment made mid-run - #783
Conversation
item::release cleared assignee_agent whenever it released a claim, whoever the assignee was. A job still running when the operator redispatched to another agent would, on failing, wipe that reassignment; the queue retry then saw no assignee and fell back to the job's frozen payload agent, so a redispatch to a new agent never stuck (seen on item 604). Only clear the assignee when it is not a different agent type than the releasing owner. Adds a backend regression test and an MCP-level one that replays the redispatch-then-old-job-releases sequence. Agentflare-Agent: claude-code_2-1-278_agent Agentflare-Branch: task/605-item-release-wipes-a-reassignment-made-m Agentflare-Item: 605 Agentflare-Session: ca443dbc-124a-49dd-8747-6e32ade55b8e
|
Tracking this PR for automated review ( |
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: getappz/agentflare/.coderabbit.yaml Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (3)
Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. 📝 WalkthroughWalkthrough
ChangesLease release safety
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
supervisor — CI self-repair dispatchedFailing checks: build (windows-latest), CI Green. Please investigate and push a fix. job: 5jRhX0yJWtupNBYK_jS0V |
supervisor — CI greenChecks are passing again. |
Summary
Fixes "redispatch to a new agent doesn't stick" (seen on agentflare item #604, where a redispatch to claude-code kept reverting to opencode).
Root cause.
agentflare_backend::item::releasesetassignee_agent = NULLwhenever it released a claim, whoever the assignee was. If a job for agent A is still running when the operator redispatches to agent B, that job later fails,release_and_comment->item_release->item::releasewipes B. The queue then retries the same job,apply_fresh_overridessees a NULL assignee and fails open to the job's frozen payload agent (A), and the claim re-assigns the item toA:<job>.Evidence from
item_assignment_eventson #604:The NULL between those rows is the wipe.
Fix.
item::releasenow clearsassignee_agentonly when the item has not been reassigned to a different agent type than the releasing owner (agent_partcomparison). Ordinary release still clears it, so item #93's behavior (a released item must not stay pinned to the releasing agent type) is unchanged, and a no-op release is unchanged too. This complements #780, which releases the old claim on redispatch but could not stop a still-running job from wiping the assignee afterwards.Not changed:
apply_fresh_overridesfail-open (a NULL assignee after a normal release legitimately means "use the payload agent"),redispatch,reassignment_releases_claim.Tracks agentflare item #605 (not GitHub PR/issue #605).
Test plan
left: None, right: Some("claude-code"), and pass afterrelease_keeps_an_assignee_reassigned_to_a_different_agent_mid_run(backend)item_release_by_a_superseded_job_keeps_the_redispatched_assignee(MCP layer, replays redispatch then the old job's release)cargo test -p agentflare-backend: 151 passedcargo fmt --all --checkcleancargo clippy --locked --workspace --all-targets --all-features -- -D warnings -A unsafe_code -A clippy::pedanticexits 0cargo test --workspace: not clean locally, see below; left to CILocal
cargo test --bin agentflarehad 5 failures, none caused by this change. Two fail identically on unmodified master (agent_detector_flags_the_claudecode_marker_run_denies_on, which depends on the session env, andclaim_self_repair_defers_when_another_workstation_already_holds_a_live_claim);pm_health_matches_item_health_for_the_same_paramsis a 1-second timing flake; the other two (claim_guard_leaves_the_claim_held_when_disarmed,claim_then_headless_not_found_releases_claim_and_posts_error_comment) pass when run alone.Known follow-ups (not in this PR)
pick_implementer_agentmay swap claude-code for a fallback whenclaude_over_threshold()is true. No evidence it fired here.Summary by CodeRabbit
Bug Fixes
Tests