Skip to content

fix: fixed the problem of failure to call extensionTransport connection tool in ReAct mode#260

Merged
zzcr merged 2 commits intodevfrom
zzc/fix-react-calltool-issue-1213
Dec 23, 2025
Merged

fix: fixed the problem of failure to call extensionTransport connection tool in ReAct mode#260
zzcr merged 2 commits intodevfrom
zzc/fix-react-calltool-issue-1213

Conversation

@zzcr
Copy link
Member

@zzcr zzcr commented Dec 23, 2025

fix: 修复ReAct模式下调用extensionTransport连接的工具失败问题

Summary by CodeRabbit

  • Bug Fixes

    • Fixed transport connection handling to prevent server connection interruptions by refining which connection types are terminated during cleanup operations.
  • Chores

    • Version updates: next-remoter (0.0.10-beta.1 → 0.0.10-beta.2) and next-sdk (0.1.15-beta.1 → 0.1.15-beta.2).

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 23, 2025

Walkthrough

Version bumps in two package files, with a logic update to AgentModelProvider._closeOneClient method to also exclude ExtensionClientTransport from closure operations alongside existing paired transports, with corresponding comment updates.

Changes

Cohort / File(s) Summary
Version Bumps
packages/next-remoter/package.json, packages/next-sdk/package.json
Version incremented in beta releases: next-remoter (0.0.10-beta.1 → 0.0.10-beta.2) and next-sdk (0.1.15-beta.1 → 0.1.15-beta.2).
Transport Type Exclusion
packages/next-sdk/agent/AgentModelProvider.ts
_closeOneClient method updated to exclude ExtensionClientTransport from closure checks alongside InMemoryTransport and MessageChannelTransport. Comments clarified that these three are paired transports that must not be closed to preserve server connections.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A transport so fine, with clients so dear,
No closure shall break what they hold near,
Extension joins kin in the paired transport crew,
Connections preserved—fresh beta version too!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references extensionTransport connection tool issues in ReAct mode, which aligns with the actual fix to AgentModelProvider.ts that excludes ExtensionClientTransport from being closed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch zzc/fix-react-calltool-issue-1213

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/next-sdk/agent/AgentModelProvider.ts (1)

134-146: Good fix: Correctly prevents closing paired ExtensionClientTransport.

The addition of ExtensionClientTransport to the exclusion list is correct. Like InMemoryTransport and MessageChannelTransport, it's a paired transport where closing the client side would disrupt the server connection (via Chrome extension messaging). This properly fixes the ReAct mode tool calling failure.

Optional: Consider consolidating the two transport exclusion checks

The two separate if blocks (lines 136-141 and 144-146) could be combined for better maintainability:

-      // 如果是 InMemoryTransport 或 MessageChannelTransport,不关闭传输层
-      // 因为它们是配对的,关闭一端会影响另一端(服务端)
-      if (
-        (transport && transport instanceof InMemoryTransport) ||
-        (transport && transport instanceof MessageChannelTransport)
-      ) {
-        return
-      }
-
-      // 因为它们是基于 Chrome 扩展的消息传递机制,关闭会影响服务端的连接
-      if (transport && transport instanceof ExtensionClientTransport) {
-        return
-      }
+      // 如果是配对传输(InMemoryTransport、MessageChannelTransport、ExtensionClientTransport),
+      // 不关闭传输层,因为关闭一端会影响另一端(服务端)的连接
+      if (
+        (transport && transport instanceof InMemoryTransport) ||
+        (transport && transport instanceof MessageChannelTransport) ||
+        (transport && transport instanceof ExtensionClientTransport)
+      ) {
+        return
+      }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a75c17e and fb96e7c.

📒 Files selected for processing (3)
  • packages/next-remoter/package.json
  • packages/next-sdk/agent/AgentModelProvider.ts
  • packages/next-sdk/package.json
🧰 Additional context used
🧬 Code graph analysis (1)
packages/next-sdk/agent/AgentModelProvider.ts (2)
packages/next-sdk/index.ts (1)
  • InMemoryTransport (10-10)
packages/next-sdk/transport/ExtensionClientTransport.ts (1)
  • ExtensionClientTransport (11-90)
🔇 Additional comments (3)
packages/next-sdk/package.json (1)

3-3: LGTM: Version bump coordinated with the fix.

The beta.2 version increment is appropriate for this bug fix release and aligns with the corresponding version bump in packages/next-remoter/package.json.

packages/next-remoter/package.json (1)

3-3: LGTM: Coordinated version bump.

The beta.2 version increment maintains consistency with the next-sdk package update.

packages/next-sdk/agent/AgentModelProvider.ts (1)

143-146: Listener cleanup bypassed for ExtensionClientTransport prevents proper removal.

The close() method in ExtensionClientTransport correctly calls this._messageListener() to unregister the chrome.runtime.onMessage listener (line 84), but this cleanup is never executed because AgentModelProvider intentionally skips calling close() on these transports (lines 143-146). This causes listeners to accumulate on repeated transport instantiation cycles, creating a memory leak risk.

The current approach assumes transport instances are long-lived, but this assumption should be documented and verified:

  1. Confirm if ExtensionClientTransport instances are created/destroyed multiple times during a session
  2. If session/lifecycle events trigger new instances, implement explicit cleanup on those boundaries
  3. Consider whether the server-connection concerns can be addressed with graceful disconnection instead of skipping cleanup entirely

@zzcr zzcr merged commit 04a483e into dev Dec 23, 2025
3 checks passed
@kagol kagol deleted the zzc/fix-react-calltool-issue-1213 branch January 8, 2026 08:20
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

Comments