Skip to content

feat: send session/request ID to LLM provider for call grouping #3

@a6b8

Description

@a6b8

Problem

When reviewing LLM provider activity (e.g. OpenRouter dashboard), the "App" column shows "Unknown" for all calls from mcp-agent-server. This makes it impossible to:

  • Group calls that belong to the same user request
  • Distinguish which agent made which call
  • Analyze cost per conversation/session

OpenRouter Activity

Proposal

The mcp-agent-server should send identifying metadata with each LLM call so providers can display it in their dashboards:

1. App Name

Send a static app identifier (e.g. X-Title header for OpenRouter) so calls show up as "Anschluss Mobility" instead of "Unknown".

2. Session/Request ID

Send a unique session or request ID with each call so all sub-agent calls from one user question can be grouped together. For example:

  • User asks: "How do I get from the station to my office?"
  • Main Agent call → session: req-abc123
  • Bahnhof Agent call → session: req-abc123
  • Weather Agent call → session: req-abc123
  • Navigator Agent call → session: req-abc123

All 4 calls would be grouped under req-abc123 in the provider dashboard.

3. Agent Name

Include the agent name (e.g. ticketkauf, radparken) so you can see which specialist made the call.

Implementation Ideas

OpenRouter supports these headers:

  • X-Title — App name shown in dashboard
  • HTTP-Referer — Can be used for grouping

A possible approach:

  • Generate a sessionId per incoming user request in the server
  • Pass it through to all sub-agent LLM calls
  • Set X-Title to {appName}/{agentName}

Context

Discovered during cost analysis of the "Anschluss erreichen" Hackathon (March 2026). 251 calls, $4.22 total — but impossible to tell which calls belonged to which user question.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions