Skip to content

[Bug]: Grok Build turns on ChatGPT-backed OpenAI models get almost no prompt-cache reuse (missing session_id) #6481

Closed

Description

@lidge-jun

Client or integration

Other

Area

Proxy and routing

Summary

Grok Build (the grok CLI, wired by ocx through the managed [model_providers.opencodex] block with x-opencodex-grok = "1") gets almost no prompt-cache reuse when it uses an OpenAI model served by the ChatGPT Codex backend (for example gpt-6-astra). The same model used from Codex reuses the prefix normally.

From the last 400 request-log entries on one machine:

Surface Model Requests Cached input share Affinity
Codex gpt-6-astra 122 97.1% —
Grok gpt-6-astra 88 13.6% new_bind on all 88
Grok claude-opus-5-5 31 90.8% —

The Grok rows show cachedInputTokens of 0 or a fixed 3200/4992 regardless of conversation length, and conversationId is never set.

Cause: Grok sends its conversation identity as x-grok-conv-id / x-grok-session-id and as the body prompt_cache_key, but it never sends the session_id header that Codex clients send. The ChatGPT Codex backend only reuses a warmed prefix when session_id is present, and opencodex also reads that header for thread affinity and request-log conversation identity. Grok's request bodies are append-only across turns (checked by diffing consecutive captured bodies: tools identical, input a strict prefix), so the client is not the problem.

Reproduction

  1. ocx with an OpenAI (ChatGPT) account and the Grok integration enabled.
  2. In Grok Build, pick ocx-gpt-6-astra and run a multi-turn task (several tool calls).
  3. Open Logs: every Grok/gpt-6-astra row is affinity: new_bind and cached input stays near zero.

A/B confirmation by replaying one captured Grok request body (≈16.7k input tokens) three times against /v1/responses with the Grok headers:

Replay cached_tokens
no session_id header 0 → 0 → 0
session_id = the body's prompt_cache_key 0 → 16640 → 16640

Version

2.76.0 (dev at 4b74668)

Operating system

macOS (aarch64)

Provider and model

openai (ChatGPT Codex backend, pool account) / gpt-6-astra, Grok Build 1.0.46

Logs or error output

surface=grok model=gpt-6-astra affinity=new_bind conversationId=<none> usage.inputTokens=42565 cachedInputTokens=3200

Screenshots and supporting files

Logs page with consecutive Grok gpt-6-astra rows at 2만+ tokens and cache c 3200 or none.

Redacted configuration

[model_providers.opencodex]
base_url = "http://127.0.0.1:10100/v1"
api_backend = "responses"
api_key = "opencodex-loopback"

[model_providers.opencodex.extra_headers]
x-opencodex-grok = "1"

Checks

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

Activity

  1. added
    proxyHTTP proxy, routing, reverse-proxy / management auth
    toolstool_calls, MCP, web-search / sidecar tools
    on Oct 3, 2026
  2. added a commit that references this issue on Oct 3, 2026
    7625014
  3. lidge-jun commented on Oct 3, 2026

    @lidge-jun
    OwnerAuthor

    Fixed on dev by #6482.

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 workingproxyHTTP proxy, routing, reverse-proxy / management authtoolstool_calls, MCP, web-search / sidecar tools

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions