Skip to content

feat(extensions): delegate OpenCode commands to approved subagents - #1965

Merged
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/opencode-command-subagent-delegation
Aug 2, 2026
Merged

feat(extensions): delegate OpenCode commands to approved subagents#1965
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/opencode-command-subagent-delegation

Conversation

@limityan

@limityan limityan commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Why

OpenCode prompt commands can explicitly select a subagent, but BitFun previously only expanded those commands into the current agent. This change supports the verified OpenCode subtask behavior through BitFun's existing approved Subagent and Task lifecycle, without introducing another orchestration or plugin-runtime path.

Design

  • Add a provider-neutral prompt-command execution target and carry it through discovery, conflict resolution, guarded expansion, Desktop, CLI, and Agent Runtime ports.
  • Map only OpenCode commands with an explicit agent and subtask omitted or true to a fresh external-subagent target.
  • Resolve the exact same-ecosystem, same-workspace, approved active route and hold its generation lease for the child run.
  • Reuse the existing Scheduler, Coordinator, Registry, permission ceiling, cancellation, Task events, transcript persistence, and child-session relationship owners.
  • Persist a normal parent UserDialog plus Task call/result while the selected external subagent runs as a fresh single-use child.
  • Move generic Subagent Task completion formatting to a provider-neutral Agent Runtime owner shared by ordinary Task, this command path, and the DeepReview compatibility wrapper.
  • Bump the preview Rust Agent Runtime SDK to v3 because AgentDialogTurnRequest gains the execution field; existing struct literals migrate with execution set to Standard or Default.

Safety and scope

  • Delegation requires a local idle session with an empty queue; the Scheduler enforces this under the session operation lock and the Coordinator checks it again.
  • Attachments, prepended reminders, remote workspaces, Shared TUI execution, missing or stale routes, and malformed execution targets fail closed.
  • Commands combining delegation with shell expansion are restricted before expansion, so local shell side effects cannot occur before later admission fails.
  • Model, variant, subtask false, implicit/default-agent delegation, and cross-ecosystem or local same-name fallback remain unsupported.
  • No Plugin Host Runtime, LSP, background/team/follow-up delegation, or temporary compatibility path is added.

Validation

  • cargo check -p bitfun-core -p bitfun-cli
  • cargo check -p bitfun-desktop
  • focused Core and CLI delegated-command tests: 12 passed
  • focused OpenCode adapter, Runtime Port, SDK v3, and Task result-shape tests passed
  • Web lint, TypeScript check, and 3 focused suites: 51 passed
  • Core boundary check and self-test passed
  • i18n audit and repository hygiene passed
  • git diff --check passed

An isolated adversarial review was repeated after fixes and found no remaining P0, P1, or P2 issues.

@limityan
limityan force-pushed the yanzhn/opencode-command-subagent-delegation branch from 1d38c20 to a035831 Compare August 2, 2026 05:26
@limityan
limityan merged commit 6cf29e3 into GCWing:main Aug 2, 2026
7 checks passed
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.

1 participant