Skip to content

[Bug]: Anthropic Messages adapter drops sessionId when metadata is absent #318

Description

@JakobM7

Product or interface

CLI - interactive TUI

Version

MiniMax Code 0.5.2

Platform

Windows

OS version and architecture

Windows 11 x64

Issue area

MCP / OAuth / integration

Desktop log upload ID (optional)

No response

Steps to reproduce

  1. Configure MiniMax Code to use an Anthropic-compatible endpoint backed by OpenCodex.
  2. Start a long conversation with mostly unchanged context.
  3. Run several consecutive turns, including a subagent or branch request.
  4. Inspect the proxy usage data for observed cache reads.
  5. Compare the behavior with a local diagnostic change that forwards
    sessionId when metadata.user_id is absent.

Expected and actual behavior

Expected:

If the internal request contains a sessionId, the Anthropic request should
preserve the session identity, or the supported field/header for doing so
should be documented.

Actual:

The generated Anthropic request builder appears to forward metadata.user_id
only when a metadata object exists:

if (r?.metadata) {
  const userId = r.metadata.user_id;
  typeof userId === "string" &&
    (a.metadata = { user_id: userId });
}

When the request contains sessionId but no separate metadata object, no
metadata.user_id is emitted.
In a MiniMax Code -> OpenCodex setup, this was associated with
inconsistent observed prompt-cache reads, especially for subagent and branch
requests. A local diagnostic change using sessionId as a fallback resulted
in high cache reads in subsequent requests.

Redacted error summary

No runtime exception occurs. The issue is behavioral: repeated requests
sometimes report zero or very low observed cache reads despite mostly
unchanged context.

Screenshots

No response

Before submitting

  • I have searched existing issues.
  • I have included my version and removed sensitive information.

Activity

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

    bugSomething isn't workingneeds-infoWaiting for specific information requested from the reportertuiInteractive terminal UI (TUI)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions