Skip to content

analytics: add responses api call schema#18028

Open
rhan-oai wants to merge 1 commit intomainfrom
pr18028
Open

analytics: add responses api call schema#18028
rhan-oai wants to merge 1 commit intomainfrom
pr18028

Conversation

@rhan-oai
Copy link
Copy Markdown
Collaborator

@rhan-oai rhan-oai commented Apr 16, 2026

Why

We need a Responses API call analytics event that can support context-window-health analysis without logging raw prompt, tool, or model content. This PR adds the analytics-side event schema and item-metadata extraction primitives that describe the shape and approximate size of the ResponseItems involved in a Responses API call.

What changed

This adds the codex_responses_api_call_event request shape, including thread and turn identifiers, thread lifecycle metadata, client/runtime metadata, Responses API identifiers, model metadata, terminal status, timing, token counts, and per-item metadata.

It introduces CodexResponsesApiCallInput, CodexResponsesApiCallFact, CodexResponsesApiCallStatus, CodexResponsesApiItemMetadata, CodexResponsesApiItemPhase, and CodexResponseItemType in codex-rs/analytics/src/facts.rs. The public API intentionally exposes only the core-facing input/status types from codex_analytics; the event fact and item metadata remain analytics-internal.

It also adds codex-rs/analytics/src/response_items.rs, which maps protocol ResponseItems into metadata-only analytics records. The mapper captures fields such as item phase, item index, response item type, role, status, message phase, call id, tool name, payload byte size, text part count, and image part count. It avoids raw content while preserving enough structure to analyze context-window composition.

Finally, this adds small serialization/byte helpers in codex-rs/analytics/src/lib.rs that are shared by the response item metadata mapper.

Verification

Verified with cargo test -p codex-analytics, which covers the new response item metadata mapping tests.


Stack created with Sapling. Best reviewed with ReviewStack.

AppUsed(CodexAppUsedEventRequest),
HookRun(CodexHookRunEventRequest),
Compaction(Box<CodexCompactionEventRequest>),
#[allow(dead_code)]
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

to pass lint tests, removed in next commit

@rhan-oai rhan-oai force-pushed the pr18028 branch 2 times, most recently from c220805 to 5ea466f Compare April 22, 2026 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant