Skip to content

feat: add Agent Team support#382

Open
shadowpigy wants to merge 4 commits intozed-industries:mainfrom
shadowpigy:feat/agent-team-support
Open

feat: add Agent Team support#382
shadowpigy wants to merge 4 commits intozed-industries:mainfrom
shadowpigy:feat/agent-team-support

Conversation

@shadowpigy
Copy link

Summary

  • Enable experimental agent teams for all ACP sessions (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1)
  • Forward task_started/task_progress/task_notification as agent_message_chunk notifications
  • After result with team activity, continue reading generator with timeout for follow-up messages (30s initial, 5s for subsequent cleanup turns)
  • Display TeamCreate/TeamDelete/SendMessage in tool info
  • Carry over pending generator promise across prompt() calls via session.pendingNext

Partially addresses #336

Test plan

  • npm run lint passes
  • npm run format:check passes
  • npm run test:run — 126 tests pass
  • Manual E2E: direct stdio test with team creation, greeter agent, message exchange, cleanup

🤖 Generated with Claude Code

Enable experimental agent teams for all ACP sessions and surface team
lifecycle events to clients.

- Set CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 in session env
- Forward task_started/task_progress/task_notification as agent_message_chunk
- After result with team activity, continue reading generator with
  timeout to catch follow-up messages from team monitoring (30s initial,
  5s for subsequent cleanup turns)
- Display TeamCreate/TeamDelete/SendMessage in tool info
- Carry over pending generator promise across prompt() calls via
  session.pendingNext

Partially addresses zed-industries#336

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cla-bot
Copy link

cla-bot bot commented Mar 5, 2026

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: hexarrior.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4856710b85

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cla-bot
Copy link

cla-bot bot commented Mar 5, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @shadowpigy on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

- Remove default CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS env var; let
  callers opt-in via user-provided options (per maintainer feedback)
- Respect session cancellation during team idle timeout (P2)
- Preserve promptResult in replay-handoff path (P1)
- Fix test _meta structure to match NewSessionMeta type

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cla-bot
Copy link

cla-bot bot commented Mar 5, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @shadowpigy on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@shadowpigy
Copy link
Author

@cla-bot check

1 similar comment
@shadowpigy
Copy link
Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed label Mar 5, 2026
@cla-bot
Copy link

cla-bot bot commented Mar 5, 2026

The cla-bot has been summoned, and re-checked this pull request!

Apply the same filtering logic from the live streaming path to
replaySessionHistory: skip user messages where content is a string
or a single text block, as these are CLI-injected synthetic messages
(teammate-message, system-reminder, etc.) not meant for display.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@shadowpigy
Copy link
Author

Addressed all review feedback:

  • Removed the hardcoded CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS env var — callers now opt-in via _meta.claudeCode.options.env (per @josevalim's suggestion)
  • Added cancellation check during team idle timeout (Codex P2)
  • Preserved promptResult in replay-handoff path (Codex P1)
  • Fixed replaySessionHistory to filter CLI-injected synthetic user messages (teammate-message, system-reminder, etc.) — applied the same filtering logic already used in the live streaming path

@shadowpigy
Copy link
Author

Bug found: replaySessionHistory() filter is too broad — drops all text-only user messages

The filter added in replaySessionHistory() to skip CLI-injected synthetic messages (teammate-message, system-reminder, etc.) inadvertently skips all text-only user messages:

if (
  role === "user" &&
  (typeof content === "string" ||
    (Array.isArray(content) && content.length === 1 && content[0].type === "text"))
) {
  continue;
}

The problem is that synthetic and real user text messages are structurally identical — there's no metadata to distinguish them. This causes session/load to replay history without any of the user's text messages (only image messages survive the filter).

Possible fixes:

  1. Check content for synthetic markers (e.g. <teammate-message>, <system-reminder> tags)
  2. Have CLI add metadata (e.g. _synthetic: true) when injecting synthetic messages
  3. Move filtering to the CLI layer (handleUserMessageChunk) instead of ACP

@josevalim What's your take on the right approach here?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants