Add required human review gate to the Agent pipeline.
Agent web jobs now stop after Brain consolidation and enter needs_review with a persisted review queue (blocking: high-severity, low-confidence, sensitive-category findings; audit sample of clean clusters). Humans decide confirm/reject/unsure/needs_clarification via new review API and frontend queue; a finalizer applies decisions (rejections suppressed with reason codes), performs bounded targeted reruns for clarifications, drafts RFIs only for kept issues, and only then marks the job done and sends the final email. Two-phase email (review-required, then final report), per-decision feedback labels with redacted aggregate metrics, restart recovery from job artifacts, and CLI --no-review bypass. Classic pipeline unchanged. 65 non-LLM tests.
This commit is contained in:
+24
-8
@@ -17,6 +17,7 @@ _ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
if _ROOT not in sys.path:
|
||||
sys.path.insert(0, _ROOT)
|
||||
|
||||
from backend import config # noqa: E402
|
||||
from backend.agents.runner import run_agent_pipeline # noqa: E402
|
||||
from backend.pipeline.runner import run_pipeline # noqa: E402
|
||||
|
||||
@@ -33,6 +34,9 @@ def main() -> int:
|
||||
parser.add_argument("--occupancy", default=None)
|
||||
parser.add_argument("--work-type", default=None,
|
||||
help="new_building | remodel | tenant_improvement | addition | ...")
|
||||
parser.add_argument("--no-review", action="store_true",
|
||||
help="Agent mode only: skip the human-review gate and finish the run "
|
||||
"(overrides AGENT_REQUIRE_REVIEW=true)")
|
||||
args = parser.parse_args()
|
||||
|
||||
if not os.path.isfile(args.pdf):
|
||||
@@ -46,13 +50,21 @@ def main() -> int:
|
||||
}.items() if v
|
||||
}
|
||||
out_dir = args.out or os.path.join("out", os.path.splitext(os.path.basename(args.pdf))[0])
|
||||
runner = run_agent_pipeline if args.mode == "agent" else run_pipeline
|
||||
report = runner(
|
||||
args.pdf,
|
||||
out_dir=out_dir,
|
||||
project_input=project_input or None,
|
||||
source_name=os.path.basename(args.pdf),
|
||||
)
|
||||
if args.mode == "agent":
|
||||
report = run_agent_pipeline(
|
||||
args.pdf,
|
||||
out_dir=out_dir,
|
||||
project_input=project_input or None,
|
||||
source_name=os.path.basename(args.pdf),
|
||||
require_review=config.AGENT_REQUIRE_REVIEW and not args.no_review,
|
||||
)
|
||||
else:
|
||||
report = run_pipeline(
|
||||
args.pdf,
|
||||
out_dir=out_dir,
|
||||
project_input=project_input or None,
|
||||
source_name=os.path.basename(args.pdf),
|
||||
)
|
||||
|
||||
s = report["summary"]
|
||||
print("\n" + "=" * 60)
|
||||
@@ -60,7 +72,11 @@ def main() -> int:
|
||||
f"(high {s['by_severity']['high']}, "
|
||||
f"medium {s['by_severity']['medium']}, "
|
||||
f"low {s['by_severity']['low']})")
|
||||
print(f" Report: {os.path.join(out_dir, 'report.md')}")
|
||||
if s.get("agent_status") == "needs_review":
|
||||
print(" Stopped for human review - finalize via the web UI, "
|
||||
"or rerun with --no-review.")
|
||||
else:
|
||||
print(f" Report: {os.path.join(out_dir, 'report.md')}")
|
||||
print("=" * 60)
|
||||
return 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user