Skip to content

(CODUX-129) Harden Codex invocation parsing - #2810

Merged
numnx merged 1 commit into
feature/sprint-COWIN-3-feat-invocation-parsing-all-providers-implementationfrom
task/feature-sprint-c-t02-codex-4193c9a3-mreirp1j
Jul 10, 2026
Merged

(CODUX-129) Harden Codex invocation parsing#2810
numnx merged 1 commit into
feature/sprint-COWIN-3-feat-invocation-parsing-all-providers-implementationfrom
task/feature-sprint-c-t02-codex-4193c9a3-mreirp1j

Conversation

@numnx

@numnx numnx commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

🧩 Task: Harden Codex invocation parsing

Automated task PR opened by Code UX for T02.

📋 Summary

Sprint: Sprint 3 · Feat: Invocation Parsing all Providers · Task: T02

Implement extended invocation parsing across every local CLI provider so provider-backed invocations persist normalized user, assistant, reasoning, tool-call, and tool-result turns with accurate usage metadata, regression coverage, and updated documentation.

🤖 Model & Provider

Provider Codex CLI
Model gpt-5.5

⏱️ Timing

Started 2026-07-10 05:53:02 UTC
Finished 2026-07-10 06:02:27 UTC
Duration 9m 25s

📊 Token Usage

Metric Value
Input tokens 98,197
Cached input tokens 1,765,760
Output tokens 19,565
Total tokens 1,883,522
Invocations 1
Tool calls 46
Active time 7m 33s

Included usage estimate (subscription/local login): $1.96

✅ QA Review

⏳ QA review runs after this PR is opened. Check the task card in the dashboard for the outcome once it lands.

📝 Full Task Prompt
## Objective
Improve Codex invocation parsing so both rollout JSONL files and `codex exec --json` stdout consistently produce normalized conversation turns and isolated usage for the current invocation.

## Scope
- Edit `src/infrastructure/providers/cli/provider-logs/codex-log-parser.ts`
- Edit `tests/backend/infrastructure/providers/cli/codex-log-parser.test.ts`
- Verify integration behavior through `tests/backend/infrastructure/providers/cli/provider-usage.test.ts`
- Relevant symbols: `parseCodexRolloutJsonl`, `parseCodexExecStdout`, `turnsFromCodexItem`, `parseUsageObject`, `subtractUsageCounts`

## Implementation Requirements
1. Extend Codex parser handling for current rollout and exec schemas, including `response_item` messages, reasoning summaries, `function_call`, `custom_tool_call`, command execution items, tool outputs, `thread.started` or session ids, and `turn.completed` usage payloads.
2. Preserve invocation-window filtering with the existing start-time grace behavior so resumed or reused Codex session files do not replay earlier conversation turns as the current invocation.
3. Keep cumulative usage subtraction for rollout token snapshots and ensure cached input tokens are not double-counted in total tracked usage.
4. Add parser tests for mixed rollout and exec streams, malformed JSONL lines, duplicate event messages, current-run filtering, tool call/result pairing, and fallback transcript extraction.

## Constraints
- Do not count developer scaffolding or duplicated `event_msg` transcript rows as user-visible conversation turns.
- Do not throw on malformed JSONL records; skip bad records and keep valid later records.
- Preserve existing `collectProviderUsageTelemetry` preference order: rollout JSONL first, exec stdout fallback second, estimated telemetry last.
- Do not edit Gemini, Claude, Qwen, OpenCode, or Antigravity parser files in this task.

## Verification
- Run `pnpm exec vitest run tests/backend/infrastructure/providers/cli/codex-log-parser.test.ts tests/backend/infrastructure/providers/cli/provider-usage.test.ts`.
- Run `pnpm run lint`.
- Success means Codex invocations produce ordered normalized turns and per-invocation usage from both rollout files and exec stdout without regressing estimation fallback.
🌿 Branch Info

Base: feature/sprint-COWIN-3-feat-invocation-parsing-all-providers-implementation
Head: task/feature-sprint-c-t02-codex-4193c9a3-mreirp1j


🤖 Generated by Code UX

@numnx
numnx merged commit 00916cb into feature/sprint-COWIN-3-feat-invocation-parsing-all-providers-implementation Jul 10, 2026
@numnx
numnx deleted the task/feature-sprint-c-t02-codex-4193c9a3-mreirp1j branch July 10, 2026 06:03
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