Skip to content

[Feature]: Prevent main-session explore/librarian launches alongside plan #4589

@ririnto

Description

@ririnto

Prerequisites

  • I will write this issue in English (see our Language Policy)
  • I have searched existing issues and discussions to avoid duplicates
  • This feature request is specific to oh-my-opencode (not OpenCode core)
  • I have read the documentation or asked an AI coding agent with this project's GitHub URL loaded and couldn't find the answer

Problem Description

search-mode and analyze-mode can instruct the main orchestrator to launch explore and librarian background agents in parallel.

For example, search-mode says:

MAXIMIZE SEARCH EFFORT. Launch multiple background agents IN PARALLEL:
- explore agents (codebase patterns, file structures, ast-grep)
- librarian agents (remote repos, official docs, GitHub examples)

analyze-mode has a similar context-gathering instruction:

CONTEXT GATHERING (parallel):
- 1-2 explore agents (codebase patterns, implementations)
- 1-2 librarian agents (if external library involved)

That is useful when the main orchestrator is doing research directly. However, when the same user request also triggers plan, the parent-level research calls can become redundant.

The plan subagent already receives explicit startup instructions to gather context by calling call_omo_agent for explore and librarian.

The plan-agent prepend currently includes a mandatory context-gathering protocol equivalent to:

Launch background agents to gather context:
- call_omo_agent(..., subagent_type="explore", run_in_background=true, ...)
- call_omo_agent(..., subagent_type="librarian", run_in_background=true, ...)

So a single main-session request can produce a mixed wave like:

main Sisyphus
  -> task(subagent_type="explore", run_in_background=true)
  -> task(subagent_type="librarian", run_in_background=true)
  -> task(subagent_type="plan", run_in_background=false)

Then the plan session may start and perform its own context gathering:

plan
  -> call_omo_agent(subagent_type="explore", run_in_background=true)
  -> call_omo_agent(subagent_type="librarian", run_in_background=true)

This is related to #2124, but the request here is not just to improve prompt-following. It is to add a runtime guardrail that prevents redundant parent-level research subagents from being launched alongside plan.

Proposed Solution

Add a runtime guardrail for main-session subagent delegation when plan is part of the same delegation wave.

Recommended behavior:

If the main session attempts to launch `plan` together with `explore` or `librarian`,
fail the main-session `explore` / `librarian` launches and allow `plan` to run.

The rationale is that plan already has explicit instructions to call call_omo_agent for explore and librarian when it needs context. Letting the main session launch those same research agents in parallel can duplicate the same work.

Suggested blocking message:

Blocked: `explore` / `librarian` should not be launched in parallel with `plan` from the main session.
The `plan` subagent already gathers context via `call_omo_agent`; let `plan` run first and use its own context-gathering path.

The guard should be scoped narrowly:

  • Apply only to main-session launches.
  • Apply when plan is being launched in the same parent delegation wave.
  • Prefer failing explore / librarian launched alongside plan, not failing plan.
  • Do not block plan from calling call_omo_agent internally.
  • Do not block normal explore / librarian usage when plan is not part of the same wave.

Alternatives Considered

  1. Strengthen prompts only

This was effectively the situation in #2124. It depends on model compliance and can regress across models or prompt combinations.

  1. Fail plan when research subagents are already active

This avoids duplication, but it pushes the agent back toward the same prompt-following problem. Since plan has its own context-gathering instructions, allowing plan and failing the redundant main-session research calls seems more deterministic.

  1. Disable plan's own context gathering

This targets a different layer. The plan prompt explicitly tells plan to gather context via call_omo_agent, so the cleaner guardrail is to avoid launching duplicate research subagents from the parent main session.

  1. Block explore / librarian globally from main sessions

Too broad. explore and librarian are useful when plan is not involved. The issue is only the mixed wave with plan.

Doctor Output (Optional)

Not available. This feature request is based on source inspection and prior issue #2124.

Additional Context

Related issue:

Relevant source paths:

  • packages/prompts-core/prompts/mode/search.md
  • packages/prompts-core/prompts/mode/analyze.md
  • src/tools/delegate-task/constants.ts
  • src/agents/dynamic-agent-core-sections.ts

Feature Type

New Hook

Contribution

  • I'm willing to submit a PR for this feature
  • I can help with testing
  • I can help with documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions