Skip to content

fix: supervisor: repair targets the agent that executed the work job (#765) - #940

Merged
getappz merged 5 commits into
masterfrom
task/765-supervisor-repair-fallback-should-use-th
Oct 21, 2026
Merged

getappz merged 5 commits into
masterfrom
task/765-supervisor-repair-fallback-should-use-th

Conversation

@getappz

@getappz getappz commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #764 / PR #934 (CodeRabbit Major on the repair fallback).

resolve_repair_agent fell back to the enqueue-time args[1] of the last work job. WorkItemExecutor::execute can switch agents through prelaunch_failover, so after the work job cleared assignee_agent, repair could target an agent that never ran the work.

  • agent_jobs gets an effective_agent column (migration) plus Queue::set_effective_agent; last_agent_for_item now returns COALESCE(effective_agent, args[1]).
  • cancel::Registration::with_agent_sink / record_effective_agent let an executor report the agent it settled on; the worker persists it best-effort (a failed write leaves the enqueue-time fallback).
  • settle_execution_agent in cli/work.rs applies the pre-launch failover and records the resulting agent before execute_work. A mid-run exhaustion failover ends the job and re-queues the item, so the agent never changes within one job.
  • Tests: a worker test that an executor-reported agent is persisted and preferred over args[1], and a self-repair test that repair resolves the failover agent.

Closes agentflare item #765.

Summary by CodeRabbit

  • New Features

    • Job history now records the agent that actually executed each job.
    • Agent information remains available when execution switches to a fallback agent.
  • Bug Fixes

    • Failover now correctly clears incompatible model selections and records the replacement agent.
    • Subsequent repair-agent selection now uses the agent that actually handled the failed job.
    • Agent-recording issues no longer interrupt job execution.

…ets the agent that ran the work (#765)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Agentflare-Agent: claude-code
Agentflare-Branch: task/765-supervisor-repair-fallback-should-use-th
Agentflare-Item: 765
Agentflare-Session: a7614f3b-ff30-4e5c-b80d-dfc51b946b70
…tion_agent, test it end to end (#765)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Agentflare-Agent: claude-code
Agentflare-Branch: task/765-supervisor-repair-fallback-should-use-th
Agentflare-Item: 765
Agentflare-Session: a7614f3b-ff30-4e5c-b80d-dfc51b946b70
@getappz

getappz commented Oct 20, 2026

Copy link
Copy Markdown
Owner Author

Tracking this PR for automated review (flared:c997d745ae66).

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 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: 91c9e702-1f11-4dde-89b5-927788c10fc1
📥 Commits

Reviewing files that changed from the base of the PR and between 3646ca6 and bb29dfb.

📒 Files selected for processing: 3
  • crates/agentflare-jobs/src/cancel.rs
  • crates/agentflare-jobs/src/queue.rs
  • crates/agentflare-jobs/src/worker.rs
💤 Files with no reviewable changes: 1
  • crates/agentflare-jobs/src/cancel.rs
🚧 Files skipped from review as they are similar to previous changes: 2
  • crates/agentflare-jobs/src/queue.rs
  • crates/agentflare-jobs/src/worker.rs

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

📝 Walkthrough

The queue now stores the effective agent used for a job. Workers persist executor-reported agents, and execution setup records agents selected by pre-launch failover. Agent lookup prefers the stored effective agent over the enqueue-time agent.

Changes: Effective Agent Tracking

Layer / File(s) Summary
Persist the effective agent
crates/agentflare-jobs/src/queue.rs, crates/agentflare-jobs/src/cancel.rs, crates/agentflare-jobs/src/worker.rs
The queue stores an optional effective agent and returns it before the enqueue-time agent. In-process workers register a callback that persists executor-reported agents. Tests verify persistence and lookup precedence.
Record the pre-launch failover agent
src/cli/work.rs, src/supervisor_self_repair_tests.rs
settle_execution_agent applies pre-launch failover, clears the model when the agent changes, and records the selected agent. The regression test verifies repair-agent resolution after failover.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant InProcessWorker
  participant Executor
  participant record_effective_agent
  participant Queue
  participant AgentLookup
  InProcessWorker->>InProcessWorker: register agent sink
  Executor->>record_effective_agent: report effective agent
  record_effective_agent->>Queue: persist effective agent
  AgentLookup->>Queue: call last_agent_for_item
  Queue-->>AgentLookup: return effective agent or enqueue-time agent
Loading
Merge Risk: ⚪ Minimal · up to bb29d

The reviewed paths record the selected execution agent for later repair lookup. No actionable merge-blocking risk remains after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 72.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the supervisor repair behavior and matches the primary change: repair now targets the agent that executed the work job.
Description check Passed The description provides a detailed summary of the problem, implementation, fallback behavior, and tests. It does not use the template headings or include the requested command checklist and reviewer …
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.
Full details: Description check

Explanation

The description provides a detailed summary of the problem, implementation, fallback behavior, and tests. It does not use the template headings or include the requested command checklist and reviewer notes, but the essential change and validation details are present.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

…ge and doc comment (#765)

clippy's double_must_use rejected the attribute: Registration is already
#[must_use], so the builder inherits it. Also joins the split eprintln!
message with a line continuation instead of an 18-space gap, and reflows
the last_agent_for_item doc comment.

Agentflare-Agent: claude-code_2-1-305_agent
Agentflare-Branch: task/765-supervisor-repair-fallback-should-use-th
Agentflare-Item: 765
Agentflare-Session: b39fb7c8-e549-4da4-9407-4c3a3392da34
@getappz

getappz commented Oct 21, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

No files to review.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@getappz
getappz merged commit 250bdf7 into master Oct 21, 2026
17 checks passed
@getappz
getappz deleted the task/765-supervisor-repair-fallback-should-use-th branch October 21, 2026 06:11
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