Skip to content

Proposal: background subagents, monitors, cron, worktree isolation #49842

Description

@KapilSareen

Hi team, I built a set of agent-orchestration features in my fork for my own work. Sharing in case it helps someone. Happy to split into PRs if anything looks interesting upstream, no pressure either way.

Fork (branch better): https://github.com/KapilSareen/opencode-extended

I checked each item against current upstream dev before posting; none of these exist there (upstream still injects background results via a fresh prompt(), has no background/monitor/sleep/cron/notify_parent tools, no per-agent isolation flag, bare cancel on abort, and hides completed tool blocks including diffs).

What is in it:

  • Non-blocking background subagents: completion notices are written durably and picked up mid-drain instead of going through a fresh prompt() (fixes model-reset, cache-bust and parked-injection races), plus a timeout that upgrades stuck foreground tasks to background instead of hanging the parent.
  • background tool (status with spend/tokens/recent activity, send, kill, list, tail, detach, by task_id or spawn name) and notify_parent so running children can push milestones to their parent.
  • monitor tool/service: watch a process, stream matching lines into a session, process-group kill. Plus cron scheduling and sleep keep-alive with early wake on new input.
  • Per-agent automatic worktree isolation (default on, falls back outside git): subagents run in detached linked worktrees, removed when clean. (Upstream worktrees exist as a manual feature; this adds the per-agent flag and lifecycle.)
  • ESC drains queued input instead of stranding it (programmatic aborts/kills still stay dead).
  • Completed diffs stay visible in the TUI when tool details are hidden.

Everything is in separated commits with integration tests. Let me know if any of it would help upstream and how you would like it shaped. Thanks for opencode!

Activity

  1. rndmcnlly commented on Sep 23, 2026

    @rndmcnlly

    The monitor part is the one I would use immediately. I built opencode-perk for V1 because I wanted a running job to send progress back to an idle agent, without blocking the conversation or waiting for the job to finish. A CI watcher, for example, should be able to report a failing step while the run is still going, and I should still be able to talk to the agent in the same session. Claude Code’s Monitor tool captures the workflow well.

    V2 already owns background shell jobs, so I’d rather see progress events attached to those jobs than another job runner. Perk used an append-only drip stream with quiet-gap coalescing; stdout lines might be simpler here. I’m likely to prototype a V2 monitor plugin in the meantime to learn what works. The earlier #33806 looks like useful prior art.

  2. KapilSareen commented on Sep 26, 2026

    @KapilSareen
    Author

    I kinda needed the background tasks without waiting on V2, so thought about sharing here so somebody could benefit if they're looking for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions