Skip to content

fix(agents): transform tool call output text#97765

Closed
lin-hongkuan wants to merge 2 commits into
openclaw:mainfrom
lin-hongkuan:text-transforms-toolcalls
Closed

fix(agents): transform tool call output text#97765
lin-hongkuan wants to merge 2 commits into
openclaw:mainfrom
lin-hongkuan:text-transforms-toolcalls

Conversation

@lin-hongkuan

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #97761.

Plugin textTransforms.output currently rewrites streamed assistant text and final messages, but skips structured tool-call output boundaries. Providers that emit masked or placeholder strings through toolcall_delta or parsed toolCall.arguments can therefore pass stale values into later tool execution even though normal text output is transformed.

Why This Change Was Made

The stream wrapper already owns output replacement at the provider boundary. This change extends that same boundary to tool-call deltas and the string leaves inside tool-call argument objects, while leaving tool names, ids, numeric values, and other metadata untouched.

User Impact

Users relying on plugin output replacements get consistent behavior for tool-call payloads as well as regular assistant text, reducing the chance that masked placeholders reach external tools.

Evidence

  • node scripts/run-vitest.mjs src/agents/plugin-text-transforms.test.ts
  • pnpm format:check src/agents/plugin-text-transforms.ts src/agents/plugin-text-transforms.test.ts
  • git diff --check
  • Secret scan over diff: no matches for common token/private-key patterns

Refs/Fixes: #97761

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Jun 29, 2026
@clawsweeper

clawsweeper Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: this PR is a partial same-root-cause fix, while #97769 is open, mergeable, proof-positive, and covers the missing final-result tool-call path for the same linked issue.

Root-cause cluster
Relationship: superseded
Canonical: #97769
Summary: This PR, #97769, and #97775 all target the same text-transform tool-call issue; #97769 is the narrow proof-positive viable candidate that supersedes this partial branch.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Land one canonical implementation for #97761, preferably the proof-positive narrow candidate in #97769 unless maintainers choose the broader alternative, then close the remaining duplicate branches.

So I’m closing this here and keeping the remaining discussion on #97761 and #97769.

Review details

Best possible solution:

Land one canonical implementation for #97761, preferably the proof-positive narrow candidate in #97769 unless maintainers choose the broader alternative, then close the remaining duplicate branches.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection shows current main does not transform ToolCall.arguments in the final message path, while agent-loop executes tool calls from response.result(); I did not run a live DeepSeek/chat-space scenario in this read-only review.

Is this the best way to solve the issue?

No. This PR is a plausible partial fix, but the best fix must also transform final assistant-message ToolCall.arguments; #97769 already does that with real behavior proof.

Security review:

Security review cleared: The diff only changes the agent text-transform helper and its focused test; no dependency, CI, permission, package, downloaded-code, or secret-handling surface changed.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • steipete: git show ties Peter Steinberger to feat: add plugin text transforms, which added the helper and tests now being changed, and history also shows adjacent stream-wrapper work. (role: introduced behavior and adjacent owner; confidence: high; commits: 202f80792ed1, 4e2541e5fbbf; files: src/agents/plugin-text-transforms.ts, src/agents/plugin-text-transforms.test.ts, src/plugins/provider-runtime.ts)
  • vincentkoc: Recent history shows adjacent provider/plugin runtime seam work that the text-transform wrapper depends on, including provider runtime and embedded runner paths. (role: recent adjacent contributor; confidence: medium; commits: a7436c8b4a93, 7198a9f0eeed; files: src/plugins/provider-runtime.ts, src/agents/embedded-agent-runner/run/attempt.ts, src/agents/cli-backends.ts)
  • pick-cat: Current git blame attributes the inspected transform and agent-loop lines to a recent commit, but that commit appears broad/adjacent rather than the feature introduction, so this is only a weak routing signal. (role: current-line provenance; confidence: low; commits: eb5fb2aa69f4; files: src/agents/plugin-text-transforms.ts, packages/agent-core/src/agent-loop.ts)

Codex review notes: model internal, reasoning high; reviewed against 6cb82eaab865.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jun 29, 2026
@lin-hongkuan

Copy link
Copy Markdown
Contributor Author

Ensured the PR body has explicit real-behavior proof sections for the proof gate.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 30, 2026
@clawsweeper

clawsweeper Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] textTransforms should apply output replacements to toolcall_delta / toolcall_end events

1 participant