Skip to content

Commit c7339cf

Browse files
committed
fix(chat): sync live-stream fence strip regex with backend TOOL_TAGS
The browser-side EXEC_FENCE_RE only covered 6 tool names (web_search, read_file, write_file, create_document, edit_document, update_document) while the backend strips all TOOL_TAGS from persisted round_texts. This caused executed fenced tool calls (e.g. list_emails, send_email) to remain visible in the live streaming view until session reload. Replace the hardcoded regex with an EXEC_TOOL_TAGS array sourced from the same set as src/agent_tools/__init__.py (minus bash/python/ls which are valid code-block identifiers), and build EXEC_FENCE_RE from it. Fixes #3993
1 parent 9d7a3d6 commit c7339cf

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

static/js/chatRenderer.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,34 @@ function _openVisionEditor(att, userMsgEl) {
406406

407407
// Tool call syntax patterns to strip from displayed text
408408
const TOOL_CALL_RE = /\[TOOL_CALL\][\s\S]*?\[\/TOOL_CALL\]/gi;
409-
// Only strip fenced tool-call blocks that look like structured invocations, not regular code examples
410-
const EXEC_FENCE_RE = /```(?:web_search|read_file|write_file|create_document|edit_document|update_document)\s*\n[\s\S]*?```/gi;
409+
// Executable fenced tool-call blocks: must stay in sync with src/agent_tools/__init__.py TOOL_TAGS.
410+
// Excludes bash/python/ls which commonly appear as fenced-code language identifiers.
411+
const EXEC_TOOL_TAGS = [
412+
'web_search', 'web_fetch', 'read_file', 'write_file', 'edit_file',
413+
'grep', 'glob', 'get_workspace',
414+
'create_document', 'update_document', 'edit_document',
415+
'search_chats',
416+
'chat_with_model', 'create_session', 'list_sessions', 'send_to_session',
417+
'pipeline',
418+
'manage_session', 'manage_memory', 'list_models',
419+
'ui_control', 'generate_image', 'ask_user', 'update_plan',
420+
'manage_tasks', 'api_call', 'ask_teacher', 'manage_skills',
421+
'suggest_document',
422+
'manage_endpoints', 'manage_mcp', 'manage_webhooks',
423+
'manage_tokens', 'manage_documents', 'manage_settings',
424+
'manage_notes', 'manage_calendar',
425+
'resolve_contact', 'manage_contact', 'list_email_accounts', 'send_email',
426+
'list_emails', 'read_email', 'reply_to_email', 'bulk_email',
427+
'archive_email', 'delete_email', 'mark_email_read',
428+
'download_model', 'serve_model', 'list_served_models', 'stop_served_model',
429+
'list_downloads', 'cancel_download',
430+
'search_hf_models', 'list_cached_models',
431+
'list_serve_presets', 'serve_preset', 'adopt_served_model',
432+
'list_cookbook_servers',
433+
'edit_image', 'trigger_research', 'manage_research',
434+
'app_api',
435+
];
436+
const EXEC_FENCE_RE = new RegExp('```(?:' + EXEC_TOOL_TAGS.join('|') + ')\\s*\\n[\\s\\S]*?```', 'gi');
411437
// XML-style tool calls: <minimax:tool_call>, <tool_call>, <function_call>, bare <invoke>
412438
const XML_TOOL_CALL_RE = /<(?:[\w]+:)?(?:tool_call|function_call)>[\s\S]*?<\/(?:[\w]+:)?(?:tool_call|function_call)>/gi;
413439
const XML_INVOKE_RE = /<invoke\s+name=['"][^'"]*['"]>[\s\S]*?<\/invoke>/gi;

0 commit comments

Comments
 (0)