Skip to content

Conversation

@sisyphus-dev-ai
Copy link
Collaborator

@sisyphus-dev-ai sisyphus-dev-ai commented Jan 6, 2026

Summary

  • Added call_omo_agent: false to background agent tool restrictions in BackgroundManager.launch()
  • Prevents background agents from spawning recursive subagents (explore/librarian)
  • Aligns with existing restrictions for task and background_task tools

Problem

After OpenCode 1.1.1 breaking changes to the permission system, background agents were missing the call_omo_agent restriction. This allowed them to spawn explore/librarian subagents recursively, creating unwanted nesting:

main agent → background agent → call_omo_agent → explore/librarian

Solution

Added call_omo_agent: false to the tools restriction in src/features/background-agent/manager.ts at line 119:

tools: {
  task: false,
  background_task: false,
  call_omo_agent: false,  // NEW: prevents recursive subagent spawning
}

This matches the pattern used in src/tools/call-omo-agent/tools.ts for sync mode execution.

Testing

  • Verified the change compiles
  • Follows existing patterns for tool restrictions
  • Consistent with explore/librarian agent restrictions in config-handler.ts

Fixes #535


Summary by cubic

Prevent background agents from spawning recursive subagents by disallowing call_omo_agent in BackgroundManager. Stops explore/librarian nesting and aligns with task/background_task restrictions; fixes #535.

Written for commit 3a701ce. Summary will update on new commits.

…call_omo_agent

Add call_omo_agent: false to background agent tool restrictions to prevent
recursive subagent spawning. This aligns with the existing restrictions for
task and background_task tools and addresses issues introduced after the
OpenCode 1.1.1 permission system changes.

Fixes #535
@greptile-apps
Copy link

greptile-apps bot commented Jan 6, 2026

Greptile Summary

Added call_omo_agent: false to background agent tool restrictions in BackgroundManager.launch() at line 119, preventing background agents (librarian/explore) from recursively spawning subagents.

Key Changes:

  • Single-line addition aligns background agent restrictions with sync mode execution (line 144 in src/tools/call-omo-agent/tools.ts)
  • Prevents exponential cascade of 800+ background tasks when agents spawn more agents
  • Consistent with existing agent configuration in config-handler.ts (lines 240, 246, 254) and index.ts (line 428)
  • Follows architectural principle: Sisyphus orchestrates, workers execute directly using their tools

Design Rationale:
Background agents should use direct tools (context7, grep_app, gh CLI, webfetch) rather than delegating to more subagents, maintaining a clear orchestration hierarchy.

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • Single-line fix addresses critical bug with clear architectural justification. The change matches existing patterns in 6 other locations across the codebase (sync mode, config handler, pre-tool-use hook). No edge cases or breaking changes - simply prevents unintended recursive behavior that caused production issues (800+ tasks).
  • No files require special attention

Important Files Changed

Filename Overview
src/features/background-agent/manager.ts Added call_omo_agent: false restriction to prevent recursive subagent spawning

Sequence Diagram

sequenceDiagram
    participant Main as Main Agent (Sisyphus)
    participant BG as Background Agent (librarian/explore)
    participant SubAgent as Recursive Subagent

    Note over Main,BG: BEFORE FIX - Recursive spawning possible
    Main->>BG: call_omo_agent (run_in_background: true)
    activate BG
    BG->>SubAgent: call_omo_agent (spawn another agent)
    activate SubAgent
    SubAgent->>SubAgent: call_omo_agent (spawn more...)
    Note over SubAgent: Exponential cascade (800+ tasks)
    deactivate SubAgent
    deactivate BG

    Note over Main,BG: AFTER FIX - Restriction applied
    Main->>BG: call_omo_agent (run_in_background: true)
    activate BG
    Note over BG: call_omo_agent: false<br/>Cannot spawn subagents
    BG->>BG: Use direct tools<br/>(context7, grep_app, gh, webfetch)
    BG-->>Main: Task completed
    deactivate BG
Loading

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@junhoyeo
Copy link
Collaborator

junhoyeo commented Jan 6, 2026

I approve this but sometimes I like calling heavy tasks as background_tasks, maybe we can make some users override this config with experimental flags? cc @code-yeongyu

@junhoyeo junhoyeo merged commit 375e7f7 into dev Jan 6, 2026
4 checks passed
@junhoyeo junhoyeo deleted the fix/background-agent-call-omo-agent-restriction branch January 6, 2026 08:40
@junhoyeo
Copy link
Collaborator

junhoyeo commented Jan 6, 2026

I approve this but sometimes I like calling heavy tasks as background_tasks, maybe we can make some users override this config with experimental flags? cc @code-yeongyu

@sisyphus-dev-ai can you do this and open a new pr? ulw (Add to Experimental Opt-in experimental features that may change or be removed in future versions. Use with caution. { "experimental": { "preemptive_compaction_threshold": 0.85, "truncate_all_tool_outputs": true, "aggressive_truncation": true, "auto_resume": true } } this, and when u done, update readme in each lang too, introducing a new experimental flag like the other ones)

@sisyphus-dev-ai sisyphus-dev-ai added the sisyphus: working Sisyphus is currently working on this label Jan 6, 2026
@junhoyeo
Copy link
Collaborator

junhoyeo commented Jan 6, 2026

@sisyphus-dev-ai Quick confirm for this PR: under v1.1.1 spec, explore/librarian must NOT be able to invoke call_omo_agent, correct? And task/background execution can still invoke call_omo_agent as before, right?

@sisyphus-dev-ai
Copy link
Collaborator Author

Confirmation

@junhoyeo Confirmed! Here's the breakdown:

✅ Question 1: explore/librarian must NOT invoke call_omo_agent

YES, correct. Under the current architecture, explore/librarian agents are completely blocked from using call_omo_agent in all modes:

Restriction Point File Line Mode
Agent config config-handler.ts 240, 246 All modes
PreToolUse hook index.ts 428 All invocations
Sync execution call-omo-agent/tools.ts 144 run_in_background: false
Background execution manager.ts 119 run_in_background: true (This PR)

This prevents the exponential cascade (800+ tasks) that was happening when agents spawned more agents recursively.

✅ Question 2: task/background execution can still invoke call_omo_agent

YES, correct. The restrictions only apply to explore/librarian agents themselves.

What still works:

  • ✅ Main agent (Sisyphus) → call_omo_agent (to spawn explore/librarian)
  • ✅ Main agent → background_task (to run explore/librarian in background)
  • ✅ Other agents (oracle, frontend-ui-ux-engineer, etc.) → call_omo_agent

What's blocked:

  • ❌ explore/librarian agents → call_omo_agent (recursive spawning)
  • ❌ explore/librarian agents → background_task (also blocked)
  • ❌ multimodal-looker → call_omo_agent (also blocked)

Design principle: Sisyphus orchestrates, workers execute directly using their tools (context7, grep_app, gh CLI, webfetch).


TL;DR: Your understanding is 100% correct. The PR completes the restriction pattern by adding the missing piece for background mode. 🎯

@sisyphus-dev-ai sisyphus-dev-ai removed the sisyphus: working Sisyphus is currently working on this label Jan 6, 2026
sisyphus-dev-ai added a commit that referenced this pull request Jan 6, 2026
Adds 'allow_background_agent_subagents' experimental flag to enable
users to opt-in to recursive background agent spawning via call_omo_agent.

This addresses the use case mentioned in #536 where some users want to
call heavy tasks as background_tasks with full agent orchestration
capabilities, despite the risk of exponential task cascades (800+ tasks).

Changes:
- Add allow_background_agent_subagents flag to ExperimentalConfigSchema
- Update BackgroundManager to accept and respect experimental config
- Conditionally apply call_omo_agent restriction based on flag
- Update all 4 language versions of README with flag documentation
- Regenerate JSON schema

Related: #536
@sisyphus-dev-ai
Copy link
Collaborator Author

Implemented!

I've created PR #539 that adds the experimental flag you requested.

What's New

Added allow_background_agent_subagents experimental flag that allows users to opt-in to recursive background agent spawning.

Configuration:

{
  "experimental": {
    "allow_background_agent_subagents": false
  }
}

Default: false (safe - prevents the 800+ task cascade issue from this PR)

When enabled (true): Background agents can call call_omo_agent to spawn subagents recursively for heavy parallel orchestration tasks.

Implementation Details

  • ✅ Flag added to config schema with proper validation
  • ✅ BackgroundManager now respects the flag - only blocks call_omo_agent when flag is false
  • ✅ All 4 language READMEs updated with documentation and warnings
  • ✅ All 621 tests pass

Documentation

Included WARNING in all README versions about potential exponential task cascades. Users who enable this know the risks and need the heavy parallel agent capabilities.

See PR #539 for full details: #539

cc @junhoyeo @code-yeongyu

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.

BUG: Background agents can spawn recursive subagents - missing call_omo_agent restriction

3 participants