Skip to content

fix(ai): name or refuse a gateway caller without an end-user header #3578

Closed

Description

@devops-cli-service

Split from #3485.

Problem

litellm_proxy_total_requests_metric_total{end_user="None"} counts gateway requests that name no caller. gateway_caller_headers in src/devops_cli/ai/client/network.py sends the header x-litellm-end-user-id, so only a client that omits the header shows None. Nobody has found that client: these series have user="default_user_id", no key alias and no team, and the gateway logs hold no request lines.

  • In the 24 h to 2026-11-05T17:15Z, the series shows about 15 qwen3-embedding:0.6b and 5 qwen3.8:27b requests.
  • In the window of fix(k8s): the coder tier serves no second chat model #3485 (2026-11-03T15:05Z to 2026-11-04T15:05Z), 295 of 321 qwen3.8:27b requests had no end-user value. The same label sent all 30 gpt-oss:20b requests, and all 30 failed. This is a lead, not a proof.

Expected

Each request to the gateway names its caller, or the gateway refuses it.

Acceptance criteria

  • The client that sends no header names itself or gets a refusal, and litellm_proxy_total_requests_metric_total{end_user="None"} shows 0 over 24 h.

Existing tool considered

The end-user header (#1668). LiteLLM cannot name a caller that omits this header, as the refine proposal of #3485 states.

Related

Related: #3485, #1668, #2479

Proposed design

Problem statement

Some requests reach the gateway with no caller name, so litellm_proxy_total_requests_metric_total counts them as end_user="None". Every client in this repository sends x-litellm-end-user-id, but its value comes from otel_service_name() with no fallback. A process that sets no OTel service name therefore sends an empty value. The change gives the header a non-empty value on every gateway request from this repository.

Acceptance criteria

Requirement: Non-empty end-user value

gateway_caller_headers SHALL return a non-empty x-litellm-end-user-id value for every gateway request.

Scenario: No OTel service name

  • WHEN otel_service_name() returns an empty string
  • THEN gateway_caller_headers() returns x-litellm-end-user-id with the value devops-cli.

Requirement: Every gateway path names its caller

The OpenAI client, the embeddings client and the pydantic-ai gateway client SHALL each send x-litellm-end-user-id with a non-empty value on every gateway request.

Scenario: Recorded request headers

  • WHEN each client sends a chat or embedding request to a mock transport
  • THEN each recorded request holds x-litellm-end-user-id with a non-empty value.

Existing Tool Considered

No alternatives check has run. LiteLLM (BerriAI/litellm, https://github.com/BerriAI/litellm) is the open, maintained tool that covers the need: its x-litellm-end-user-id header sets the end_user label on litellm_proxy_total_requests_metric_total. It lacks a way to name a caller that sends no header or an empty value, so the client must always send a non-empty value.

Key questions

  • Which client sends a gateway request with no end-user header?: No client in this repository omits the header. gateway_caller_headers sets x-litellm-end-user-id from otel_service_name() with no fallback, so an empty service name gives an empty header value, and the gateway records it as None. [sources: src/devops_cli/ai/client/network.py:64, src/devops_cli/ai/client/network.py:80, src/devops_cli/ai/client/openai.py:36, src/devops_cli/ai/rag/embeddings.py, openspec/changes/archive/2026-10-29-1668-gateway-traffic-dashboard/tasks.md:7]
  • What value names the caller when the process sets no OTel service name?: gateway_caller_headers returns the fixed value devops-cli for x-litellm-end-user-id when otel_service_name() is empty. (best practice) [sources: src/devops_cli/ai/client/network.py:64, src/devops_cli/ai/client/network.py:70]
    • Chosen: Fixed fallback in gateway_caller_headers. It names the caller in every process, and one function keeps the rule.
    • Rejected: Refuse the call with AIClientError. It stops every CLI call on a workstation that sets no OTel service name.
    • Rejected: Refuse the request at the LiteLLM gateway. The gateway configuration is outside this repository, so a separate item holds it.
  • How does an offline test prove that each gateway client path sends the end-user header?: Each client sends a request to a mock transport, and the test reads the recorded request headers. (best practice) [sources: tests/ai/client/test_gateway_caller_headers.py, tests/ai/client/test_ai_client_network.py]
    • Chosen: Mock transport that records request headers. It runs offline and checks the header that the client actually sends.
    • Rejected: A live call to the gateway. It needs network access and a running gateway, so it is no offline test.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/ai
    status/new
    value/medium
    effort/low
    on Nov 5, 2026
  2. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    ContributorAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/ai. The (ai) scope of the title gives the scope.
    • Priority: P2-Medium. Missing end-user headers produce empty metric labels, degrading observability but not breaking functionality.
    • Value: Medium. Correct caller attribution in metrics is needed for accurate spend and usage reporting.
    • Effort: Low. A single check for the header with a default name or a refusal response is a small change.
    • Related: feat(monitoring): the ai-spend dashboard counts gateway traffic from the gateway's own series, shows failed attempts and names each caller #1668, which asks for a different change. Both concern naming gateway callers, but the candidate changes gateway request handling while #1668 changes dashboard display of caller names.
  3. dan-petty commented on Nov 5, 2026

    @dan-petty
    Owner

    Answer from project standards, under the owner's instruction of 2026-11-05.

    Question: What does this item ask for? Its body stopped at {end_user=.

    Answer: It asks for criterion 4 of #3485: "The client that sends no header names itself or gets a refusal, and litellm_proxy_total_requests_metric_total{end_user="None"} shows 0 over 24 h."

    Source of the answer: the acceptance criteria of #3485, its refine proposal, which says that LiteLLM cannot name a caller that omits the end-user header and defers the unnamed caller, and the record refine.deferred on #3485, which names this item.

    What I changed

    I restored the criterion text and added the problem, the expected result, the existing tool and the related issues from #3485. The first line and the record block have not changed. I did not change the labels.

    What I checked at 2026-11-05T17:15Z

    • Prometheus: over the last 24 h, end_user="None" shows about 15 qwen3-embedding:0.6b and 5 qwen3.8:27b requests, with user="default_user_id", no key alias and no team. So the criterion does not hold.
    • gateway_caller_headers in src/devops_cli/ai/client/network.py still sends x-litellm-end-user-id.
    • I did not find the client. I also did not find why the body stopped at that point.

    For a person

    devops roadmap explain 3578 says that a refine round does not take this item, because GitHub gives its author the association CONTRIBUTOR. So only devops roadmap refine --item 3578 --confirm refines it. I did not run that command. I changed no code.

  4. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    ContributorAuthor

    Refine cannot set this item to Ready at bd65ef6. A bot opened the item, so a review of the issue and of the proposal must approve it first. The review found the defects below. A person edits the body to answer them. The next refine round looks at the item again only after a body edit.

    • false_premise at key_questions[0]: The plan claims that an empty OTel service name causes the None label. No cited file text supports this, because files is empty. The issue says the series come from a client that omits the header. Evidence: "so an empty service name gives an empty header value, and the gateway records it as None."
  5. added
    status/in-review
    and removed
    status/new
    on Nov 14, 2026
  6. removed
    status/in-review
    on Nov 14, 2026
  7. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    ContributorAuthor

    Live since 2026-11-14 15:02 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/aisource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions