Skip to content

[Bug]: Claude Code transcripts cannot correlate /v1/messages replies with the durable OCX request ID #6815

Closed

Description

@thisisjun786

Client or integration

Claude Code

Area

Proxy and routing

Summary

On the installed OpenCodex 2.80.0, Claude Code transcript records can lack requestId for responses handled by the proxy, even though OpenCodex records its own ocx-... request ID in durable request history. A downstream usage collector then has no deterministic per-call key to relate the Claude transcript to the authoritative proxy record.

This is a correlation gap, not evidence that OpenCodex failed to record or price the request. A collector can continue counting the proxy ledger once and keep the unlinked transcript as unresolved; it cannot safely infer whether an unlinked native-model transcript was a direct Anthropic call or an OCX call.

Observed evidence

Read-only inspection of the installed 2.80.0 source shows:

  • src/server/index/startup-warnings.ts defines withRequestLogId(response, requestId) and sets only x-opencodex-request-id.
  • The /v1/messages route in src/server/index/serve-options.ts does not expose that log ID through the Anthropic-compatible request-id response header.
  • Claude Code's persisted metadata can have an absent top-level requestId while proxy request-history rows retain their OCX request IDs.
  • The retained proxy usage metadata does not provide a corresponding Claude message ID or upstream request ID that can be joined to those old transcript rows. A conversation-level hash is not a per-call join key.
  • message.id is insufficient: native passthrough can preserve an upstream Anthropic message ID, so its shape alone does not prove which route answered.

No prompts, credentials, real request IDs, account details, local paths, usage totals, or transcript bodies are attached.

Reproduction

Use an isolated fake HOME and the existing mocked-server test setup; a paid provider call is unnecessary.

  1. Configure a mock Anthropic Messages upstream and start the real proxy server through the existing Claude integration test harness.
  2. Send a POST /v1/messages request with a regular native Claude model identifier, first streaming and then non-streaming. Let the mock return a normal Messages response and usage.
  3. Inspect the downstream response headers and the corresponding durable request-history ID.
  4. Inspect the metadata a Claude Code client persists from the response: its requestId is obtained from the protocol request-id header, not the custom x-opencodex-request-id header.
  5. Observe that the proxy has a durable OCX ID but the client may retain no matching ID, preventing exact transcript-to-ledger correlation.

The current report combines installed-source inspection and existing transcript/ledger metadata observations. No new live model call was made for this report. The mocked procedure describes a regression test the maintainers can run.

Expected behavior

A logged /v1/messages response should expose a stable, documented correlation ID through metadata Claude Code actually persists, and that ID should identify the same durable proxy request-history row.

Please cover native and translated responses, streaming and non-streaming responses, and logged refusals. Preserve stream cancellation, response bodies, existing header semantics, and privacy boundaries. Responses which have no log row should not acquire a misleading ledger association.

If request-id is used for the OCX log ID, document how any upstream Anthropic request ID is represented separately. An alternative supported correlation contract that Claude Code persists would also address the issue.

This would help future records. It does not retroactively prove the route of old records that lack any shared key; timestamps, model names, or approximate token matches must not be treated as exact reconstruction.

Version

Installed @bitkyc08/opencodex 2.80.0

Operating system

Linux

Provider and model

Anthropic Messages-compatible native Claude route; the issue is the client/proxy correlation contract rather than a particular model.

Duplicate search

Searched this repository's issues and PRs for request-id, requestId transcript, x-opencodex-request-id, and transcript accounting.

Related #1217 covers durable stream diagnostics and the custom correlation header; it does not cover Claude Code persisting the standard Messages header. #6775 concerns test HOME isolation, not response-to-transcript correlation. No exact duplicate was found in these targeted searches.

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

  1. added
    bug
    cli
    proxy
    on Oct 9, 2026
  2. added a commit that references this issue on Oct 9, 2026
    4504a56
  3. lidge-jun commented on Oct 9, 2026

    @lidge-jun
    Owner

    Fixed on dev by #6831 (merge commit 4504a56).

    When the proxy writes a request-history row for a /v1/messages response, the standard request-id header and x-opencodex-request-id now both carry that row's durable OCX id. This covers native and translated routes, streaming and non-streaming responses, and the refusals that are logged. Responses without a log row get no ledger id. On native Anthropic routes, the upstream's own request id moves to x-opencodex-upstream-request-id, and only a bounded req_... value is carried. Both names are exposed through CORS. Bodies, SSE payloads and message.id are unchanged. The contract is documented in the proxy formats reference. It ships with the next release.

    Older transcripts are not linked retroactively, as you noted. A live Claude Code transcript capture was not part of this change's verification.

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

    bugcliproxy

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions