Duplicate Check / 重复检查
Claudex Version
0.2.4
Operating System
Linux (x86_64)
Description / 描述
The OpenAI Responses streaming translator always starts Anthropic usage at input_tokens: 0 and only forwards output_tokens at the end. Claude Code consequently records every translated assistant turn with zero input tokens, so its context accounting cannot trigger proactive auto-compaction reliably.
When the Responses backend eventually emits response.failed with error.code: context_length_exceeded, upstream Claudex silently finalizes the stream as a normal end_turn. Newer error-aware variants that classify it as a generic api_error can instead make Claude Code enter its non-streaming fallback; ChatGPT's Codex Responses endpoint then rejects that fallback with Stream must be set to true, masking the original context overflow.
This is distinct from #5 / #6: those cover the proxy's HTTP request-body limit, while this report concerns translated token usage and terminal SSE error semantics.
Steps to Reproduce / 复现步骤
- Configure an
OpenAIResponses profile, such as ChatGPT Codex OAuth.
- Run a long Claude Code session through Claudex until its upstream context window is full.
- Inspect Claude Code's transcript usage: translated assistant turns report
input_tokens: 0.
- Observe the upstream
response.failed event with context_length_exceeded; the client does not receive a recognizable Anthropic invalid_request_error and does not compact normally.
Expected Behavior / 预期行为
- Terminal Responses usage is propagated through the final Anthropic
message_delta, including input and cached-input accounting.
context_length_exceeded becomes one terminal Anthropic invalid_request_error with no fabricated message_stop, allowing Claude Code's context-limit recovery to run.
Actual Behavior / 实际行为
- Input usage remains zero for the entire session.
- Context overflow is ignored or masked by a secondary non-streaming error.
Configuration / 配置
[[profiles]]
provider_type = "OpenAIResponses"
auth_type = "oauth"
oauth_provider = "chatgpt"
Proxy Logs / 代理日志
streaming=true model=<model>
Responses stream terminated with an error upstream_code=context_length_exceeded
streaming=false model=<model>
status=400 Bad Request body={"detail":"Stream must be set to true"}
Additional Context / 补充信息
Anthropic's TypeScript SDK merges input_tokens, cache_creation_input_tokens, and cache_read_input_tokens supplied in message_delta.usage, so the terminal Responses usage can be forwarded without buffering the stream.
Duplicate Check / 重复检查
Claudex Version
0.2.4
Operating System
Linux (x86_64)
Description / 描述
The OpenAI Responses streaming translator always starts Anthropic usage at
input_tokens: 0and only forwardsoutput_tokensat the end. Claude Code consequently records every translated assistant turn with zero input tokens, so its context accounting cannot trigger proactive auto-compaction reliably.When the Responses backend eventually emits
response.failedwitherror.code: context_length_exceeded, upstream Claudex silently finalizes the stream as a normalend_turn. Newer error-aware variants that classify it as a genericapi_errorcan instead make Claude Code enter its non-streaming fallback; ChatGPT's Codex Responses endpoint then rejects that fallback withStream must be set to true, masking the original context overflow.This is distinct from #5 / #6: those cover the proxy's HTTP request-body limit, while this report concerns translated token usage and terminal SSE error semantics.
Steps to Reproduce / 复现步骤
OpenAIResponsesprofile, such as ChatGPT Codex OAuth.input_tokens: 0.response.failedevent withcontext_length_exceeded; the client does not receive a recognizable Anthropicinvalid_request_errorand does not compact normally.Expected Behavior / 预期行为
message_delta, including input and cached-input accounting.context_length_exceededbecomes one terminal Anthropicinvalid_request_errorwith no fabricatedmessage_stop, allowing Claude Code's context-limit recovery to run.Actual Behavior / 实际行为
Configuration / 配置
Proxy Logs / 代理日志
Additional Context / 补充信息
Anthropic's TypeScript SDK merges
input_tokens,cache_creation_input_tokens, andcache_read_input_tokenssupplied inmessage_delta.usage, so the terminal Responses usage can be forwarded without buffering the stream.