Skip to content

Lifecycle: distinguish model steps from user turns - #183

Merged
oratis merged 6 commits into
mainfrom
codex/lifecycle-events
Aug 2, 2026
Merged

Lifecycle: distinguish model steps from user turns#183
oratis merged 6 commits into
mainfrom
codex/lifecycle-events

Conversation

@oratis

@oratis oratis commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • add an explicit model_step_complete event for each provider round-trip
  • emit turn_complete exactly once for each runAgent terminal state
  • include the terminal stop reason and optional final assistant message
  • route abort, provider error, end-turn, approval abort, and max-turn exits through one completion path
  • keep CLI renderers intentionally silent for both lifecycle bookkeeping events

Validation

  • pnpm docs:check
  • pnpm lint (3 pre-existing warnings, 0 errors)
  • pnpm format:check
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • cargo check --manifest-path apps/desktop/src-tauri/Cargo.toml
  • cargo test --manifest-path apps/desktop/src-tauri/Cargo.toml (31 passed)

Stack

Depends on #182, #181, and #180. This is the lifecycle-invariant slice of PR 3; protocol extraction and record/replay remain follow-ups.

@oratis
oratis changed the base branch from codex/session-compat to main August 2, 2026 06:36
@oratis
oratis marked this pull request as ready for review August 2, 2026 06:37
@oratis

oratis commented Aug 2, 2026

Copy link
Copy Markdown
Owner Author

Review: approved ✅

Small (+31/-17) but it fixes a real semantic conflation: there was no way for a client to tell "the model finished one round-trip" from "the user's turn is over". Anything driving UI state off the old signal was guessing.

What I checked

  • turn_complete is emitted exactly once per runAgent terminal state, with all five exits (abort, provider error, end-turn, approval abort, max-turns) funnelled through one completion path. That single-exit discipline is what makes the once-only guarantee actually hold rather than being a comment — worth preserving in future edits to the loop.
  • Carrying the terminal stop reason plus the optional final assistant message on the event means clients don't have to reconstruct why a turn ended from event archaeology.
  • CLI renderers stay intentionally silent for both events. Correct — these are bookkeeping for programmatic clients, and the terminal already renders completion its own way.

This is the event contract the app-server (#188) and every thin client downstream depend on, so landing it as its own reviewable slice ahead of them is the right ordering.

Validation: CI green; full suite green locally at the stack tip.

@oratis
oratis merged commit af9580e into main Aug 2, 2026
4 checks passed
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