openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Budget-exhausted on main chat surfaces as 'empty response' instead of typed budget error

Open CodeGhost21 opened this issue 5 months ago • 1 comments

Summary

When the OpenHuman cloud inference budget is exhausted, the main chat call can still surface as a generic "model returned an empty response, try a different model" instead of the actionable budget-exhausted copy added by #3121 — sending the user toward the wrong remediation (swap model / check local provider) when the real fix is "top up credits, or switch routing to a local model".

Problem

Sentry issue TAURI-RUST-4JX (5219 on the self-hosted Sentry, domain=agent operation=run_single, channel=web_channel) has 2623 events from a single user on release [email protected]+e8968077aeb5. The Sentry suppression from #2790 lands in ≥ v0.57.4 so the noise will stop on its own — this issue is about the underlying user-experience bug those events represent.

Latest event breadcrumbs (2026-06-04 15:19:15Z, abridged):

15:19:12.866  [llm_provider] api_error budget-exhausted 400 — not reporting to Sentry  (provider=inference:summarization-v1)
15:19:12.868  [tree_global::digest] summarise failed … {"success":false,"error":"Insufficient budget"} — using fallback
15:19:14.133  [llm_provider] api_error budget-exhausted 400 — not reporting to Sentry  (provider=inference:summarization-v1, retry)
15:19:14.134  [memory_tree::extract::llm] chat provider=inference:summarization-v1 failed … Insufficient budget
15:19:15.005  [stream]      OpenHuman aggregated text_chars=0 thinking_chars=0 tool_calls=0
15:19:15.005  [agent_loop]  provider response i=1 elapsed_ms=341 text_chars=0 native_tool_calls=0
15:19:15.007  [agent_loop]  provider returned an empty final response (i=1, …) — surfacing as error

The two budget-exhausted 400s in the seconds before the chat call are inference:summarization-v1 (memory tree background work), but the main chat completion then finishes in 341 ms with text_chars=0 thinking_chars=0 tool_calls=0 — fast enough to be a backend rejection, but no [llm_provider] … budget-exhausted 400 breadcrumb fires for it. The agent loop bails at src/openhuman/agent/harness/engine/core.rs:394-405 with AgentError::EmptyProviderResponse, which renders to the user-facing string "The model returned an empty response. Please try again." from src/openhuman/agent/error.rs:92-97.

Two ways the main chat call can hit this:

  • (a) It received a 400 + {"success":false,"error":"Insufficient budget"} like the summarization path did, but the streaming code path in src/openhuman/inference/provider/compatible.rs (one of the callsites around lines 287 / 849 / 1377 / 1886 / 2053 / 2213) didn't run is_budget_exhausted_http_400 / log_budget_exhausted_http_400 before collapsing the stream into an empty OpenHuman aggregated text_chars=0 log. The classifier comment at compatible.rs:498-505 already calls this out: "That 400 streams back as an empty completion, which the agent loop collapses to 'The model returned an empty response'…"
  • (b) The OpenHuman backend served the main chat call as 200 + empty stream under budget exhaustion (only summarization hit 400). In that case the classifier has no per-call signal to disambiguate "budget" from "real empty completion", and the empty_response arm from #3199 fires by default.

Either way, the user-visible outcome on a budget-exhausted account is the wrong remediation: PR #3199 directs them to switch models / check local provider in Settings → AI → LLM, when PR #3121's budget-exhausted top-up-or-switch-routing copy is what should fire.

Version / platform: Reproduced on [email protected]+e8968077aeb5, Windows 10 26200, channel=web_channel. Should also be reproducible on current main because PR #3199's empty_response arm wins by default when no budget signal reaches the classifier on the main chat path.

Steps to reproduce:

  1. Use an OpenHuman backend account with depleted inference budget ({"success":false,"error":"Insufficient budget"} returned on POST to the inference proxy).
  2. Send any user message in the web-channel chat.
  3. Observe the chat surface returns "model returned an empty response, try a different model" / "check local provider" instead of the budget-exhausted top-up / routing-switch copy.
  4. Sentry side: prior to v0.57.4, the agent run also publishes a TAURI-RUST-4JX event for every retry the user makes.

Solution (optional)

Two pieces, depending on what the live repro shows:

  1. Confirm path (a) or (b) — add a debug log on the main chat code path that records the HTTP status + first ~200 bytes of body when the aggregated stream comes out empty. If status is 400 + Insufficient budget, then a log_budget_exhausted_http_400 callsite is being bypassed and the fix is wiring detection into the streaming aggregation path. If status is 200 + empty, then the backend needs to either start returning 400 under budget exhaustion (server-side fix) or the client needs a within-session correlator (e.g., if summarization-v1 has been hitting budget-exhausted in the last N seconds, classify a same-session empty chat completion as budget_exhausted rather than empty_response).
  2. Tighten the classifier ordering — classify_inference_error in src/openhuman/channels/providers/web_errors.rs currently does first-match-wins on substrings. Adding a "recent budget-exhausted signal" check that's evaluated before the empty_response arm would let the existing #3121 copy win in the same-session case from (b) without changing semantics for users who actually got an empty model output.

Whichever path turns out to be live, the user-facing assertion is: a single contiguous chat turn whose preceding memory/summarization calls just hit budget-exhausted 400s must not surface as "empty response, try a different model" — the user is two clicks from the actionable budget remediation and we're sending them in the opposite direction.

Acceptance criteria

  • [ ] Repro gone — On a budget-exhausted test account, sending a chat message surfaces the PR #3121 budget-exhausted copy (top up / switch routing) on the main chat path, not the #3199 empty_response copy.
  • [ ] Regression safety — Unit coverage for classify_inference_error (or its successor) under (i) main-chat 400 + Insufficient budget body, and (ii) main-chat 200 + empty stream with a recent same-session budget-exhausted summarization 400. Both must classify as budget_exhausted.
  • [ ] Diff coverage ≥ 80% — fix PR meets the changed-lines coverage gate.
  • [ ] Sentry stays quiet — TAURI-RUST-4JX and the web-channel re-report TAURI-RUST-4Z1 should not regress; the existing AgentError::skips_sentry() (#2790) and observability::is_empty_provider_response_message classifier paths must continue to fire if any chat-side empty response slips through.

Related

  • Sentry: TAURI-RUST-4JX (https://sentry.tinyhumans.ai/organizations/tinyhumans/issues/5219/) — 2623 events / 1 user / v0.56.0.
  • #2790 — agent-side Sentry suppression (AgentError::skips_sentry()), ships in ≥ v0.57.4.
  • #3121 — budget-exhausted classifier arm + actionable top-up / switch-routing copy.
  • #3199 — empty_response / provider_request_rejected / capability_unsupported classifier arms (this is the arm that currently wins on the chat side when budget is the underlying cause).
  • #2935 — earlier Sentry-noise complaint that drove the suppression work.
  • #3092 — closed "Something went wrong" surface (resolved by #3199).

CodeGhost21 avatar Jun 04 '26 19:06 CodeGhost21

Status / parity check — classifier infra present, the two named gaps remain (~30%)

The error-classification scaffolding this depends on is on main: classify_inference_error, a budget_exhausted arm, and is_budget_exhausted_http_400 detection (alongside #3199's empty-response arm and #3121's budget copy). Direct 400 budget responses on non-streaming paths are detectable.

What's remaining are exactly the two paths this issue calls out, both still open:

  1. Streaming aggregation — the streamed-empty path collapses to "empty response" without running budget detection first.
  2. No session correlator — the empty-response arm fires before any budget check, and there's no same-session "recent budget-exhausted signal" to reclassify a budget-caused empty turn. So a budget exhaustion on main chat still surfaces the generic empty-response copy instead of the typed budget error.

Acceptance criteria aren't met yet. Keeping open.

oxoxDev avatar Jun 05 '26 12:06 oxoxDev