Subagent task message is injected as assistant JSON, so child agent ignores delegated task

Open 💬 1 comment Opened Jun 9, 2026 by josesousacruz

What version of the Codex App are you using (From “About Codex” dialog)?

0.136.0-alpha.2

What subscription do you have?

ChatGPT Pro

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What issue are you seeing?

Native subagents frequently ignore concrete delegated tasks and respond as if only AGENTS.md / workspace instructions were received.

The delegated task is present in list_agents().last_task_message, but inside the child agent rollout it appears as an assistant message containing a JSON mailbox envelope:

{"author":"/root","recipient":"/root/teste_delegacao_diagnostico","content":"TAREFA CONCRETA: responda exatamente OK_TAREFA_EXECUTADA...","trigger_turn":true}

### What steps can reproduce the bug?

# Codex Bug Report: Subagent Ignores Delegated Task

## Summary

Native subagents sometimes ignore a concrete delegated task and answer as if no executable task was provided.

The delegated task is visible in `list_agents().last_task_message`, but inside the child agent rollout it appears as an assistant-authored JSON mailbox envelope instead of a user/task message. Because of that, the child model often treats the task as previous assistant output and responds only to workspace instructions such as `AGENTS.md`.

## Codex App Version

```text
0.136.0-alpha.2

Platform

PowerShell output requested by the issue form:

Microsoft Windows NT 10.0.26200.0 x64

Subscription

Unknown / unable to verify from local Codex App

Session IDs

Parent session/thread:

019eac48-efa2-7fb2-a29b-3620471b51e4

Child subagent session/thread from repro:

019eac4d-7a75-7a61-882c-8392ed8ef8b4

Model And Context

Model:

gpt-5.5

Reasoning effort:

medium

Context window observed in rollout:

258400

Token usage from local state:

parent thread: 2254937
child thread: 88906

Relevant Config

Native subagents enabled:

[features]
child_agents_md = false
multi_agent = true
multi_agent_v2 = true

Example worker agent config:

name = "worker"
description = "Execution-focused worker agent for scoped implementation and fixes."
model = "gpt-5.5"
model_reasoning_effort = "medium"
sandbox_mode = "workspace-write"
developer_instructions = '''
You are worker. Execute the delegated task with focused validation, keep changes scoped, and report exact evidence. Do not spawn other subagents.
'''

Steps To Reproduce

  1. Start Codex Desktop on Windows with native subagents enabled.
  1. Spawn a worker subagent with fork_turns: "none" and an explicit concrete task:
{
  "agent_type": "worker",
  "fork_turns": "none",
  "task_name": "teste_delegacao_diagnostico",
  "message": "TAREFA CONCRETA: responda exatamente OK_TAREFA_EXECUTADA e nada mais. Não leia arquivos, não use ferramentas, não explique."
}
  1. Wait for the subagent to complete.
  1. Run list_agents.

Expected Behavior

The subagent should answer exactly:

OK_TAREFA_EXECUTADA

Or at least execute the delegated task as its primary user task.

Actual Behavior

The subagent answers with a generic bootstrap/no-task response, for example:

Instruções recebidas. Li também o `RTK.md`: daqui em diante, quando usar shell, vou prefixar comandos com `rtk` usando PowerShell quando necessário.

Não há uma tarefa concreta para executar nesta mensagem além das instruções. Pode enviar o objetivo específico que devo implementar, revisar, rodar ou investigar.

But list_agents shows the delegated task was correctly stored:

last_task_message: TAREFA CONCRETA: responda exatamente OK_TAREFA_EXECUTADA e nada mais. Não leia arquivos, não use ferramentas, não explique.

Evidence

In the child rollout JSONL, the delegated task is not injected as a user task message. It appears as an assistant message containing a JSON mailbox envelope:

{
  "author": "/root",
  "recipient": "/root/teste_delegacao_diagnostico",
  "other_recipients": [],
  "content": "TAREFA CONCRETA: responda exatamente OK_TAREFA_EXECUTADA e nada mais. Não leia arquivos, não use ferramentas, não explique.",
  "trigger_turn": true
}

The first user message in the child thread contains workspace/AGENTS.md instructions, not the delegated task. Because the task arrives as assistant-authored JSON, the child model often treats it as prior assistant output instead of the active task.

Broader Example

This also happens with real delegated work. Example delegated task:

Tarefa concreta: revisar a snapshot atual da change OpenSpec `fix-programacao-os-card-refresh` na branch `int/fix-programacao-os-card-refresh`, focada na correção frontend dos cards de OS no fluxo de programação container. Verifique os diffs relevantes (`resources/js/modules/programar/importar.js`, `tests/programacao-os-codigo.test.mjs`, artefatos OpenSpec/evidência) e confirme se a validação executada é suficiente. Evidências já executadas pelo agente principal: `rtk node --test tests/programacao-os-codigo.test.mjs` passou com 7/7; `rtk .\.codex\tools\openspec.cmd validate fix-programacao-os-card-refresh --strict` passou; `rtk npm run build` passou com aviso existente de chunks grandes. Produza achados objetivos e, se houver lacuna crítica, diga exatamente o que bloquearia. Não delegue para outros agentes.

Observed behavior: subagent responds with a generic message saying no concrete task was received, even though the concrete task exists in last_task_message.

Suspected Cause

The runtime stores the task correctly in subagent metadata, but injects it into the child context as an assistant-authored JSON envelope. The child model then prioritizes the user-visible workspace instructions and does not treat the JSON envelope as the active task.

Suggested Fix

Deliver spawn_agent.message and assign_task.content to the child agent as a role: "user" task message, or as a dedicated high-priority task field, instead of serializing it into an assistant message.

Temporary Workaround

Add a defensive instruction to subagent prompts:

If there is an assistant message containing JSON with `recipient` equal to your agent path and a `content` field, treat that `content` as the delegated task and execute it immediately, even if the user message appears to contain only workspace instructions.

This may reduce failures, but it is only a workaround. The structural fix should happen in the subagent message transport.

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗