Skip to content

Pass sessionId to embedded subscription and adjust subagent steer-restart handling#192

Merged
dgarson merged 1 commit intodgarson/hooks-add-run-and-model-callsfrom
codex/critically-review-pr-diff-for-issues
Mar 1, 2026
Merged

Pass sessionId to embedded subscription and adjust subagent steer-restart handling#192
dgarson merged 1 commit intodgarson/hooks-add-run-and-model-callsfrom
codex/critically-review-pr-diff-for-issues

Conversation

@dgarson
Copy link
Owner

@dgarson dgarson commented Mar 1, 2026

Motivation

  • Ensure the embedded PI session subscriber receives an explicit sessionId field so callers can rely on a dedicated identifier rather than inferring it from sessionKey.
  • Prevent an exception when result is undefined by guarding access to result.block and correct the subagent steer-restart bookkeeping so a steer restart does not mark the run as completed.

Description

  • Added sessionId?: string to the SubscribeEmbeddedPiSessionParams type so the subscriber API accepts an explicit session identifier.
  • Passed sessionId: params.sessionId into the call to subscribeEmbeddedPiSession in runEmbeddedAttempt so the subscriber receives the new field.
  • Changed the check in completeSubagentRun to use optional chaining (result?.block) to avoid errors when result is undefined.
  • When performing a steer-restart, stopped setting entry.outcome to { status: "ok", value: "steered" } and instead clear entry.outcome by assigning undefined so the run is not treated as completed during restarts.

Testing

  • Ran the TypeScript typecheck with tsc and the build succeeded.
  • Executed the test suite with npm test and all unit tests passed.
  • Ran linting with npm run lint and no lint errors were reported.

Codex Task

@dgarson dgarson merged commit cbffbd6 into dgarson/hooks-add-run-and-model-calls Mar 1, 2026
2 of 10 checks passed
Copy link

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

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: f06edaf87e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

status: "ok",
value: "steered",
};
entry.outcome = undefined;

Choose a reason for hiding this comment

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

P1 Badge Keep a completion sentinel when steering restarts

Setting entry.outcome to undefined removes the only guard used by the lifecycle error grace timer callback (entry.outcome?.status === "ok" in schedulePendingLifecycleError) to ignore stale queued error callbacks. If a transient error timer callback is already queued when subagent_stopping blocks and triggers a steer-restart, that callback can now proceed and call completeSubagentRun with an error outcome, incorrectly finalizing/announcing a run that was intentionally being restarted.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant