Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(opencode): show native Task subagents in the Agents panel #7393

Closedinayayousfi(GitHub profile, opens in a new tab)wants to merge 10 commits intomain fromrefs/pull/7393/headopened View on GitHub

Written by inayayousfi, typed by GPT-5.6 Sol running in OpenCode. Every call here is inayayousfi's, and no agent acted on its own.

What Changed

OpenCode's adapter now translates native Task tool states into the existing task.* lifecycle events consumed by the Agents panel. It keeps the current Task rows in the work log, preserves child identity and model metadata, and handles foreground, resumed, failed, and background tasks.

The adapter tests cover lifecycle projection, duplicate updates, missing error metadata, and background completion notifications.

Why

OpenCode already created and completed child sessions, but its adapter only emitted generic item.* events. The work appeared in the thread while the Agents panel incorrectly said No agents yet.

This uses the parent Task metadata instead of routing every child-session event into the parent thread.

Fixes #5952.

Closes discussions

UI Changes

Before

Completed OpenCode Task calls with an empty Agents panel

After

Two completed OpenCode subagents in the Agents panel

Verification

  • vp test run apps/server/src/provider/Layers/OpenCodeAdapter.test.ts
  • vp run --filter t3 typecheck
  • Two native Explore subagents completed in a real OpenCode thread and appeared as separate Agents rows.

Note

Medium Risk Changes OpenCode session startup ordering and event translation for subagent UI; behavior is heavily unit-tested but affects reconnect and concurrent startSession races.

Overview OpenCode’s adapter now turns native Task tool activity into task.started, task.updated, and task.completed events (with role, model, and tool metadata) so the Agents panel can show subagents instead of only generic item.* events.

Live updates come from message.part.updated on Task tool parts and synthetic <task> text notifications; background tasks wait for those notifications rather than treating a completed tool part as terminal. On resume/fork, it reads session.messages, replays the latest terminal per task with stable event IDs, and dedupes against the live stream.

startSession now subscribes to events before emitting session.started / thread.started; subscribe failure returns ProviderAdapterProcessError with no session registered, and reused sessions are not session.abort’d on that path.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 748474775ec3e8ad753b223fa3b8f85d3258f330. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Show native Task subagents in the Agents panel for OpenCode sessions

  • Adds task.started, task.updated, and task.completed event emission to the OpenCode adapter by inferring task lifecycle state from task tool parts in the live event stream.
  • On session resume or reuse, stored task terminals are recovered via client.session.messages and replayed as task.completed events (with deterministic synthetic event IDs) before live streaming begins.
  • Adds early failure handling in startSession: if event subscription fails, no startup events are published and reused sessions are not aborted.
  • Deduplicates task terminal events seen in both stored history and live stream to avoid double-emitting completions.
  • Risk: session startup behavior changes — subscription failure now returns a ProviderAdapterProcessError immediately rather than proceeding with session events.
Macroscope summarized 7484747.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 945202a9-e307-45bf-9f69-4ba8c2bd5cde

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR introduces a new feature for displaying Task subagents in the Agents panel, including new event types (task.started/updated/completed), complex lifecycle state management, and history reconciliation logic. The scope and runtime behavior changes warrant human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Written by inayayousfi, typed by GPT-5.6 Sol running in OpenCode. Every call here is inayayousfi's, and no agent acted on its own.

      Macroscope passed its correctness check but marked this pull request not approvable because it considers the adapter work substantial new functionality. I renamed the pull request from fix to feat to match that classification, but I highly suspect this reasoning is a model hallucination. The prefix changes neither the code nor its review risk, and this work makes native OpenCode Task subagents appear in the existing Agents panel.

      Could a maintainer please review the pull request and the automated eligibility decision?

    5. Validated this PR against OpenCode 1.18.18 and found several lifecycle edge cases beyond the existing raw-XML finding. I opened a focused PR against the source branch with fixes and 45 passing adapter tests: https://github.com/inayayousfi/t3code/pull/1. A local integration run displayed two native Explore agents as separate settled rows in T3’s Agents panel.

    6. Written by inayayousfi, typed by GPT-5.6 Sol running in OpenCode. Every call here is inayayousfi's, and no agent acted on its own.

      Thanks to @jamie-dit for validating this work against OpenCode 1.18.18 and opening https://github.com/inayayousfi/t3code/pull/1. Their review surfaced three gaps that are now addressed in 5ec72b132: missed background completions after reconnect, truncated results containing Task-like closing tags, and startup success being reported before event subscription succeeded.

      The contribution was based on an earlier version of this branch, so I reimplemented those findings against the current code instead of merging it directly. The extra validation materially improved this pull request.

    7. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 518c12ebcbed50facbffd201c6eb74865bd8ec6b. Configure [here](https://www.cursor.com/dashboard/bugbot).
    8. That would be a lovely addition 👍🏼

    9. This also affects me, validated against opencode 1.18.25.

    10. This is my most wanted feature!

    11. Note

      🤖 GPT-6 Astra (preview) responding on behalf of Theo

      This note is part of an automated cleanup pass.

      Carryover from #9295 at 8c0ad49: preserve OpenCodeAdapter.test.ts cases settles in-flight opencode tasks when the turn is interrupted and ignores late running parts for settled opencode tasks. Stop must emit task.completed with stopped status for each live child task. A delayed running update must not reactivate that task. Apply these assertions to the retained child-session identity and background-task model rather than copying the tool-call identity from the alternative. The cases are recorded for follow-up. They are not claimed as implemented or rerun.

    12. @inayayousfi @t3dotgg — this branch conflicts with main after the adapter rewrite, so I opened inayayousfi/t3code#2 against fix/opencode-task-subagents with the merge resolved and the feature re-ported onto the current adapter (per-part status snapshot instead of the removed tool-part cache, history settled before the pump starts). It also adds the Stop sweep and the two test cases the cleanup pass recorded from #9295, on the child-session identity model this PR uses.

      Theo: I don't know if you're already working on this in a local branch that isn't PR'd yet, but I suggest this implementation as the way to unblock #7393. If the author merges the fork PR, this PR updates in place. Adapter tests are at 116 passing, typecheck is clean.

    13. Thanks for the PR. We're not taking changes to the orchestration and provider layers right now: that part of the server is being rewritten for V2, and merging into the current code would either conflict with or be thrown away by that work.

      Closing for now. If this is still an issue once V2 lands, please reopen (or open a fresh PR against the new code) and we'll take a proper look.

    14. juliusmarminge closed this

Sign in to join this conversation.