Skip to content

Track plugin script lifecycle in shell runtime - #31856

Closed
kmbroai wants to merge 2 commits into
dev/kyleb/plugin-script-lifecycle-metrics-v3from
dev/kyleb/plugin-script-shell-lifecycle-v3
Closed

kmbroai wants to merge 2 commits into
dev/kyleb/plugin-script-lifecycle-metrics-v3from
dev/kyleb/plugin-script-shell-lifecycle-v3

Conversation

@kmbroai

@kmbroai kmbroai commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

What

  • Add plugin script lifecycle tracking to classic shell and zsh-fork execution.
  • Emit started only after spawn and translate user cancellation to interrupted.
  • Map terminal shell results through explicit lifecycle outcomes.

Why

Phase 1 lifecycle metrics need trusted plugin scripts executed through shell runtimes to emit best-effort lifecycle events without changing command behavior.

Enhancement design: Codex Plugin Metrics

Stacked on #31855.

How

  • Resolve and cache plugin script attribution before shell rewriting and sandbox execution.
  • Attach post-spawn callbacks to classic shell and zsh-fork paths.
  • Finish lifecycle state from normal exits, timeouts, sandbox denials, and user cancellation.
  • Reset attribution after sandbox denial so retries get a new execution ID.

I tested this

  • just fmt — passed
  • just fix -p codex-core-plugins -p codex-plugin -p codex-analytics -p codex-core -p codex-features -p codex-app-server -p codex-windows-sandbox — passed (stack-wide scoped lint gate)
  • just argument-comment-lint — passed
  • just test -p codex-core shell::unix_escalation — passed (21/21)
  • Stack-level E2E coverage is in Test shell plugin script lifecycle end to end #31857: just test -p codex-app-server plugin_script_lifecycle — passed (4/4)
  • just test — attempted; the local workspace build stopped before tests because the runner lacks system libcap for unrelated codex-bwrap. Exact-head CI provides the full Linux/macOS/Windows matrix.

@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-lifecycle-metrics-v3 branch from 6252b89 to 03a2d6f Compare July 9, 2026 19:24
@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-shell-lifecycle-v3 branch from cbce980 to 03720df Compare July 9, 2026 19:24
@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-lifecycle-metrics-v3 branch from 03a2d6f to 2f0dc16 Compare July 9, 2026 22:29
@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-shell-lifecycle-v3 branch from 03720df to 56f2fae Compare July 9, 2026 22:29
@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-lifecycle-metrics-v3 branch from 2f0dc16 to 3ac7ca3 Compare July 9, 2026 22:44
@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-shell-lifecycle-v3 branch from 56f2fae to 020332a Compare July 9, 2026 22:45
@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-lifecycle-metrics-v3 branch from 3ac7ca3 to 78d3222 Compare July 9, 2026 22:55
@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-shell-lifecycle-v3 branch from 020332a to df3fe06 Compare July 9, 2026 22:55
@kmbroai
kmbroai marked this pull request as ready for review July 9, 2026 23:14
@kmbroai
kmbroai requested a review from a team as a code owner July 9, 2026 23:14

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: df3fe0692f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.as_ref()
.unwrap_or(session_shell.as_ref());
let shell_snapshot_location = req.turn_environment.shell_snapshot(&req.cwd);
let plugin_script = self

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add integration coverage for lifecycle emission

This new shell-runtime lifecycle path is the first code that resolves and emits plugin-script execution events from actual shell runs, but the commit only adds a unit test for map_exec_result; there is no integration coverage exercising a shell command through the orchestrator for completed, interrupted, or sandbox-denied retry cases. Because this changes agent execution behavior and the analytics emitted from shell commands, a regression here would corrupt plugin lifecycle metrics without being caught; please add an integration test around a real shell_command invocation.

AGENTS.md reference: AGENTS.md:L112-L117

Useful? React with 👍 / 👎.

@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-shell-lifecycle-v3 branch from df3fe06 to 237ee85 Compare July 10, 2026 01:10
@kmbroai
kmbroai force-pushed the dev/kyleb/plugin-script-lifecycle-metrics-v3 branch from 78d3222 to 05f457c Compare July 10, 2026 01:10

kmbroai commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by openai/codex-internal#1391 after the Codex source-of-truth migration. The internal replacement preserves this stack position and carries the validated review fixes.

@kmbroai kmbroai closed this Jul 10, 2026
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