Promote background codex exec runs into subagent rows - #158
Merged
Conversation
A Claude thread that launches `codex exec …` as a background Bash command is running a second agent, but the SDK only reports it as a `local_bash` task, so the agents panel showed a bare run row: no model, no effort, no transcript, nothing to click into. The Claude adapter now recognises a `codex exec` invocation from the originating Bash tool call and emits the same `subagent.metadata.updated` events the Codex adapter emits for native subagents. The row appears on the task's start edge with the role, the task description as its goal, and any `-m` / `-c model_reasoning_effort=` the command stated. A scoped poll then correlates the run with the rollout JSONL codex writes under `$CODEX_HOME/sessions/`, matching on the exec originator and a realpath-equal cwd, and upgrades the row with the transcript id, the resolved model and the effort from the file's first `turn_context`. The task's completion settles the row, with codex's own final message as the result. `readSubagentTranscript` serves those rollouts for `codex-exec:<uuid>` ids, resolving from the id alone so a transcript still opens after a restart. Web-side, a task whose tool call the thread already tracks as a subagent is kept off the run list, and the run it would have been is handed to the matching agent row so the row keeps the same stop arm the run row had. New payload keys on `SubagentMetadataUpdatedPayload` (status, transcriptAgentId, resolvedModel, resultBody, resultCreatedAt) were already read by the subagent projection; they are now declared so emitters can set them.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a Claude thread launches
codex execas a background Bash command, it is a second agent, but the agents panel showed it as a bare background-run row: no model, no reasoning effort, nothing to click into. This promotes it to the same rich subagent row that native codex subagents get.How it works
task_startededge for alocal_bashbackground task, the originating Bash command is matched against a strict, quote-awarecodex execmatcher (Drivers/CodexExecRollouts.ts). Commands that merely mention codex exec (echoed strings, other programs' arguments) never match; a false positive would demote real shell runs, so the matcher is biased toward false negatives.npx codex execis deliberately unmatched for now.subagent.metadata.updatedevent (keyed by the spawning tool call id), so it appears the moment the task starts. Explicit-m/--modeland-c model_reasoning_effort=…flags seed provisional model/effort.$CODEX_HOME/sessions/, confirmed by originator, realpath-equal cwd, and the recorded session start time. Mtime alone is not enough: a still-running older rollout keeps a fresh mtime and would steal the match, so candidates that began before the task did are rejected. Once found, the row gains the codex session identity plus the authoritative model and effort fromturn_context.codex-exec:<session-uuid>agent ids. The Claude adapter's transcript route resolves the rollout from the id alone (so it survives server restarts) and maps it into the standard transcript entries: prompt, reasoning, tool calls with output previews, final message.promotedSubagentRunsmap; the matching subagent row borrows the run's stop arm while live, wired through the existingstopBackgroundRunpath. Model/effort meta, history, receipts, and transcript drill-in all ride the existing subagent surfaces.Every codex-exec path is guarded so any failure degrades to today's behavior (a plain run row) rather than disturbing task handling.
Testing
vp fmt,vp lint,vp run typecheckNot yet exercised live end-to-end against a real
codex execrun from a real thread; that is the next step after merge-readiness review.