Skip to content

MAIT-296: Fix missing tool call result when two tools called simultaneously - #12

Merged
vedmaka merged 7 commits into
masterfrom
MAIT-296-fix-missing-tool-call-result
Nov 19, 2026
Merged

vedmaka merged 7 commits into
masterfrom
MAIT-296-fix-missing-tool-call-result

Conversation

@acikabubo

Copy link
Copy Markdown
Contributor

Summary

  • done=false tool call blocks in serialize_content_blocks were missing a trailing newline, causing inconsistent marked.js token structure between in-progress and done states
  • Svelte's index-keyed each destroyed and recreated the second tool call Collapsible on transition, while the first updated in place, leaving it invisible
  • Added trailing newline to done=false blocks in both serialization paths in middleware.py

…eously

done=false blocks were serialized without a trailing newline, while
done=true blocks ended with \n. With two concurrent tool calls this
caused consecutive in-progress blocks to have no separator between
them, while done blocks got \n\n (a marked space token). The token
array structure shifted on transition, causing Svelte's index-keyed
#each to destroy and recreate the second Collapsible while updating
the first in place — leaving the first tool call result invisible.

Fix: add trailing \n to done=false blocks in both serialization paths
so both states produce identical token structure with stable indices.
…etion

The backend sends tool_calls data only in content_blocks, not in the
content string of the final chat:completion event. Without this fix,
tool call result blocks never appear in the rendered message.

Serialize content_blocks (reasoning, tool_calls, text) back into
message.content HTML when done=true so the markdown renderer can
display the <details type="tool_calls"> collapsibles.
@acikabubo
acikabubo force-pushed the MAIT-296-fix-missing-tool-call-result branch from 6b52950 to 050b96c Compare June 28, 2026 16:15
replaceTokens() replaces [N] citation markers with <source_id> tags
across the whole message, including inside <details type="tool_calls">
blocks. When a tool's result text contains a [N] that collides with an
active citation index, this corrupts the details tag's attributes and
the frontend stops recognizing it, silently dropping that tool's
result. Confirmed against the chat originally linked in this ticket.

Scope the substitution to skip <details>...</details> regions, same as
the existing code-fence exclusion.

Also fixes Chat.svelte's content_blocks rebuild only escaping quotes
(not <, >, &) in tool output, which corrupts the same tag structure via
raw markup like MediaWiki <ref> tags — a related bug, not confirmed as
this ticket's specific symptom.
Comment thread backend/open_webui/utils/middleware.py Resolved
…e blocks

Reverts the trailing \n added in 0148d54. That change targeted a
token-alignment theory that isn't the actual cause of the reported bug
— the confirmed root cause (citation-marker substitution corrupting
the tool_calls details tag) is unrelated to newline placement and is
fixed separately. Per review feedback.
Comment thread src/lib/components/chat/Chat.svelte Resolved
Comment thread src/lib/components/chat/Chat.svelte Resolved
Comment thread src/lib/utils/index.ts Resolved
Replace citations in the body of a details block. Keep the opening tag and summary unchanged. An unclosed backtick can no longer change the tag.
@github-actions

Copy link
Copy Markdown

🐳 The image has been built and pushed with the following tags: ghcr.io/wikiteq/maition-web-ui:pr-12, ghcr.io/wikiteq/maition-web-ui:bfcbdd6

@vedmaka
vedmaka merged commit e2b6e3a into master Nov 19, 2026
6 checks passed
@vedmaka
vedmaka deleted the MAIT-296-fix-missing-tool-call-result branch November 19, 2026 02:59
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.

3 participants