fix(platform): expose run correlation in list

This commit is contained in:
Your Name
2026-07-22 17:48:43 +08:00
parent 34d6f88f0c
commit 7b3b7786c7
6 changed files with 165 additions and 25 deletions

View File

@@ -35,8 +35,7 @@ from src.db.base import get_db_context
from src.services.run_state_machine import LEASE_TTL_SECONDS, transition
from src.services.runtime_correlation import (
canonical_traceparent,
canonical_work_item_id,
is_canonical_traceparent,
correlation_readback_for_run,
new_runtime_correlation,
new_uuid7,
)
@@ -412,21 +411,18 @@ async def get_run_status(run_id: UUID, project_id: str) -> dict[str, Any] | None
if run is None:
return None
work_item_id = canonical_work_item_id(run.project_id, run.run_id)
trace_id = str(run.trace_id or "")
correlation = correlation_readback_for_run(
run.project_id,
run.run_id,
run.trace_id,
)
return {
"run_id": str(run.run_id),
"project_id": run.project_id,
"agent_id": run.agent_id,
"state": run.state,
"is_shadow": run.is_shadow,
"trace_id": run.trace_id,
"work_item_id": work_item_id,
"correlation_status": (
"canonical"
if is_canonical_traceparent(trace_id, run_id=run.run_id)
else "legacy_or_invalid_trace"
),
**correlation,
"attempt_count": run.attempt_count,
"cost_usd": float(run.cost_usd),
"step_count": run.step_count,