Skip to content

fix(formatter): keep parallel Ollama tool calls on one assistant message - #3910

Merged
qbc2016 merged 1 commit into
agentscope-ai:mainfrom
MaxFreedomPollard:fix/ollama-parallel-tool-calls
Nov 10, 2026
Merged

qbc2016 merged 1 commit into
agentscope-ai:mainfrom
MaxFreedomPollard:fix/ollama-parallel-tool-calls

Conversation

@MaxFreedomPollard

Copy link
Copy Markdown
Contributor

OllamaChatFormatter gave every ToolCallBlock its own assistant message, so a turn with parallel tool calls became consecutive assistant messages. Ollama's server collates consecutive same-role messages by appending only their content to the first one, which drops the tool calls of every message after the first while their tool results stay.

A tool call that follows another tool call of the same Msg now joins the message carrying the earlier calls, along with any text or images in between, matching the one-message shape of Ollama's parallel tool calling and of the other chat formatters.

PR Title Format

Please ensure your PR title follows the Conventional Commits format:

  • Format: <type>(<scope>): <description>
  • Example: feat(memory): add redis cache support
  • Allowed types: feat, fix, docs, ci, refactor, test, chore, perf, style, build, revert
  • Description should start with a lowercase letter

AgentScope Version

[The version of AgentScope you are working on, e.g. import agentscope; print(agentscope.__version__)]

Description

[Please describe the background, purpose, changes made, and how to test this PR]

Checklist

Please check the following items before code is ready to be reviewed.

  • An issue has been created for this PR
  • I have read the CONTRIBUTING.md
  • Docstrings are in Google style
  • Related documentation has been updated (e.g. links, examples, etc.) in documentation repository
  • Code is ready for review

OllamaChatFormatter gave every ToolCallBlock its own assistant message,
so a turn with parallel tool calls became consecutive assistant
messages. Ollama's server collates consecutive same-role messages by
appending only their content to the first one, which drops the tool
calls of every message after the first while their tool results stay.

A tool call that follows another tool call of the same Msg now joins
the message carrying the earlier calls, along with any text or images
in between, matching the one-message shape of Ollama's parallel tool
calling and of the other chat formatters.
@github-actions github-actions Bot added pr/awaiting-review Waiting for maintainers to review this PR pr/no-linked-issue This PR does not link to any issue labels Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the pull request. One thing worth sorting out before it is reviewed:

  • This pull request does not close an issue. Please open one describing the problem first and link it with Fixes #<number>, so the change can be discussed against the problem it solves.

If you think it belongs here anyway, say so and a maintainer will take a look.

@qbc2016 qbc2016 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qbc2016
qbc2016 merged commit 6d95d57 into agentscope-ai:main Nov 10, 2026
9 checks passed
@github-actions github-actions Bot removed the pr/awaiting-review Waiting for maintainers to review this PR label Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr/no-linked-issue This PR does not link to any issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants