Skip to content

feat: added agent handoffs - #8

Merged
inesaranab merged 2 commits into
inesfrom
agent_harness_v7
Jul 26, 2026
Merged

feat: added agent handoffs#8
inesaranab merged 2 commits into
inesfrom
agent_harness_v7

Conversation

@inesaranab

@inesaranab inesaranab commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added specialized support agents for triage and billing inquiries.
    • Added guided handoffs between agents when billing expertise is needed.
    • Added support for processing structured refund requests.
    • Tools are now tailored to the active support agent.
  • Improvements

    • The activity inspector now clearly displays agent handoffs, including source, destination, and reason.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@inesaranab, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d1e9fc54-2733-4219-b567-ad1fb943374f

📥 Commits

Reviewing files that changed from the base of the PR and between ff0dc56 and c62648e.

📒 Files selected for processing (1)
  • harness/runtime.py
📝 Walkthrough

Walkthrough

Adds triage and billing agents with distinct tool allowlists, enables runtime handoffs with agent-specific prompts and schemas, adds refund tooling, and renders handoff events in the InspectorPane.

Changes

Agent Handoff Workflow

Layer / File(s) Summary
Agent contracts and capabilities
harness/agents.py, harness/tools.py
Defines immutable agent metadata, tool selection, triage and billing registries, refund execution, and handoff schemas.
Agent-aware runtime flow
harness/memory.py, harness/runtime.py
Passes system prompts into context construction, sends active-agent tools to the model, and switches agents when handoff executes.
Handoff event presentation
web/src/components/InspectorPane.tsx
Adds agent event styling and specialized rendering for handoff source, target, emojis, timestamps, and reasons.

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

Sequence Diagram(s)

sequenceDiagram
  participant Workflow
  participant OpenAI
  participant AgentRegistry
  participant ToolRuntime
  participant InspectorPane
  Workflow->>OpenAI: Request model turn with active agent tools
  OpenAI-->>Workflow: Return handoff tool call
  Workflow->>AgentRegistry: Resolve target agent
  AgentRegistry-->>Workflow: Return billing agent
  Workflow->>Workflow: Emit agent.handoff and update active agent
  Workflow->>OpenAI: Request next turn with billing prompt and tools
  OpenAI-->>Workflow: Return tool call
  Workflow->>ToolRuntime: Execute registered tool
  ToolRuntime-->>Workflow: Return tool result
  Workflow-->>InspectorPane: Stream agent.handoff event
  InspectorPane-->>InspectorPane: Render source and target agents
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: introducing agent handoffs.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent_harness_v7

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

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@harness/runtime.py`:
- Around line 171-193: Validate the handoff call’s JSON arguments and ensure its
“to” target is present in REGISTRY before emitting the agent.handoff event or
updating active. For malformed arguments or unknown targets, return an
appropriate failed tool result so the workflow continues and the model can
retry; only emit and switch for valid targets in the handoff branch of the
tool-call loop.

In `@harness/tools.py`:
- Around line 46-70: Update issue_refund to validate that amountCents is
positive and the customerId/chargeId are eligible, then execute the refund
through the payment provider before constructing a response. Return the
provider’s actual success status and refund identifier, and never report
refunded: True unless the provider confirms execution.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 348773c5-0129-4028-8235-ac6072b65bfa

📥 Commits

Reviewing files that changed from the base of the PR and between 8031ec1 and ff0dc56.

📒 Files selected for processing (5)
  • harness/agents.py
  • harness/memory.py
  • harness/runtime.py
  • harness/tools.py
  • web/src/components/InspectorPane.tsx

Comment thread harness/runtime.py
Comment thread harness/tools.py
Comment on lines +46 to +70
def issue_refund(customerId: str, chargeId: str, amountCents: int) -> dict:
# IRREVERSIBLE: moves real money. The capability triage lacks.
return {
"refunded": True,
"customerId": customerId,
"chargeId": chargeId,
"amountCents": amountCents,
}


# ── the schemas (what the model reads to decide what to call) ────────
TOOL_SCHEMAS: list[FunctionToolParam] = [
{
"type": "function",
"strict": False,
"name": "issueRefund",
"description": "Issue a refund. IRREVERSIBLE - moves real money",
"parameters": {
"type": "object",
"properties": {
"customerId": {"type": "string"},
"chargeId": {"type": "string"},
"amountCents": {"type": "integer"},
},
"required": ["customerId", "chargeId", "amountCents"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Do not report a refund before one is executed.

This returns refunded: True for arbitrary charge/customer IDs and amounts without a payment-provider call or validation. The billing agent can subsequently send a false confirmation to the customer. Execute and verify the provider operation first; enforce a positive, eligible amount and return its real status/identifier.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@harness/tools.py` around lines 46 - 70, Update issue_refund to validate that
amountCents is positive and the customerId/chargeId are eligible, then execute
the refund through the payment provider before constructing a response. Return
the provider’s actual success status and refund identifier, and never report
refunded: True unless the provider confirms execution.

@inesaranab
inesaranab merged commit 7b38877 into ines Jul 26, 2026
1 of 3 checks passed
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