Skip to content

fix(ollama): preserve tools across agent loop turns (#13254) - #13269

Open
maoxin1234 wants to merge 2 commits into
continuedev:mainfrom
maoxin1234:fix/ollama-preserve-tools-multi-turn
Open

fix(ollama): preserve tools across agent loop turns (#13254)#13269
maoxin1234 wants to merge 2 commits into
continuedev:mainfrom
maoxin1234:fix/ollama-preserve-tools-multi-turn

Conversation

@maoxin1234

Copy link
Copy Markdown

Description

Fixes #13254. In core/llm/llms/Ollama.ts, options.tools was only forwarded if ollamaMessages.at(-1)?.role === 'user'. In multi-turn tool calling and agent loops, subsequent turns have assistant or tool message histories, causing Ollama to drop the tools definitions mid-loop.

This PR removes the unnecessary restriction, ensuring options.tools remains available throughout multi-turn tool interactions.

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Tests

  • Added unit test in core/llm/llms/Ollama.test.ts verifying tools persistence when the last message is a tool response.
  • Executed �un test core/llm/llms/Ollama.test.ts (all 8 tests passing).

@maoxin1234
maoxin1234 requested a review from a team as a code owner September 13, 2026 05:43
@maoxin1234
maoxin1234 requested review from sestinj and removed request for a team September 13, 2026 05:43
@github-actions

github-actions Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@maoxin1234

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

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.

Ollama provider drops tools after the first tool call, breaking multi-step agent loops

1 participant