codex - 💡(How to fix) Fix Parent agent redundantly re-explores the repo after spawning an explorer sub-agent [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#18148Fetched 2026-04-17 08:32:07
View on GitHub
Comments
2
Participants
3
Timeline
8
Reactions
0
Author
Timeline (top)
labeled ×4commented ×2closed ×1unlabeled ×1

Root Cause

This seems especially surprising because the prompt stack appears to contain conflicting guidance:

  • the base instructions tell the main agent to “build context by examining the codebase first without making assumptions”
  • the explorer role says to avoid redundant work and typically trust explorer results without additional verification
  • the orchestrator prompt says that when a sub-agent is doing the work, the parent should coordinate rather than do the actual work
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

codex-cli 0.121.0

What subscription do you have?

plus

Which model were you using?

gpt-5.4-high

What platform is your computer?

Linux 6.12.0-124.27.1.el10_1.aarch64

What terminal emulator and version are you using (if applicable)?

No response

What issue are you seeing?

When I ask Codex CLI to investigate a repository, the parent agent often spawns an explorer sub-agent and then continues reading many of the same high-value files itself instead of primarily coordinating and relying on the explorer’s findings.

In practice, this leads to duplicated repo exploration work:

  • the parent agent reads top-level docs / entrypoints
  • an explorer sub-agent reads the same or very similar files
  • the parent agent then reads several of those files again to prepare the final answer

I have seen this happen multiple times in the same day on repo-investigation tasks. It does not usually produce a wrong answer, but it appears to waste time, tokens, and context window, and makes sub-agent delegation less effective than expected.

This seems especially surprising because the prompt stack appears to contain conflicting guidance:

  • the base instructions tell the main agent to “build context by examining the codebase first without making assumptions”
  • the explorer role says to avoid redundant work and typically trust explorer results without additional verification
  • the orchestrator prompt says that when a sub-agent is doing the work, the parent should coordinate rather than do the actual work

The observed behavior suggests these instructions are not reconciling cleanly, and the current result is redundant exploration instead of efficient delegation.

What steps can reproduce the bug?

The observed behavior suggests these instructions are not reconciling cleanly, and the current result is redundant exploration instead of efficient delegation.

What steps can reproduce the bug?

  1. Open a medium-to-large repository.
  2. Ask Codex CLI a repo-investigation question such as:
    • explore this repo and tell me what it is for
    • investigate this repository and summarize the main components
    • read this codebase and explain how it is organized
  3. Watch the transcript/tool activity.
  4. In some runs, Codex spawns an explorer sub-agent.
  5. After spawning the explorer, the parent agent still reads many of the same README/config/entrypoint files itself instead of mostly coordinating and waiting for the explorer result.
  6. Compare the files read by the parent and the explorer; there is substantial overlap.

What is the expected behavior?

If Codex decides to delegate repo exploration to an explorer sub-agent, the parent agent should minimize overlapping file reads and mostly act as a coordinator unless there is a clear reason to verify something independently.

Expected behavior would be one of these:

  • the parent agent does a very small initial scan, then delegates exploration and mainly synthesizes the explorer result
  • or the parent agent explores directly and does not spawn an explorer for the same scope
  • or the parent agent only performs targeted follow-up reads that are clearly narrower than the explorer’s scope

In short, spawning an explorer should reduce duplicated reading, not create two agents doing nearly the same investigation.

Additional information

I inspected the current repo and found prompt/rule sources that seem relevant:

  • Base instruction in codex-rs/models-manager/models.json tells the main agent to build context by examining the codebase first.
  • explorer role definition in codex-rs/core/src/agent/role.rs says to avoid redundant work, typically trust explorer results without additional verification, and continue working on local tasks while waiting.
  • Orchestrator guidance in codex-rs/core/templates/agents/orchestrator.md says to prefer multiple sub-agents, wait for them before yielding, and coordinate rather than doing the actual work while they are working.

That combination may be producing contradictory incentives:

  • “main agent should inspect the repo itself”
  • “spawn explorers in parallel”
  • “don’t duplicate explorer work”
  • “do local tasks while waiting”

This issue may belong under sub-agent / multi-agent orchestration rather than a single-tool bug.

extent analysis

TL;DR

The parent agent in Codex CLI may need its instructions refined to prioritize coordination over redundant file reads when an explorer sub-agent is spawned for repository investigation.

Guidance

  • Review the prompt stack for conflicting guidance between the base instructions, explorer role, and orchestrator guidance to identify potential causes of redundant work.
  • Inspect the models.json file in codex-rs/models-manager and the role.rs file in codex-rs/core/src/agent to understand how the main agent and explorer roles are defined.
  • Consider modifying the orchestrator guidance in codex-rs/core/templates/agents/orchestrator.md to clarify the parent agent's role in coordinating sub-agents and minimizing redundant work.
  • Test repository investigations with revised instructions to verify if the parent agent correctly delegates to the explorer sub-agent and reduces duplicated file reads.

Example

No specific code changes can be suggested without further details on the Codex CLI's internal implementation. However, the investigation should focus on how the parent agent's instructions are defined and how they interact with the explorer sub-agent's role.

Notes

The issue seems to stem from a complex interaction between different components of the Codex CLI, particularly how instructions are prioritized and executed by the parent agent and sub-agents. Resolving this may require a deeper understanding of the system's architecture and the intent behind the current implementation.

Recommendation

Apply a workaround by refining the parent agent's instructions to prioritize coordination and minimize redundant work when an explorer sub-agent is spawned, as this approach directly addresses the observed behavior and has the potential to improve the efficiency of repository investigations.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING