Skip to content

fix: end a Codex turn when its task completes, not at the next prompt - #371

Open
Mark Warren (ZeSnarf) wants to merge 1 commit into
microsoft:mainfrom
PharSideLabs:claude/upstream-codex-turn-end
Open

Mark Warren (ZeSnarf) wants to merge 1 commit into
microsoft:mainfrom
PharSideLabs:claude/upstream-codex-turn-end

Conversation

@ZeSnarf

@ZeSnarf Mark Warren (ZeSnarf) commented Nov 3, 2026 •

Copy link
Copy Markdown

Description

A Codex turn's totalElapsed ran from the prompt to the last line logged before the next prompt. That line is often the next turn's task_started, so the time between turns counted as agent time. A 30-second answer followed by a prompt the next morning became a ten-hour turn, which inflated slow-response findings and turn-duration charts.

This PR:

  • records when a turn's task ends (task_complete or turn_aborted) and measures totalElapsed to that point;
  • extends the end to any assistant message, reasoning or tool call Codex logs after task_complete, so late work stays in the turn;
  • keeps the old measure for logs without these events;
  • bumps CACHE_VERSION.

We found this by running the extension on real Codex logs, where turns spanning an overnight gap showed up as hours-long agent runs.

Related Issues

None filed.

Checklist

  • npm run check passes (typecheck + lint + spellcheck + knip + tests)
  • Changes are covered by tests (parser-codex.test.ts: a turn ended by task_complete, one ended by turn_aborted, and work logged after task_complete)
  • Documentation updated (if applicable): not needed

A Codex turn's totalElapsed ran from the prompt to the last line before the
next prompt, so the time the user spent away between turns counted as the
agent working: a 30-second answer read the next morning became a
ten-hour turn. The turn now ends at task_complete or turn_aborted; work
Codex logs after that extends the turn to that work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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