← Back to PRs

#11876: fix(ollama): don't auto-enable enforceFinalTag for Ollama models

by Nina-VanKhan open 2026-02-08 13:25 View on GitHub →
stale
## Summary `isReasoningTagProvider("ollama")` returns true for ALL Ollama models, which auto-enabled `enforceFinalTag`. This requires LLM output to be wrapped in `<final>` tags. However, Ollama models (including reasoning models like deepseek-r1) use `<think>` tags for reasoning but output the final response as **plain text** - they do NOT wrap output in `<final>` tags. With `enforceFinalTag` enabled, `stripBlockTags` returned an empty string since no `<final>` tags were found, resulting in silent empty responses. ## Changes - Removed automatic `enforceFinalTag: true` based on provider in `get-reply-run.ts` - Changed `resolveEnforceFinalTag` in `agent-runner-utils.ts` to only honor explicit `run.enforceFinalTag` configuration - The `<think>` tag stripping still works correctly without `enforceFinalTag` ## Test Plan 1. Configure an Ollama model (e.g., `gemma3`) 2. Send a message via the dashboard chat 3. Verify the response is displayed correctly (not empty) 🤖 Generated with [Claude Code](https://claude.ai/code) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This change removes provider-based auto-enabling of `enforceFinalTag` for embedded Pi runs. - In `src/auto-reply/reply/get-reply-run.ts`, the code no longer injects `enforceFinalTag: true` when `isReasoningTagProvider(provider)` is true. - In `src/auto-reply/reply/agent-runner-utils.ts`, `resolveEnforceFinalTag` now only returns `true` when `run.enforceFinalTag` is explicitly set, rather than inferring it from the provider. This is intended to prevent Ollama outputs from being stripped to an empty string when models emit `<think>` but do not wrap final output in `<final>` tags. <h3>Confidence Score: 2/5</h3> - This PR is not safe to merge as-is due to a behavior change that likely breaks existing reasoning-tag provider expectations and associated tests. - The change removes all provider-based enforcement of `enforceFinalTag`, but the repository includes tests asserting that fallback reasoning-tag providers must run with `enforceFinalTag: true`. Unless call sites are updated to set `run.enforceFinalTag` for those providers, this alters behavior and will likely cause test failures or incorrect output parsing for providers that rely on `<final>` tags. - src/auto-reply/reply/agent-runner-utils.ts, src/auto-reply/reply/get-reply-run.ts, and any tests/logic relying on isReasoningTagProvider-based enforcement (e.g. src/auto-reply/reply/agent-runner.reasoning-tags.test.ts) <!-- greptile_other_comments_section --> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs