Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/demo_qa/chat_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ def start_repl(
continue

run_id = uuid.uuid4().hex[:8]
run_dir = runs_root / f"{run_id}_{uuid.uuid4().hex[:8]}"
event_logger = EventLogger(path=None, run_id=run_id)

artifacts: RunArtifacts | None = None
try:
case = Case(id=run_id, question=line, tags=[])
result = run_one(case, runner, runs_root, plan_only=False, event_logger=event_logger)
result = run_one(case, runner, runs_root, plan_only=False, event_logger=event_logger, run_dir=run_dir)
plan_obj = _load_json(Path(result.artifacts_dir) / "plan.json")
ctx_obj = _load_json(Path(result.artifacts_dir) / "context.json") or {}
artifacts = RunArtifacts(
Expand All @@ -124,7 +125,7 @@ def start_repl(
print(result.answer or "")
print(f"Events: {Path(result.artifacts_dir) / 'events.jsonl'}")
except Exception as exc: # pragma: no cover - REPL resilience
error_artifacts = artifacts or RunArtifacts(run_id=run_id, run_dir=runs_root, question=line)
error_artifacts = artifacts or RunArtifacts(run_id=run_id, run_dir=run_dir, question=line)
error_artifacts.error = error_artifacts.error or str(exc)
last_artifacts = error_artifacts
save_artifacts(error_artifacts)
Expand Down
9 changes: 7 additions & 2 deletions examples/demo_qa/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,14 @@ def run_one(
*,
plan_only: bool = False,
event_logger: EventLogger | None = None,
run_dir: Path | None = None,
) -> RunResult:
run_id = uuid.uuid4().hex[:8]
run_dir = artifacts_root / f"{case.id}_{run_id}"
if run_dir is None:
run_id = uuid.uuid4().hex[:8]
run_dir = artifacts_root / f"{case.id}_{run_id}"
else:
run_id = run_dir.name.split("_")[-1]

case_logger = event_logger.for_case(case.id, run_dir / "events.jsonl") if event_logger else None
if case_logger:
case_logger.emit({"type": "case_started", "case_id": case.id, "run_dir": str(run_dir)})
Expand Down