Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
N
nocode-gpu-stack
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • agently
  • nocode-gpu-stack
  • Merge requests
  • !2

Open
Created Jun 28, 2026 by agently@agentlyMaintainer
  • Report abuse
Report abuse

fix(litellm): link traces on the Anthropic /v1/messages path

  • Overview 0
  • Commits 4
  • Changes 6

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.

🤖 Generated with Claude Code

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: agent/litellm-langfuse-routing-e137