Skip to content

fix(core): stop sub-agent streams from bubbling to parent - #1003

Merged
dingyi222666 merged 2 commits into
v1-devfrom
fix/sub-agent-stream
Aug 5, 2026
Merged

dingyi222666 merged 2 commits into
v1-devfrom
fix/sub-agent-stream

Conversation

@dingyi222666

Copy link
Copy Markdown
Member

This pr prevents sub-agent intermediate tokens and tool calls from being streamed as if they were the main agent's output.

New Features

  • None

Bug Fixes

  • Resolve a dedicated callback set for non-background sub-agent runs instead of inheriting the parent agent's callbacks
  • Keep only registered callback providers (runtime sync, etc.) so sub-agent chunks no longer bubble up to the channel stream

Other Changes

  • None

Validation

  • yarn lint-fix (0 errors, 2 existing warnings)
  • yarn fast-build core

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 62596acc-11ea-488b-b7ba-0b0ca18e37aa

📥 Commits

Reviewing files that changed from the base of the PR and between ff55d1b and e7abda9.

📒 Files selected for processing (1)
  • packages/core/src/llm-core/agent/sub-agent/executor.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/src/llm-core/agent/sub-agent/executor.ts

Walkthrough

子代理执行器新增会话相关类型导入。执行器统一解析请求 ID。前台运行根据会话上下文解析回调。后台运行继续不传递回调。generate 使用解析后的请求 ID和回调。

Changes

子代理回调流程

Layer / File(s) Summary
会话上下文回调解析
packages/core/src/llm-core/agent/sub-agent/executor.ts
执行器导入会话相关类型,并统一解析请求 ID。前台子代理通过当前会话、会话记录、用户消息、事件和请求上下文解析回调。后台运行不传递回调。generate 使用解析后的请求 ID和回调。

Estimated code review effort: 2 (简单) | ~10 分钟

Poem

小兔捧着回调跑,
会话指路不迷航。
请求编号先解析,
前台传递新上下文。
后台安静不声响,
generate 跳起胡萝卜舞。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了阻止子代理流向父代理的核心修复。
Description check ✅ Passed 描述明确说明了回调隔离和防止子代理中间输出冒泡的变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sub-agent-stream

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.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/src/llm-core/agent/sub-agent/executor.ts`:
- Around line 108-120: 在执行流程中提前计算一次最终 requestId,优先使用
options.runConfig?.configurable?.agentContext?.requestId,否则回退到 runId;将该值同时传给
resolveCallbacks 和 options.target.agent.generate,确保回调解析与生成调用使用同一请求标识。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 45ab637e-a0e9-4a1b-a470-644679d224e3

📥 Commits

Reviewing files that changed from the base of the PR and between 214237d and ff55d1b.

📒 Files selected for processing (1)
  • packages/core/src/llm-core/agent/sub-agent/executor.ts

@dingyi222666
dingyi222666 merged commit a3f2518 into v1-dev Aug 5, 2026
5 checks passed
@dingyi222666
dingyi222666 deleted the fix/sub-agent-stream branch August 5, 2026 11:34
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