Skip to content

fix(llm): record breaker health on every task path - #313

Merged
BaaRai merged 1 commit into
mainfrom
fix/task-llm-health-badge
Nov 18, 2026
Merged

BaaRai merged 1 commit into
mainfrom
fix/task-llm-health-badge

Conversation

@BaaRai

@BaaRai BaaRai commented Nov 18, 2026

Copy link
Copy Markdown
Owner

The /system/llm/ badge read llm_profile_health, which only the failover Pool wrote. Three task paths call the provider directly and never reported anything:

  • an explicit task chain (providerForProfile),
  • a bound agent with failover off (the default),
  • the global provider (the default task form sends no chain).

So a dead backend stayed Healthy, including on a single-profile install.

This replaces the report in #257 with a clean implementation. The policy lives once in llmpool.Registry.RecordCall, and the Pool uses it too, so a profile's state no longer depends on which path the request took:

  • success clears the state,
  • a failover-eligible failure trips it,
  • context cancellation and deterministic 400s are ignored on a stream, and a 400 clears an atomic call, matching the Pool,
  • a stream that already delivered output is left alone, because the Pool does not fail over there.

The selection carries healthProfileID (separate from profileID, which keeps its chain semantics), and a provider already wrapped in the Pool reports nothing, so nothing is counted twice. Every physical attempt is reported, retries included.

The LLM recording page also stops looking broken when the toggle is off: the empty state explains it once the settings call has resolved, without flashing the wrong copy.

Tests cover the policy (llmpool/health_record_test.go) and the wiring (server/task_llm_health_test.go): success, atomic 400, stream 400, cancel, committed stream failure, a retried pre-commit failure per attempt, pool parity, and the healthProfileID 0 no-op.

Credit for the report: @aminasoussi1986-creator in #257.

The /system/llm/ badge read llm_profile_health, which only the failover
Pool wrote. A task pinned to an explicit chain, a bound agent with
failover off, and the global provider all call the provider directly, so
a dead backend stayed "Healthy".

One policy now lives in llmpool.Registry.RecordCall, used by the Pool and
by the task runtimes: a success clears the state, a failover-eligible
failure trips it, context cancellation and deterministic 400s do not, and
a stream that already delivered output is left alone. The selection
carries the profile whose breaker the call updates, and a provider
already wrapped in the Pool reports nothing to avoid double counting.

The LLM recording page also explains an empty list while the llm_record
toggle is off, after the settings call resolves.

Originally reported in #257.
@BaaRai
BaaRai merged commit ac5e714 into main Nov 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant