Skip to content

[codex] Expose first-response analytics in SDK CLI MCP#18

Merged
purnendu-convai merged 1 commit into
mainfrom
codex/mode-latency-sdk-cli-mcp
May 12, 2026
Merged

[codex] Expose first-response analytics in SDK CLI MCP#18
purnendu-convai merged 1 commit into
mainfrom
codex/mode-latency-sdk-cli-mcp

Conversation

@purnendu-convai
Copy link
Copy Markdown
Member

@purnendu-convai purnendu-convai commented May 11, 2026

Summary

  • add first-response SDK resource, params, and response types
  • add CLI commands for summary/timeseries/breakdown/markers/settings/interaction waterfall
  • add MCP tools/resources, deprecate voice.user_to_bot_latency for SLA reporting, and align first-response defaults/help text

Local verification

  • npm run lint, npm run typecheck, npm test -- --test-name-pattern firstResponse, and npm run build in packages/typescript
  • npm test and npm run typecheck in packages/mcp
  • npm run typecheck in cli
  • git diff --check

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive "first-response" analytics suite across the CLI, MCP package, and TypeScript SDK, effectively deprecating the legacy voice.user_to_bot_latency metric. The changes include new CLI commands, MCP tools, and SDK methods for accessing first-response summaries, timeseries, breakdowns, and interaction waterfalls. Feedback focuses on improving the CLI implementation by correcting an overly restrictive type cast for granularity, expanding help descriptions to include missing grouping dimensions, and strengthening numeric validation for the limit parameter to properly handle NaN values.

Comment thread cli/src/commands/first-response.ts Outdated
.description("Bucketed P50/P95/P99 first-response latency for one character.")
.requiredOption("--character-id <id>", "Character id")
.option("--mode <mode>", "Observed mode")
.option("--group-by <dim>", "Optional group: mode | settings_hash | stage | provider | model | status | turn_scope")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The description for the --group-by option is missing several valid grouping dimensions supported by the SDK and MCP tools, specifically breakdown_kind and character_id.

Suggested change
.option("--group-by <dim>", "Optional group: mode | settings_hash | stage | provider | model | status | turn_scope")
.option("--group-by <dim>", "Optional group: mode | breakdown_kind | stage | settings_hash | turn_scope | provider | model | status | character_id")

Comment thread cli/src/commands/first-response.ts Outdated
groupBy: opts.groupBy as FirstResponseGroupBy | undefined,
turnScope: opts.turnScope as TurnScope,
latencyKind: opts.latencyKind as FirstResponseLatencyKind,
granularity: opts.granularity as "hour",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The granularity option is cast to the literal type "hour", which is incorrect as the CLI option allows minute, hour, or day. This cast will cause the TypeScript compiler to ignore invalid values while potentially misleading developers about the supported runtime values.

Suggested change
granularity: opts.granularity as "hour",
granularity: opts.granularity as "minute" | "hour" | "day",

Comment thread cli/src/commands/first-response.ts Outdated
.command("breakdown")
.description("Grouped first-response latency for one character.")
.requiredOption("--character-id <id>", "Character id")
.option("--group-by <dim>", "mode | settings_hash | stage | provider | model | status | turn_scope", "mode")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The description for the --group-by option is missing several valid grouping dimensions supported by the SDK and MCP tools, specifically breakdown_kind and character_id.

Suggested change
.option("--group-by <dim>", "mode | settings_hash | stage | provider | model | status | turn_scope", "mode")
.option("--group-by <dim>", "mode | breakdown_kind | stage | settings_hash | turn_scope | provider | model | status | character_id", "mode")

Comment thread cli/src/commands/first-response.ts Outdated
turnScope: opts.turnScope as TurnScope,
latencyKind: opts.latencyKind as FirstResponseLatencyKind,
range: opts.range as RelativeRange,
limit: typeof opts.limit === "number" ? opts.limit : undefined,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The limit check only verifies if the type is number, which includes NaN. If a non-numeric value is passed to the CLI, opts.limit will be NaN, which is then passed to the SDK and eventually the API. It's safer to use Number.isFinite() to ensure a valid numeric value is sent.

Suggested change
limit: typeof opts.limit === "number" ? opts.limit : undefined,
limit: typeof opts.limit === "number" && Number.isFinite(opts.limit) ? opts.limit : undefined,

@purnendu-convai purnendu-convai force-pushed the codex/mode-latency-sdk-cli-mcp branch from 58058d1 to 597fada Compare May 11, 2026 20:17
Copy link
Copy Markdown

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

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: 58058d1d69

ℹ️ 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 packages/mcp/src/tools.ts Outdated
handler: (client, args) =>
client.firstResponse.settings(pickString(args, "settingsHash")!, {
characterId: pickString(args, "characterId"),
range: pickRange(args),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor last_30d default for first-response settings

The schema for get_first_response_settings declares range defaults to last_30d, but the handler calls pickRange(args), which falls back to last_24h when range is omitted. That mismatch narrows the lookup window and can cause settings hashes older than 24 hours to appear missing even though callers followed the documented defaults. Use a last_30d fallback in this handler (or read the schema-defaulted value directly) so behavior matches the declared contract.

Useful? React with 👍 / 👎.

@purnendu-convai purnendu-convai force-pushed the codex/mode-latency-sdk-cli-mcp branch from 597fada to d6c9d25 Compare May 11, 2026 20:41
@purnendu-convai purnendu-convai merged commit 35cbf99 into main May 12, 2026
10 checks passed
@purnendu-convai purnendu-convai deleted the codex/mode-latency-sdk-cli-mcp branch May 12, 2026 00:10
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