openclaw/src/shared/text
OfflynAI 78df859e15
fix: strip standalone <function> tool call tags from visible text (#67318) (thanks @joelnishanth)
* fix: strip standalone <function> tool call tags from visible text (#67093)

Models like Gemma emit tool calls as standalone <function> blocks with
nested <parameter> XML instead of wrapping them in <tool_call>. The
existing stripToolCallXmlTags only recognized tool_call, tool_result,
function_call, function_calls, and tool_calls — so bare <function> and
</function> tags leaked through to the user as raw syntax on Discord
and other channels.

Add "function" to TOOL_CALL_TAG_NAMES and extend the payload detection
for <function> tags to check XML payloads (not just JSON), matching the
same behavior already applied to <tool_call>. Other tag types keep the
more conservative JSON-only check to avoid stripping prose examples.

Made-with: Cursor

* Text: harden standalone <function> stripping

* fix: strip standalone <function> tool call tags from visible text (#67318) (thanks @joelnishanth)

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-04-16 09:53:35 +05:30
..
assistant-visible-text.test.ts fix: strip standalone <function> tool call tags from visible text (#67318) (thanks @joelnishanth) 2026-04-16 09:53:35 +05:30
assistant-visible-text.ts fix: strip standalone <function> tool call tags from visible text (#67318) (thanks @joelnishanth) 2026-04-16 09:53:35 +05:30
auto-linked-file-ref.ts refactor: dedupe command config lowercase helpers 2026-04-07 20:57:03 +01:00
code-regions.test.ts test: align code region fence slices 2026-03-28 11:48:13 +00:00
code-regions.ts fix(text): handle fenced code fence termination 2026-03-28 08:34:18 +00:00
join-segments.test.ts test: dedupe routing and text suites 2026-03-28 07:31:40 +00:00
join-segments.ts
model-special-tokens.ts fix: avoid leading spaces when stripping model tokens 2026-04-06 17:02:10 +01:00
reasoning-tags.test.ts fix: strip antml thinking tags 2026-04-02 14:28:54 +05:30
reasoning-tags.ts fix: strip antml thinking tags 2026-04-02 14:28:54 +05:30
strip-markdown.ts fix(line): preserve underscores inside words in stripMarkdown (#47465) 2026-03-28 21:31:09 -05:00