openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

fix(observability): classify 'does not support tools' provider 400 as user-state (Sentry TAURI-RUST-35 + 9 siblings)

Open CodeGhost21 opened this issue 6 months ago • 1 comments

Summary

Add "does not support tools" to is_provider_config_rejection_message's PHRASES array (src/openhuman/inference/provider/config_rejection.rs). The user picks a model that doesn't implement tool calling, the agent harness sends a tool spec anyway, and the upstream rejects with {"error":{"message":"<model id> does not support tools","type":"invalid_request_error",…}}. Pure user-config — Sentry has no actionable path.

Why this drops 10 Sentry issues, not 1

Because the rejection message includes the literal model id, each (provider prefix × model id) combination produced a distinct Sentry fingerprint. The same root cause is currently split across 10 unresolved Sentry issues totalling ~458 events (snapshot 2026-05-28):

shortId events provider prefix
TAURI-RUST-35 307 cloud (gemma3:1b-it-qat)
TAURI-RUST-DF 83 cloud
TAURI-RUST-123 25 cloud
TAURI-RUST-4K7 19 ollama
TAURI-RUST-4FS 10 cloud
TAURI-RUST-4F6 5 cloud
TAURI-RUST-2YA 4 cloud
TAURI-RUST-4KR 3 ollama
TAURI-RUST-4KH 1 cloud
TAURI-RUST-4KY 1 ollama

Anchor token: the exact substring "does not support tools". It's stable across every observed wrapper shape (cloud / ollama / custom_openai × streaming API error / API error) and every observed model id, so a single phrase covers the whole long tail — and any future model that hits the same upstream rejection class.

The matcher upstream is already case-insensitive (body.to_ascii_lowercase() before substring search), so capitalisation variants are covered for free.

Tests added (provider::config_rejection::tests)

  • detects_does_not_support_tools_family — 4 verbatim wire shapes: TAURI-RUST-35 (cloud, gemma3), TAURI-RUST-4K7 (ollama prefix), the non-streaming API error sibling, and a bare body without the wrapper.
  • does_not_classify_unrelated_tools_phrases_as_config_rejection — polarity guard pinning near-miss phrases that must STILL escalate to Sentry (real tool execution failures, generic "tools" mentions like "agent ran with 0 tools available", reversed phrasing like "supports tools but received malformed tool_calls").

Test plan

  • [x] cargo test detects_does_not_support_tools_family — passes (4 wire shapes)
  • [x] cargo test does_not_classify_unrelated_tools_phrases — passes (polarity)
  • [x] cargo test config_rejection — 8 tests pass, 0 regressions
  • [x] cargo check --manifest-path Cargo.toml --bin openhuman-core — passes
  • [x] cargo fmt --check — clean

Post-merge observation: all 10 listed Sentry issues should drop to ~0 events on releases ≥ this fix. Any new "does not support tools" event on a newer release means the matcher missed a wrapper variant — investigate the wire shape, not the model id.

CodeGhost21 avatar May 27 '26 21:05 CodeGhost21

[!CAUTION]

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5ecd00a6-c923-4f2c-bebc-796717bd9131

📥 Commits

Reviewing files that changed from the base of the PR and between 85cc3e67a0455ecee7107137b01de1b3ccacfc48 and deb82ab138ea8e8e065d696b5e75e24a34aa2479.

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

📝 Walkthrough

Walkthrough

Extended is_provider_config_rejection_message to classify upstream responses containing the exact substring "does not support tools" as provider config-rejections, and added unit tests covering positive and negative tool-related message variants across wrapper shapes and providers.

Changes

Provider Config Rejection Classifier Enhancement

Layer / File(s) Summary
Tool-calling capability rejection detection
src/openhuman/inference/provider/config_rejection.rs
Added exact "does not support tools" substring match to is_provider_config_rejection_message to detect tool-calling model capability-mismatch responses.
Positive tests for TAURI-RUST-35 family
src/openhuman/inference/provider/config_rejection.rs
New unit test detects_does_not_support_tools_family validates matches across streaming, non-streaming wrappers and bare extracted bodies containing the substring.
Negative tests for unrelated/near-miss tools phrases
src/openhuman/inference/provider/config_rejection.rs
New unit test does_not_classify_unrelated_tools_phrases_as_config_rejection verifies generic mentions, near-miss phrasing, dispatch failures, malformed payload contexts, and empty body do not match.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • tinyhumansai/openhuman#2830: Updates to is_provider_config_rejection_message and test fixtures for TAURI-RUST / thinking-mode / Ollama-related message shapes.
  • tinyhumansai/openhuman#2813: Earlier change extending deterministic phrase-matching for "tools not supported" 400-body shapes with tests.
  • tinyhumansai/openhuman#2239: Related work wiring the config-rejection classifier into observability/ops handling.

Suggested labels

Sentry-traced-bug, sentry-traced-bug

Suggested reviewers

  • oxoxDev
  • M3gA-Mind

Poem

🐰 I sniffed the logs and found the clues,
"does not support tools" — no more confused news,
Tests hop in for wrappers and bare,
Near-miss phrases get left in the air,
Hooray — mismatch messages handled with care!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding classification for 'does not support tools' provider errors as user-state signals for observability/Sentry issue tracking.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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[bot] avatar May 27 '26 21:05 coderabbitai[bot]

Actionable comments posted: 0

coderabbitai[bot] avatar May 28 '26 12:05 coderabbitai[bot]