From 72d2c8d53d242bcbe67d5a7c45c918cb9046b605 Mon Sep 17 00:00:00 2001 From: Silviu Druma Date: Sun, 25 Jan 2026 09:17:46 -0500 Subject: [PATCH] fix: fix opik trace id exception --- CONTRIBUTING.md | 1 + apps/api/src/planproof_api/routes.py | 10 ++++++++-- docs/assistant_prompts/codex_tasks.md | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4374e23..4aeffe5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -201,6 +201,7 @@ PlanProof values correctness over persuasion. - [x] PR 3.2: Validation Wiring - [X] PR 3.3: 1-Shot Repair Loop - [X] PR 4.1: Opik Trace Scaffolding +- [ ] PR 4.1.2 — Correct Opik Context Retrieval - [ ] PR 4.2: Opik Metrics Integration ## Infrastructure diff --git a/apps/api/src/planproof_api/routes.py b/apps/api/src/planproof_api/routes.py index abf44f9..d8c1ff1 100644 --- a/apps/api/src/planproof_api/routes.py +++ b/apps/api/src/planproof_api/routes.py @@ -22,7 +22,8 @@ PlanValidation, ValidationMetrics, ) -from planproof_api.observability.opik import opik, opik_context +from opik import opik_context +from planproof_api.observability.opik import opik router = APIRouter() @@ -228,7 +229,12 @@ def create_plan(request: PlanRequest) -> PlanResponse: ), errors=[str(exc)], ) - print(f"DEBUG: Trace ID: {opik.get_current_trace_id() or 'No Trace'}") + trace_id = "No Trace" + try: + trace_id = opik_context.get_current_trace_id() or "No Trace" + except Exception: + pass + print(f"DEBUG: Opik Trace ID: {trace_id}") return PlanResponse( plan=plan, diff --git a/docs/assistant_prompts/codex_tasks.md b/docs/assistant_prompts/codex_tasks.md index 4015931..a6cea06 100644 --- a/docs/assistant_prompts/codex_tasks.md +++ b/docs/assistant_prompts/codex_tasks.md @@ -54,6 +54,7 @@ The implementation must conform to: ## Phase 4 — Observability - [X] **PR 4.1:** Integrate Opik tracing hooks for each step (Extract -> Plan -> Validate -> Repair). +- [ ] **PR 4.1.2** — Correct Opik Context Retrieval - [ ] **PR 4.2:** Ensure `validation.metrics` are logged as properties in the Opik trace. ---