Skip to content

feat: added supervisor mode - #9

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

feat: added supervisor mode#9
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 a supervised workflow that breaks escalations into specialized billing, technical, and sales investigations.
    • Added parallel investigation with progress events and graceful handling of individual failures.
    • Added synthesis of investigator findings into a single customer-facing reply.
    • Added a selectable supervised mode when submitting tasks; the standard workflow remains available.

@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: 44 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: d038ad32-b3ca-49a9-be53-797677fa9bfc

📥 Commits

Reviewing files that changed from the base of the PR and between 1d08324 and 1b0454f.

📒 Files selected for processing (2)
  • harness/investigators.py
  • harness/supervisor.py
📝 Walkthrough

Walkthrough

Adds billing, technical, and sales investigators with bounded tool execution; introduces a DBOS supervisor that plans, runs, and synthesizes investigations; and lets WebSocket clients select supervised execution through a task mode.

Changes

Supervised investigation execution

Layer / File(s) Summary
Investigator tools and execution
harness/investigators.py
Defines investigator prompts, tool permissions, read-only tool runners, and a bounded async model loop for executing function calls.
Supervisor planning and synthesis
harness/supervisor.py
Adds structured plan models, parallel investigator dispatch, lifecycle events, failure capture, and final response synthesis.
Server mode routing
server.py
Adds supervised workflow selection to run_task and passes the requested mode from WebSocket task submissions.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant server.py
  participant supervisor_workflow
  participant Investigators
  participant OpenAI
  Client->>server.py: Submit task with mode
  server.py->>supervisor_workflow: Start supervised workflow
  supervisor_workflow->>OpenAI: Create investigation plan
  supervisor_workflow->>Investigators: Run planned objectives in parallel
  Investigators->>OpenAI: Execute bounded tool-assisted investigation
  Investigators-->>supervisor_workflow: Return findings or failure
  supervisor_workflow->>OpenAI: Synthesize successful findings
  OpenAI-->>supervisor_workflow: Return customer reply
  supervisor_workflow-->>server.py: Return workflow result
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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: adding a new supervised supervisor mode to the workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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: 3

🧹 Nitpick comments (2)
harness/supervisor.py (1)

105-105: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add strict=True to zip.

results is 1:1 with steps here, so making it explicit is free and guards future edits.

🛠️ Suggested change
-    for step, result in zip(steps, results):
+    for step, result in zip(steps, results, strict=True):
🤖 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/supervisor.py` at line 105, Update the zip call in the loop over
steps and results to pass strict=True, preserving the existing 1:1 pairing while
validating that both iterables have equal length.

Source: Linters/SAST tools

harness/investigators.py (1)

12-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Model id is duplicated across modules.

MODEL = "gpt-5.6-luna" is declared identically in harness/supervisor.py (Line 12). Pull it from config.settings so investigator and supervisor can't drift.

🤖 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/investigators.py` around lines 12 - 13, Replace the local MODEL
declaration in investigators.py with the shared model setting from
config.settings, matching the approach used by supervisor.py. Update references
in the investigator flow to use that imported setting and remove the duplicated
literal so both modules remain synchronized.
🤖 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/investigators.py`:
- Around line 33-40: Correct the inaccurate comment above _TOOL_FNS to reflect
that getCharges is available to the runner. Update the getCharges and
searchKnowledgeBase handlers to safely read required arguments without raising
KeyError for malformed or empty model arguments, so run_investigator can return
the resulting tool error to the model instead of failing the DBOS step.
- Around line 87-104: Update run_investigator to explicitly signal MAX_STEPS
exhaustion when the final response still contains function calls, using a short
error or truncation marker that supervisor_workflow records as subagent.failed
instead of successful empty findings. Also remove per-call timeout arguments
from client.responses.create and configure the timeout on the client or via
client.with_options(timeout=...).

In `@harness/supervisor.py`:
- Around line 98-101: Bound the untrusted steps produced by plan_step before the
asyncio.gather dispatch in the supervisor flow. Cap the number of planned steps
using the existing workflow limit or gate investigate_step calls with a shared
semaphore, ensuring concurrent investigators cannot grow without limit while
preserving the current result collection behavior.

---

Nitpick comments:
In `@harness/investigators.py`:
- Around line 12-13: Replace the local MODEL declaration in investigators.py
with the shared model setting from config.settings, matching the approach used
by supervisor.py. Update references in the investigator flow to use that
imported setting and remove the duplicated literal so both modules remain
synchronized.

In `@harness/supervisor.py`:
- Line 105: Update the zip call in the loop over steps and results to pass
strict=True, preserving the existing 1:1 pairing while validating that both
iterables have equal length.
🪄 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: 25da43bf-54e9-40f7-8538-565b129e492a

📥 Commits

Reviewing files that changed from the base of the PR and between 02502e4 and 1d08324.

📒 Files selected for processing (3)
  • harness/investigators.py
  • harness/supervisor.py
  • server.py

Comment thread harness/investigators.py Outdated
Comment thread harness/investigators.py Outdated
Comment on lines +87 to +104
calls = [item for item in resp.output if item.type == "function_call"]
if not calls:
return resp.output_text

# A tool fired -> upgrade to the list form so we can feed the result back.
if isinstance(input_items, str):
input_items = [{"role": "user", "content": input_items}]
input_items += [item.model_dump(exclude={"status"}) for item in resp.output]
for call in calls:
result = _TOOL_FNS[call.name](json.loads(call.arguments))
input_items.append(
{
"type": "function_call_output",
"call_id": call.call_id,
"output": json.dumps(result),
}
)
return resp.output_text if resp else ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

openai python client responses.create timeout parameter

💡 Result:

The OpenAI Python client does not have a timeout parameter directly within the create method (e.g., chat.completions.create) [1][2]. Instead, you must manage timeouts either at the client level or by using the client's with_options method to override settings for a specific request [3][4][5]. Default Configuration By default, the OpenAI Python client has a timeout of 600 seconds (10 minutes) [6][7][5]. How to Configure Timeouts 1. Client-Level Configuration: Set a default timeout for all requests when initializing the OpenAI client [3][8][5]. client = OpenAI(timeout=20.0) # Sets a 20-second timeout for all requests [3][5] 2. Per-Request Configuration: Use the client.with_options method to apply a specific timeout to a single call [3][5]. # Overrides the client default for this specific request response = client.with_options(timeout=5.0).chat.completions.create( model="gpt-4", messages=[{"role": "user", "content": "Hello!"}]) 3. Fine-Grained Control: You can pass an httpx.Timeout object to either the client or with_options for more detailed control over connection, read, write, and pool timeouts [3][7][5]. import httpx client = OpenAI( timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0)) Important Notes - If a request exceeds the specified timeout, the client will raise an APITimeoutError [3][8]. - Setting timeout=None will disable timeouts entirely, which may cause requests to hang indefinitely [5]. - Do not attempt to use parameters like request_timeout inside the create method, as this will result in a TypeError [9].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate files =="
git ls-files | rg '(^|/)investigators\.py$|(^|/)supervisor\.py$|(^|/)requirements.*\.txt$|(^|/)pyproject\.toml$|uv\.lock$|poetry\.lock$|Pipfile\.lock$' || true

echo
echo "== investigators outline =="
ast-grep outline harness/investigators.py --view expanded || true

echo
echo "== investigators relevant lines =="
cat -n harness/investigators.py | sed -n '1,130p'

echo
echo "== supervisor relevant search ====="
rg -n "completed|failed|finding|investigate|investigator|subagent|synthesi|completion" harness/supervisor.py harness -g '*.py' || true

Repository: inesaranab/agent-harness

Length of output: 10458


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== supervisor full file =="
cat -n harness/supervisor.py | sed -n '1,150p'

echo
echo "== runtime relevant file search =="
cat -n harness/runtime.py | sed -n '1,190p'

echo
echo "== pyproject deps =="
cat pyproject.toml

Repository: inesaranab/agent-harness

Length of output: 13830


Surface investigator step-limit failures instead of returning empty findings.

When run_investigator exits the MAX_STEPS loop, supervisor_workflow treats the normal return as a successful subagent result, so synthesis receives empty findings even though the last response still contained function calls. Raise a short error or return an explicit truncation marker so the supervisor fan-in can record subagent.failed.

Also, avoid per-call timeout arguments on client.responses.create (the OpenAI create API does not accept timeout=); configure client-level timeout or client.with_options(timeout=...) instead.

🧰 Tools
🪛 ast-grep (0.44.1)

[info] 100-100: use jsonify instead of json.dumps for JSON output
Context: json.dumps(result)
Note: [CWE-116] Improper Encoding or Escaping of Output.

(use-jsonify)

🤖 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/investigators.py` around lines 87 - 104, Update run_investigator to
explicitly signal MAX_STEPS exhaustion when the final response still contains
function calls, using a short error or truncation marker that
supervisor_workflow records as subagent.failed instead of successful empty
findings. Also remove per-call timeout arguments from client.responses.create
and configure the timeout on the client or via client.with_options(timeout=...).

Comment thread harness/supervisor.py
@inesaranab
inesaranab merged commit 7144c1a 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