openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Feature Request : Team Lead quality review loop structured QC pass/fail with retry, rejection, and escalation

Open githb-ac opened this issue 6 months ago • 1 comments

Summary

Add a formal quality review loop at the Team Lead layer so that sub-agent outputs are scored against configurable criteria before being accepted, returned for revision, or escalated to the orchestrator. The loop gives every team a built-in QC gate without requiring a separate QC agent archetype, and surfaces pass/fail results as structured telemetry events visible in the dashboard.

Problem

Currently, sub-agent outputs flow upward to the Team Lead and then to the orchestrator without a defined quality gate. The Team Lead may summarise or compile outputs but does not systematically score them, reject low-quality work, or request a retry. This means:

  • Hallucinated or incomplete sub-agent outputs can propagate into the final result unchallenged
  • There is no consistent mechanism for a Team Lead to send work back to a sub-agent with specific corrective instructions
  • The orchestrator has no signal about output quality below its own layer it only sees the final compiled result
  • Quality problems are caught late (by the user or in post-processing) rather than at the point of production

Solution

Scope: core (agent loop) + config

The review loop runs at the Team Lead layer after each sub-agent returns an output:

  1. Score - Team Lead evaluates the output against a rubric defined in its SKILL.md (or a default rubric): factual consistency, completeness, format compliance, and absence of hallucination markers
  2. Pass - output is accepted and passed up the chain
  3. Fail → Retry - output is returned to the sub-agent with specific corrective instructions; the sub-agent retries up to max_retries times
  4. Fail → Reject - if retries are exhausted and quality is still below threshold, the sub-agent output is marked rejected and the Team Lead compiles a partial result with a rejection notice
  5. Escalate - if the Team Lead cannot resolve the quality issue within its retry budget, it escalates to the orchestrator with a structured failure report

Configuration is per-team in config.yaml:

[[teams]]
name = "research"
qc:
  enabled: true
  min_quality_score: 0.75     # 0.0–1.0; outputs below this trigger a retry
  max_retries: 2              # retries per sub-agent output before rejection
  escalate_on_reject: true    # escalate to orchestrator if rejection occurs
  rubric: default             # or path to a custom rubric file

Retry instruction format: when returning work to a sub-agent, the Team Lead includes a structured correction block:

QC FAIL — please revise:
- [specific issue 1]
- [specific issue 2]
Retry [n] of [max_retries]

Telemetry: every QC decision (pass, fail, retry, reject, escalate) emits a structured event to the telemetry bus, visible in the dashboard live event stream and reflected in the agent's quality score.

Fallback: teams without qc.enabled: true continue to operate exactly as today - no behaviour change.

Acceptance criteria

  • [ ] QC scoring - Team Lead scores sub-agent outputs against the configured rubric after each return
  • [ ] Pass path - outputs above min_quality_score are accepted and passed up the chain without modification
  • [ ] Retry path - outputs below threshold are returned to the sub-agent with a structured correction block; retried up to max_retries times
  • [ ] Reject path - outputs still below threshold after all retries are marked rejected; Team Lead compiles partial result with rejection notice
  • [ ] Escalation - if escalate_on_reject: true, a structured failure report is sent to the orchestrator
  • [ ] Telemetry events - QC pass, fail, retry, reject, and escalate each emit a structured telemetry event
  • [ ] Dashboard visibility - QC events appear in the live event stream; agent quality scores update in the agent status table
  • [ ] Config-driven - min_quality_score, max_retries, escalate_on_reject, and rubric are read from config.yaml; defaults apply if omitted
  • [ ] Non-QC fallback - teams without qc.enabled: true are fully unaffected
  • [ ] Diff coverage ≥ 80% - the implementing PR meets the changed-lines coverage gate (Vitest + cargo-llvm-cov, enforced by .github/workflows/coverage.yml)

Related

  • OpenHuman agent architecture: https://tinyhumans.gitbook.io/openhuman/
  • Proposed: Per-agent model pinning (FR1)
  • Proposed: Named team hierarchy (FR2)
  • Proposed: Concurrent orchestrator visibility layer (FR4)

githb-ac avatar May 15 '26 20:05 githb-ac

Thanks for the writeup — the underlying point (sub-agent outputs propagating unchallenged into the final result) is a real gap worth closing. Before I open a PR, I want to be honest about what's actually in the codebase today and scope this down to something shippable.

What already exists:

  • [teams.<name>] config (src/openhuman/config/schema/agent.rs) — but it's only used for model routing (lead_model / agent_model), not as a governance layer.
  • Orchestrator → sub-agent hierarchy (no separate "Team Lead" tier between them — the lead is just the orchestrator with a different model).
  • Event bus (src/core/event_bus/) already emits SubagentSpawned / SubagentCompleted / SubagentFailed.

What's greenfield (none of this exists yet):

  • QC scoring / pass-fail / retry / reject / escalate logic
  • min_quality_score, max_retries, escalate_on_reject config
  • Per-team rubric files
  • "Agent quality score" anywhere in storage or telemetry
  • A "dashboard live event stream"

So this isn't an incremental change — it's a new control-flow + observability subsystem on top of the existing hierarchy.

v1 I'm willing to ship — one event, no retry:

  • Emit a SubagentQcOutcome { subagent_id, verdict: Pass | Fail { reasons: Vec<String> }, score: Option<f32> } event on the existing event bus after each SubagentCompleted.
  • The orchestrator (acting as the "lead") produces the verdict from the sub-agent's output during its existing compile step — no new rubric file, no retry loop, no escalation logic, no UI.
  • That's it. One event type, one place it's published, observable via the existing event-bus subscribers.

Deferred to v2+:

  • Retry loop with max_retries and structured correction blocks
  • Rubric files (SKILL.md or otherwise)
  • escalate_on_reject path back to the orchestrator
  • Dashboard live stream + per-agent quality score in the agent status table
  • Config knobs (min_quality_score, etc.)

One question that unblocks v1: can you share a specific sub-agent output from your own OpenHuman usage where this would have caught a problem — a real hallucinated or incomplete output that propagated up unchallenged? A real failure case will shape the verdict criteria much better than a generic rubric, and tells me whether Fail.reasons should be free-form text, an enum of categories, or something else.

CodeGhost21 avatar May 27 '26 18:05 CodeGhost21