Skip to content

MCP schema is non-deterministic #1930

Description

@tonybaloney

Description

I noticed that the logfire remote MCP server tools/list API returns the response in a slightly different order about 6% of the time.

I don't know how the schema is being serialized, but my guess is that whatever you're using for a hashmap is not a stable, ordered map.

This matters because Claude Code, GitHub Copilot, Codex etc. give a 90% discount to cached input tokens, but the logfire schema changes every few calls which invalidates a ~2,000 token chunk of the cache (and costs more money).

Python, Logfire & OS Versions, related packages (not required)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions