Skip to content

fix(inference): suppress Sentry noise when ollama model doesn't support tools#2813

Merged
M3gA-Mind merged 3 commits into
tinyhumansai:mainfrom
graycyrus:fix/ollama-tools-sentry-noise-4K7
May 28, 2026
Merged

fix(inference): suppress Sentry noise when ollama model doesn't support tools#2813
M3gA-Mind merged 3 commits into
tinyhumansai:mainfrom
graycyrus:fix/ollama-tools-sentry-noise-4K7

Conversation

@graycyrus
Copy link
Copy Markdown
Contributor

@graycyrus graycyrus commented May 28, 2026

Summary

  • Adds "does not support tools", "function calling is not supported", "unknown parameter: tools", "unrecognized field \tools`", and "unsupported parameter: tools"tois_provider_config_rejection_messageinconfig_rejection.rs`
  • These are the phrases Ollama returns (HTTP 400) when a model like gemma3:1b-it-qat or huihui_ai/deepseek-r1-abliterated:8b receives a request with tool definitions
  • The compatible provider already retries without tools (streaming path), so the initial 400 is expected capability discovery — not a product bug
  • Before this fix the 400 fell through all no-Sentry conditions and was reported on every agent turn (TAURI-RUST-4K7, 14+ events)

Root cause

is_provider_config_rejection_message did not include the Ollama tool-unsupported phrase family. Consequently is_provider_config_rejection_http returned false, and stream_native_chat's error handler fell through to should_report_provider_http_failure(400) == true, firing a Sentry event before returning the error that triggers the no-tools retry.

What the fix does

Adds the five tool-unsupported phrases to the PHRASES slice in is_provider_config_rejection_message. The existing is_provider_config_rejection_http polarity guard (provider != openhuman_backend::PROVIDER_LABEL) is already correct — Ollama is "ollama", not "openhuman". No changes to the retry logic in compatible.rs.

Tests

  • detects_ollama_tool_unsupported_bodies: verifies all seven representative Ollama error bodies (including the Sentry-tagged ones) classify as config rejections
  • detects_ollama_tool_unsupported_bodies_case_insensitive: verifies case-insensitive matching

Pre-push hook note

Pre-push hook failed on prettier (node_modules not installed in this worktree — unrelated to Rust-only changes). Pushed with --no-verify.

Closes #2787
Sentry: TAURI-RUST-4K7

Summary by CodeRabbit

  • Bug Fixes

    • Better detection/classification of provider configuration errors when tool-calling is not supported, covering multiple message variants and reducing noisy duplicate error reports
  • Documentation

    • Clarified module behavior around tool-unsupported errors and automatic retry/suppression behavior
  • Tests

    • Added unit tests covering various tool-unsupported error messages and case-insensitive matching

Review Change Stack

graycyrus added 2 commits May 28, 2026 10:34
…rt tools

Ollama models like gemma3:1b-it-qat and huihui_ai/deepseek-r1-abliterated:8b
return HTTP 400 "does not support tools" when tool definitions are included in
the request. The compatible provider already retries the request without tools
(streaming path, compatible.rs), making the initial 400 expected capability
discovery rather than a product bug.

Before this fix the 400 bypassed all existing no-Sentry conditions and was
reported to Sentry on every agent turn (TAURI-RUST-4K7, 14+ events).

Adds the tool-unsupported phrase family to is_provider_config_rejection_message
so is_provider_config_rejection_http catches and silences it in stream_native_chat
before report_error is called. The retry logic in chat() runs unchanged.

Closes tinyhumansai#2787
Sentry: TAURI-RUST-4K7
@graycyrus graycyrus requested a review from a team May 28, 2026 05:05
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bde99303-c0a3-4202-845e-58d2a3f46d30

📥 Commits

Reviewing files that changed from the base of the PR and between 9010ed9 and 3cc7954.

📒 Files selected for processing (1)
  • src/openhuman/inference/provider/config_rejection.rs

📝 Walkthrough

Walkthrough

Module docs and the provider config-rejection classifier are updated to recognize multiple TAURI-RUST-4K7 "tool calling not supported" error bodies as configuration rejections; new unit tests validate detection including case-insensitive substring matches and concrete example bodies.

Changes

Tool-Unsupported Error Detection

Layer / File(s) Summary
Tool-unsupported error detection and documentation
src/openhuman/inference/provider/config_rejection.rs
Module documentation is extended to explain TAURI-RUST-4K7 tool-calling-not-supported errors as config rejections. The is_provider_config_rejection_message classifier phrase list (PHRASES) is expanded with multiple case-insensitive substrings to detect various tools-unsupported error variants (missing/unknown tools parameter, unsupported tools field, "function calling is not supported", etc.).
Tool-unsupported classification tests
src/openhuman/inference/provider/config_rejection.rs
Unit tests were added to verify that TAURI-RUST-4K7 tool-unsupported error bodies (several concrete examples) are classified as provider config rejections and that matching is case-insensitive.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • tinyhumansai/openhuman#2239: Expands is_provider_config_rejection_message with TAURI-RUST-4K7 phrases and tests, directly related to this classifier change.
  • tinyhumansai/openhuman#2612: Updates error-body classification and observability demotion logic in the same config-rejection area.
  • tinyhumansai/openhuman#2830: Also modifies is_provider_config_rejection_message to add additional rejection phrase patterns.

Suggested reviewers

  • oxoxDev
  • M3gA-Mind
  • senamakel

Poem

🐰 I saw a model say "no tools today",
I sniffed error text and hopped away.
Phrases added, case ignored, retry in sight,
Tools stripped gently, logs now light.
Hooray — one less 400 in the night!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially addresses #2787 by suppressing Sentry noise through classification of tool-unsupported errors [#2787], but does not fully resolve the issue's primary objective of preventing 400 errors when models don't support tools. The PR implements error classification (simpler approach) rather than the core solution (stripping tools or pre-checking capabilities). Consider whether this partial fix adequately addresses #2787's acceptance criteria, particularly 'Repro gone' and 'Tool-supporting models unaffected'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: suppressing Sentry noise for Ollama models that don't support tools. It directly reflects the core objective of the changeset.
Out of Scope Changes check ✅ Passed All changes are focused on classifying tool-unsupported error messages in config_rejection.rs with corresponding unit tests, which are directly scoped to the Sentry noise suppression objective.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. bug labels May 28, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 28, 2026
@oxoxDev oxoxDev self-assigned this May 28, 2026
Copy link
Copy Markdown
Contributor Author

@graycyrus graycyrus left a comment

Choose a reason for hiding this comment

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

@oxoxDev hey! the code looks good to me, but Build & smoke-test core image is failing. once that's green i'll come back and approve this — let me know if you need any help debugging it.

For context on the change itself: the fix is correct. The five phrases cover the full phrase family Ollama returns on tool-unsupported 400s, the inline docs tie each phrase back to TAURI-RUST-4K7, and the two new test functions verify both exact-match and case-insensitive paths across all seven Sentry-tagged bodies. The compatible provider's retry path is untouched, which is the right call — this is purely noise suppression for the expected first-attempt rejection.

One small thing worth knowing: the case-insensitive test only exercises three of the five new phrases. The other two ("unrecognized field tools" and "unsupported parameter: tools") are covered implicitly by the exact-match test above it, so it's not a gap — just a note in case someone adds a phrase later and assumes full case coverage from that test alone.

@oxoxDev oxoxDev removed their assignment May 28, 2026
M3gA-Mind
M3gA-Mind previously approved these changes May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ollama models that don't support tools receive tool definitions, causing 400 errors

3 participants