Enable Phoenix tracing for Prompt Agent (hosted) targets - #63
Conversation
Jake Present (jakepresent)
left a comment
There was a problem hiding this comment.
This looks directionally good to me. I ran a local compile plus targeted runtime/import tests: 140 passed, 1 skipped.
I’d wait to approve/merge until #23 lands and this is rebased, since this currently touches p2m/stages/rollout.py and #23 moves that surface to inference.py / test-case terminology. After the rebase, the only thing I’d want to sanity-check is that the hosted-target trace path still registers Phoenix instrumentation in the renamed inference stage. A tiny unit test around “hosted target + target.trace registers once” would be nice, but I don’t think it needs to block if the smoke result holds.
|
Found one issue while doing a partial review before the rebase. The existing targeted tests still pass locally:
But directly exercising That means I think the fix is either:
After that plus the post-#23 rebase from |
0b9fb4a to
3cc91b4
Compare
Add _ensure_hosted_trace_instrumentation() that registers Phoenix OTEL and instruments only litellm (via LiteLLMInstrumentor) to capture spans for HostedSession LLM calls. - Use explicit LiteLLMInstrumentor().instrument() instead of auto_instrument=True to avoid side-effects from other providers - Set _hosted_trace_registered flag only after successful registration - Guard with ImportError (missing deps) and broad Exception handling - Called from _build_target_session when target.trace is configured
3cc91b4 to
6a0d0cd
Compare
|
Thanks for the review! Updated with all the fixes:
Also added unit tests ( |
Add _ensure_hosted_trace_instrumentation() that registers Phoenix OTEL and instruments only litellm (via LiteLLMInstrumentor) to capture spans for HostedSession LLM calls. - Use explicit LiteLLMInstrumentor().instrument() instead of auto_instrument=True to avoid side-effects from other providers - Set _hosted_trace_registered flag only after successful registration - Guard with ImportError (missing deps) and broad Exception handling - Called from _build_target_session when target.trace is configured
Problem
target.trace: { backend: phoenix }was silently ignored for Prompt Agent (model-only) targets. Thetraceconfig was only consumed inside theif target.is_callable:branch inrollout.py, soHostedSessionnever set up instrumentation.Fix
When
target.traceis set for a hosted target, callphoenix.otel.register(auto_instrument=True)before building the session. This detects the installedopeninference-instrumentation-litellmpackage and monkey-patches litellm so everyacompletioncall emits spans to Phoenix automatically._hosted_trace_registeredflag ensures it runs once per processarize-phoenix-otelis not installedTesting
Ran a smoke config with
azure/gpt-5.4-nano+trace: { backend: phoenix }. Confirmed:Enabled Phoenix auto-instrumentation for hosted session tracing