Skip to content

[codex] emit per-request TTFT completion telemetry#30883

Merged
xli-oai merged 2 commits into
mainfrom
xli-codex/per-request-ttft-telemetry
Jul 2, 2026
Merged

[codex] emit per-request TTFT completion telemetry#30883
xli-oai merged 2 commits into
mainfrom
xli-codex/per-request-ttft-telemetry

Conversation

@xli-oai

@xli-oai xli-oai commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Why

Codex telemetry pipeline needs a per-request TTFT value. The existing codex.turn_ttft is recorded once per turn, so it cannot represent later inference requests in the same turn and can miss the beginning of hidden reasoning.

This restores the low-volume per-request signal proposed in bk-nvidia#3 without bringing back per-WebSocket-event TRACE logging.

What changed

  • start a timer when each mapped Responses stream begins
  • latch the timer on the first response.output_item.added, including an empty hidden-reasoning item
  • attach ttft_ms to the existing codex.sse_event / response.completed telemetry record
  • cover the new completion field with an integration test

Semantics

The value is per inference request, not per turn. It measures mapped-stream-to-first-output-item latency, matching the customer-proposed metric. For HTTP, the stream is already established before timing begins, so request setup and response-header latency are excluded.

response.output_item.added is a client-visible proxy for the start of hidden reasoning; this does not claim access to the server's internal first raw-token timestamp.

Validation

  • just test -p codex-otel (47 passed)
  • just test -p codex-core process_sse_emits_completed_telemetry (1 passed after the final timer-placement change)
  • attempted just test -p codex-core: 2,855 passed and 53 failed because of unrelated local-environment failures (missing test_stdio_server fixture binary, shell startup noise, and timing-sensitive tests); the focused telemetry test passed in that run as well

@xli-oai xli-oai added the oai PRs contributed by OpenAI employees label Jul 2, 2026 — with ChatGPT Codex Connector
@xli-oai xli-oai marked this pull request as ready for review July 2, 2026 02:08
@xli-oai xli-oai requested a review from a team as a code owner July 2, 2026 02:08

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 36dadfb8bc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/client.rs
Comment thread codex-rs/core/src/client.rs
@xli-oai xli-oai merged commit 6ff670b into main Jul 2, 2026
35 checks passed
@xli-oai xli-oai deleted the xli-codex/per-request-ttft-telemetry branch July 2, 2026 11:45
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

oai PRs contributed by OpenAI employees

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants