Skip to content

Require Codex turn-completion evidence before reporting trigger success - #13

Draft
motonari728 wants to merge 49 commits into
wavever:mainfrom
motonari728:codex/verify-tui-completion
Draft

Require Codex turn-completion evidence before reporting trigger success#13
motonari728 wants to merge 49 commits into
wavever:mainfrom
motonari728:codex/verify-tui-completion

Conversation

@motonari728

Copy link
Copy Markdown

Summary

This PR bridges #11's Codex/Spark TUI completion detection and #12's quota verification and result reporting.

The changes are split this way so that #11 and #12 remain independently reviewable and mergeable. This PR connects their behavior, so parts of the problem and solution intentionally overlap with those PRs.

This PR cannot be merged on its own: both #11 and #12 must land first.

Kept as a draft until those prerequisites are merged. The current diff against main includes both prerequisite PRs; afterward, it should show only the bridging changes. Maintainers: once #11 and #12 are merged and the diff is correct, please mark this PR ready for review and review it. If the prerequisites are squash-merged or rebased, this branch may need to be updated first to remove their changes from GitHub's comparison.

Problem

A Codex TUI timeout or a clean exit without a completion notification can be reported as success even though turn completion was not confirmed.

When a completion notification and process exit arrive together, their handling order can also produce inconsistent results: a completed turn may be missed, or a process failure may be reported as success.

Solution

  • Require the TUI completion notification before reporting a completed turn.
  • Report missing completion notifications, timeouts, interruptions and process failures as unsuccessful attempts, with a nonzero CLI exit status.
  • Handle notifications arriving around process exit consistently, while allowing intentional TUI shutdown after completion.
  • Show turn completion separately from quota-window activation in CLI output and background history. A completed turn does not by itself confirm that a quota window has started.

Claude behavior and quota scheduling/retry rules are unchanged.

Checks

  • gofmt -l . prints nothing
  • go build ./...
  • go vet ./...
  • go test ./... (also tested with -race)

Safety

  • I did not include credentials, raw usage responses, or private account metadata
  • I updated README/config examples for user-facing behavior changes
  • I considered whether this change can unexpectedly consume provider quota

Codex 0.153.2 emits an OSC 9 notification when a turn completes
(agent-turn-complete). Previously, triggerCodex sent Ctrl-C as early as
4 seconds simply because the initial TUI screen rendering went quiet,
terminating the process before Codex finished session initialization and
submitted the prompt.

By passing:
  -c tui.notifications=["agent-turn-complete"]
  -c tui.notification_method="osc9"
  -c tui.notification_condition="always"

we can deterministically detect turn completion even in a focused PTY
environment.

In addition:
- Fallback TERM to xterm-256color if unset or dumb, preventing TUI
  launch failures under cron or non-interactive daemon environments.
- Maintain the 45s timeout fallback as a safety net.
- Add regression test using mock codex script without external quotas.
- Document the notification flags and updated output in README.
In Codex 0.153.2, selecting gpt-5.4-mini displays an interactive model
migration dialog on startup, preventing automated turns from starting
when relying on the default model without explicit configuration.

Update the default Codex model from gpt-5.4-mini to gpt-5.6-luna in the
built-in config defaults, template TOML, documentation, and tests.
# Conflicts:
#	README.md
#	README.zh-CN.md
# Conflicts:
#	README.md
#	README.zh-CN.md
#	docs/window-verification.md
# Conflicts:
#	README.md
#	README.zh-CN.md
# Conflicts:
#	.github/workflows/ci.yml
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