fix(agent): suppress empty-provider-response from Sentry (TAURI-RUST-4JX)
Summary
- Add
AgentError::EmptyProviderResponse { iteration }and routeagent::harness::session::turn's empty-final-response bail through it, so the existing user-facing string is preserved while the typed variant flows up torun_single. - Centralise the "skip Sentry" decision behind a new
AgentError::skips_sentry()method covering bothMaxIterationsExceededand the new variant;run_singlecalls it in place of the inlineMaxIterationsExceeded-only check. - Keeps Sentry TAURI-RUST-4JX off the radar (~33 events, escalating on 0.56.0) without changing the user-visible error or the
AgentError/recoverablesemantics.
Why
Latest event payload: Windows user, LM Studio at http://localhost:1234, custom community fine-tune (qwen3.6-27b-heretic-uncensored-finetune-neo-code-di-imatrix-max). Provider response is text_chars=0 thinking_chars=0 tool_calls=0 in 60 ms — completely empty. agent/harness/session/turn.rs:805 then returned:
return Err(anyhow::anyhow!(
"The model returned an empty response. Please try again."
));
That bubbled to run_single (agent/harness/session/runtime.rs:540), which routes anything other than AgentError::MaxIterationsExceeded through report_error_or_expected("agent", "run_single", …) → Sentry. The result is the same shape as OPENHUMAN-TAURI-99 / -98 (max-iter cap) before that fix: user-state outcome shipped to Sentry as a code-bug.
It's not actionable from Sentry (the user picked a flaky local model), the UI already surfaces the user-facing message, and the deeper "fix" lives in the user's model / provider config. Same call for suppression as the max-iter cap.
What changed
src/openhuman/agent/error.rs— new variantEmptyProviderResponse { iteration: usize }with aDisplayarm that emits the verbatim user-facing string (so UI surfaces and any external grep/fingerprint contracts hold). Newskips_sentry(&self) -> boolmethod as single source of truth for the suppressed set: today{ MaxIterationsExceeded, EmptyProviderResponse }.src/openhuman/agent/harness/session/turn.rs:805— replace anonymousanyhow::anyhow!withAgentError::EmptyProviderResponse { iteration: iteration + 1 }.into(). Warn-level breadcrumb that recorded the surfacing decision is preserved.src/openhuman/agent/harness/session/runtime.rs:540— replacelet is_max_iter = matches!(err.downcast_ref::<AgentError>(), Some(AgentError::MaxIterationsExceeded { .. }))witherr.downcast_ref::<AgentError>().is_some_and(AgentError::skips_sentry). Log message generalised to "user-state agent error". Comment updated.src/openhuman/agent/harness/session/runtime.rs:388(sanitize_event_error_message) — new arm returning"empty_provider_response"for the Sentryerror_kindtag (required by the non-exhaustive match).src/openhuman/cron/scheduler.rs:37(agent_error_to_user_message) — new arm returning actionable canned copy: "The model returned an empty response. Try a different model or check your local provider in Settings → AI → LLM." Required by the same non-exhaustive contract; gives cron job failures a useful message instead of the generic fallback.
Tests added (agent::error::tests)
empty_provider_response_display_matches_user_facing_string— locks the wire shape against accidental message changes (also a Sentry-fingerprint stability guarantee).skips_sentry_returns_true_for_known_user_state_variants—MaxIterationsExceeded+EmptyProviderResponse.skips_sentry_returns_false_for_real_failures— covers all 7 other variants (ProviderError,ContextLimitExceeded,ToolExecutionError,CostBudgetExceeded,CompactionFailed,PermissionDenied,Other); any future variant that should also suppress must be added toskips_sentry()and this test, both at once.
Test plan
- [x]
cargo test openhuman::agent::error::tests— 9 tests pass (4 new) - [x]
cargo test openhuman::agent— 751 tests pass, 0 regressions - [x]
cargo test openhuman::cron::scheduler— 50 tests pass, 0 regressions - [x]
cargo check --manifest-path Cargo.toml --bin openhuman-core— passes - [x]
cargo fmt --checkon touched files — clean
Post-merge observation: TAURI-RUST-4JX should drop to ~0 events on the next release. The variant still produces structured log::info! lines locally for diagnosability, so a real spike will still be visible in shipped logs (just not in Sentry).
This change introduces typed error classification for degenerate provider responses (no text, no thinking, no tool calls). A new Empty Provider Response Error Handling 🎯 3 (Moderate) | ⏱️ ~25 minutes 🐰 A response that's empty brings tears to the try, ✏️ Tip: You can configure your own custom pre-merge checks in the settings.📝 Walkthrough
Walkthrough
AgentError::EmptyProviderResponse variant with iteration metadata is detected in turn execution, routed through telemetry via a skips_sentry() helper to separate it from true failures, and mapped to user-facing messages in scheduler notifications.Changes
Layer / File(s)
Summary
Error Type and Observability Contract
src/openhuman/agent/error.rsAgentError::EmptyProviderResponse { iteration } variant is added with documentation, Display formatting outputs "The model returned an empty response. Please try again.", and a new public method skips_sentry() returns true for this variant and MaxIterationsExceeded, false otherwise. Tests verify the exact display string and skips_sentry() behavior for suppressed and real-failure variants.
Turn-Level Detection and Error Creation
src/openhuman/agent/harness/session/turn.rsThe empty provider-response failure path returns a typed
AgentError::EmptyProviderResponse { iteration: iteration + 1 } instead of a generic anyhow error, enabling type-safe observability downstream.
Telemetry and Event Routing
src/openhuman/agent/harness/session/runtime.rssanitize_event_error_message adds a match arm to classify EmptyProviderResponse as "empty_provider_response". run_single generalizes Sentry suppression logic by calling skips_sentry() on the downcast error; when true, it emits structured log::info! instead of reporting through Sentry.
User-Facing Message Mapping
src/openhuman/cron/scheduler.rsagent_error_to_user_message adds a case for AgentError::EmptyProviderResponse, returning a static notification message indicating the model returned an empty response.Estimated code review effort
Possibly related PRs
Suggested labels
agent, bug, workingSuggested reviewers
Poem
So we typed it, we routed it, gave users a why.
No Sentry alarms for the model's misstep,
Just logged info softly, with empathy's rep! 🌙🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name
Status
Explanation
Title check
✅ Passed
The title accurately summarizes the main change: adding a new error variant and suppressing it from Sentry reporting, which is the core objective of the PR.
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.
Description Check
✅ Passed
Check skipped - CodeRabbit’s high-level summary is enabled.
Comment @coderabbitai help to get the list of available commands and usage tips.