Skip to content

Conversation

@Gulianrdgd
Copy link
Contributor

Summary

This PR fixes two issues with the Ollama nodes:

  1. Thinking tokens issue: Ollama models with reasoning capabilities were dumping thinking tokens directly into the model output. Updated the @langchain/ollama package to the latest version and added an option to disable thinking output. I have tested this extensively and it works really well. However currently in the AI Agent node with a chat model, we cannot see the thinking output. I have written some code for that but it is rather ugly so I did not want to include it into this pull request. I noticed that the other AI models also do not show the thinking tokens, but I do think there is some use for it. If there is maybe we can think about changing the AI agent node.

We only send the think field if it is explicitly set to false. The default on Ollama is set to true. When we send think: true and the model does not support it, we get an error.

The think field should also be there on the Ollama node instead of only the OllamaChat node but sadly this is not yet implemented in LangChain. I will create a pull request there and when they have a new release I will create a new pull reuqest here.

  1. URL composition bug: The URL constructor was incorrectly removing path segments after the domain. For example, https://openwebui/ollama + /api/tags resulted in https://openwebui/api/tags instead of https://openwebui/ollama/api/tags. Simplified the URL composition logic to handle paths correctly. I know that technically this should be another pull request but the change is so small that I included it here.

Thinking on:
Screenshot 2026-01-07 at 08 48 40

Thinking off:
Screenshot 2026-01-07 at 10 51 19

Related Linear tickets, Github issues, and Community forum posts

None

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

Choose a reason for hiding this comment

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

3 Open source vulnerabilities detected - high severity
Aikido detected 3 vulnerabilities across 3 packages, it includes 3 high vulnerabilities.

Remediation Aikido suggests bumping the vulnerable packages to a safe version.
View details in Aikido Security

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 8 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/@n8n/nodes-langchain/nodes/vendors/Ollama/actions/image/analyze.operation.ts">

<violation number="1" location="packages/@n8n/nodes-langchain/nodes/vendors/Ollama/actions/image/analyze.operation.ts:439">
P1: Using `!!` to convert `processedOptions.think` treats `undefined` (option not set) the same as `false` (explicitly disabled). Per the PR description, the intent is to only send `think: false` when explicitly disabled. When the option isn't added, `undefined` should result in not sending the think field at all.</violation>
</file>

<file name="packages/@n8n/nodes-langchain/nodes/vendors/Ollama/actions/text/message.operation.ts">

<violation number="1" location="packages/@n8n/nodes-langchain/nodes/vendors/Ollama/actions/text/message.operation.ts:404">
P1: The double negation `!!processedOptions.think` incorrectly treats `undefined` (option not set) the same as `false` (explicitly disabled). When the user doesn't add the Thinking option, `processedOptions.think` is `undefined`, which becomes `false` via `!!`, causing `body.think = false` to be sent. This contradicts the PR's intent to only send `think: false` when explicitly disabled. Use strict equality check instead.</violation>
</file>

<file name="packages/@n8n/nodes-langchain/nodes/vendors/Ollama/transport/index.ts">

<violation number="1" location="packages/@n8n/nodes-langchain/nodes/vendors/Ollama/transport/index.ts:32">
P1: URL concatenation doesn't handle trailing slash on `baseUrl`. When `baseUrl` ends with `/` (e.g., `http://localhost:11434/`) and `endpoint` starts with `/` (e.g., `/api/tags`), this produces a double slash (`http://localhost:11434//api/tags`). The existing test 'should handle baseUrl with trailing slash' expects the normalized URL without double slashes.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@n8n-assistant n8n-assistant bot added community Authored by a community member in linear Issue or PR has been created in Linear for internal review labels Jan 7, 2026
@n8n-assistant
Copy link
Contributor

n8n-assistant bot commented Jan 7, 2026

Hey @Gulianrdgd,

Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request.

Before we can proceed, please ensure the following:
• Tests are included for any new functionality, logic changes or bug fixes.
• The PR aligns with our contribution guidelines.

Regarding new nodes:
We no longer accept new nodes directly into the core codebase. Instead, we encourage contributors to follow our Community Node Submission Guide to publish nodes independently.

If your node integrates with an AI service that you own or represent, please email [email protected] and we will be happy to discuss the best approach.

About review timelines:
This PR has been added to our internal tracker as "GHC-6203". While we plan to review it, we are currently unable to provide an exact timeframe. Our goal is to begin reviews within a month, but this may change depending on team priorities. We will reach out when the review begins.

Thank you again for contributing to n8n.

Gulianrdgd and others added 3 commits January 7, 2026 11:32
…ndex.ts

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
…-tokens' into fix-ollama-url-path-and-thinking-tokens
@Gulianrdgd
Copy link
Contributor Author

langchain-ai/langchainjs#9758

Here is the langchain PR btw, but they tend to not release very quickly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Authored by a community member in linear Issue or PR has been created in Linear for internal review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant