-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
blockedeffort-largeLarge effort issues - more than 12 hours of workLarge effort issues - more than 12 hours of workmetricsIssues related to request inspection and performance metricsIssues related to request inspection and performance metricspriority-mediumMedium priority issues - important features or significant improvementsMedium priority issues - important features or significant improvements
Description
Summary
Extend the plugin's diagnostics with Codex-style metrics and request inspection commands (e.g. /codex-metrics, /codex-inspect) that expose structured information similar to ResponsesRequest in openai/codex.
Background
In openai/codex:
codex-rs/core/tests/common/responses.rsandcore/tests/suite/tool_harness.rsuse aResponsesRequesthelper to inspect:body_json,input,function_call_output,custom_tool_call_output,call_output,header,path,query_param.
- Tests assert fine-grained behaviors around tool calls, request paths, and payload structure.
In this plugin:
- We already have a
/codex-metricscommand and logging controlled byENABLE_PLUGIN_REQUEST_LOGGING. - We also track basic cache and instruction metrics.
There is still room to provide more structured, Codex-CLI-like diagnostics that make it easier to debug tool calls, prompt caching, and request transformation.
Proposed Features
-
Enhanced
/codex-metricsoutput- Include per-session counters for:
- Number of Codex requests made.
- Cache hits vs misses vs "no cache key" cases.
- Number of tool calls, broken down by tool type (
shell,apply_patch, custom tools, MCP tools). - Number of compaction events (once plugin-level compaction is implemented).
- Surface the current normalized model and reasoning config (effort/summary/verbosity) as seen by the plugin.
- Include per-session counters for:
-
New
/codex-inspectcommand- Provide a command that prints the last N Codex requests in a structured way (similar to
ResponsesRequest):- HTTP method, path, and key headers (e.g.
chatgpt-account-id, beta headers). - The transformed request body:
model,prompt_cache_key,store,stream,include.toolsandtool_choice/parallel_tool_callsafter normalization.inputafter filtering (stripped IDs, filtered system prompts, injected bridge/tool-remap message).
- HTTP method, path, and key headers (e.g.
- Provide safe redaction for sensitive values (e.g. tokens, account IDs) so inspection is safe to use in logs or bug reports.
- Provide a command that prints the last N Codex requests in a structured way (similar to
-
Optional JSON output for automation
- Allow
/codex-inspectto return a JSON-encoded structure when a flag is present (e.g./codex-inspect --json) so that advanced users can pipe it into other tools.
- Allow
-
Testing and observability
- Add tests that:
- Verify
/codex-metricsand/codex-inspectwork without making additional network calls. - Ensure redaction logic is applied correctly (no secrets leaked in snapshots).
- Exercise edge cases like empty history, no tools, and multiple requests per session.
- Verify
- Add tests that:
Rationale
- Brings the plugin's debugging experience closer to Codex CLI's
ResponsesRequest-driven tests and tooling. - Makes it much easier to debug complex tool flows and caching behavior from within opencode.
- Provides a natural place to hang future diagnostics (e.g. model upgrades, parallel tool-call behavior, compaction metrics).
Acceptance Criteria
/codex-metricsexposes richer per-session stats without regressing existing output./codex-inspectcan show at least the last request in a structured, partially redacted way.- JSON output option is available and documented.
- Tests cover the major paths and redaction behavior.
Metadata
Metadata
Assignees
Labels
blockedeffort-largeLarge effort issues - more than 12 hours of workLarge effort issues - more than 12 hours of workmetricsIssues related to request inspection and performance metricsIssues related to request inspection and performance metricspriority-mediumMedium priority issues - important features or significant improvementsMedium priority issues - important features or significant improvements