Skip to content

Include the subagent session ID in foreground completion text - #847

Open
uvforce wants to merge 1 commit into
agegr:mainfrom
uvforce:pr/subagent-session-id
Open

uvforce wants to merge 1 commit into
agegr:mainfrom
uvforce:pr/subagent-session-id

Conversation

@uvforce

@uvforce uvforce commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Problem

The Agent tool exposes resume ("Existing subagent session ID to continue instead of creating a new session") and get_subagent_result(agent_id), both keyed by the subagent session ID. But when a foreground subagent completes, the tool result text is only the subagent's report; the session ID is present only in details, which the model never sees. Background runs already include Session ID: … in their text, and every other status branch (running, aborted, interrupted, failed) includes the ID too.

In practice this makes resume unreachable for foreground runs. Observed with a builder profile that has max_turns: it hit the limit and handed back a partial report, the parent model tried to resume as instructed, guessed three wrong IDs (Subagent not found), and had to start a fresh session and redo the work.

Change

subagentFinalText now prefixes the completed text with Subagent <id> completed. (and Subagent <id> completed without text output. when the run produced no text), matching the format of the other status branches. The report body is unchanged. details is untouched.

This also applies to the background completion notification delivered via notifyParent, so both paths now consistently carry the ID.

Verification

  • lib/subagent-extension.test.mjs: foreground completion, get_subagent_result (with and without text), and resume now assert the ID-prefixed text.
  • lib/subagent-runtime.test.mjs: background completion notification asserts the ID-prefixed text.
  • npm test (38 in the touched suites; full suite 1094 on the fork branch), tsc --noEmit clean.

The Agent tool exposes `resume` and `get_subagent_result`, both keyed by the
subagent session ID, but a foreground run that completes returns only the
subagent's report text; the ID is only in `details`, which the model never
sees. Background runs already put the ID in text. Prefix the completed text
with `Subagent <id> completed.` so the model can pass it back, matching the
other status branches.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-14T04:21:09.214107Z 088ad9a PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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