fix(litellm): link traces on the Anthropic /v1/messages path
Problem (found during live dev testing)
After MR #1, the consolidation was half-working on real agent traffic: routing succeeded (low-level GENERATIONs reached the correct Langfuse project) but linking failed — they landed in a separate litellm-anthropic_messages trace instead of attaching to the agent-request trace.
Root cause: the agently Claude Agent SDK calls LiteLLM via the Anthropic /v1/messages endpoint, not /v1/chat/completions. That handler rebuilds the request metadata, so data["metadata"]["existing_trace_id"] set in the pre-call hook is lost by log time. (The logging-object reference survives, which is why routing still worked.)
Fix
Also inject langfuse_existing_trace_id into the proxy_server_request headers, which the langfuse logger reads at log time via add_metadata_from_header. Works on both /v1/messages and /v1/chat/completions.
Verified live on nocode
-
/v1/messages+x-agent-langfuse-trace-id→ GENERATION attaches to the target trace ✓ (previously created an orphan) -
/v1/chat/completions→ still links ✓ (no regression)
Already applied live on the box.