conversation: scrub OpenClaw tool_code fences before TTS#26
Open
tundakk wants to merge 1 commit intotechartdev:mainfrom
Open
conversation: scrub OpenClaw tool_code fences before TTS#26tundakk wants to merge 1 commit intotechartdev:mainfrom
tundakk wants to merge 1 commit intotechartdev:mainfrom
Conversation
…tick-tool_code markdown fences from /v1/chat/completions responses, which carry raw LLM output upstream of all plugin hooks; fence-only output becomes "OK.", surrounding text untouched. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Strip
```tool_code```markdown fences from conversation responses before they reach the Assist pipeline.When OpenClaw is paired with a workspace plugin that handles tool calls via gemma3-style fences (e.g., a custom
record_facttool in a personal-memory plugin), Voice PE TTS literally speaks the raw call: "record underscore fact open paren person underscore slug equals quote...". OpenClaw's plugin hook system rewrites the persisted transcript viabefore_message_write, butresult.payloadsis built directly from raw LLM output upstream of any hook — verified empirically withstream:false(the response payload still surfaces the raw fence even when persistence-side bridges have logged the rewrite). The architectural fix would belong upstream inopenclaw/openclaw(firingbefore_message_writeonresult.payloadstoo, or a newbefore_response_finalizehook); this PR is a localized HA-side scrub.The scrubber is 15 lines, no new dependencies, applied symmetrically on both the streaming and non-streaming response paths in
_get_response. Behavior:record_fact-style turns) →"OK."Test plan
record_fact-triggering prompt round-tripped through/api/services/conversation/process?return_response=true:speech.plain.speechis"OK."(was raw fence)"Son1's favorite color is blue. Source: family_db#son1.favorites.color"🤖 Generated with Claude Code