Skip to content

Release 0.8.17 review, rounds 2 and 3: outages at ERROR in every phase, widget timeout and network text, test gaps - #589

Merged
neuromechanist merged 24 commits into
developfrom
fix/release-0.8.17-review-2
Oct 7, 2026
Merged

neuromechanist merged 24 commits into
developfrom
fix/release-0.8.17-review-2

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Fixes from rounds 2 and 3 of the release review of #585 (four reviewers each round: code, error handling, tests, comments, on the Sonnet model), applied before the release.
Refs #578, #582, #587.

Round 2 checked each round 1 fix (#588) and looked for what the fixes introduced; round 3 did the same for round 2's.
No critical or high findings in either round; every finding is below, fixed or answered.

Round 2: what the review found, and what changed

  • An outage before the response began never reached ERROR (medium).
    Round 1 made a stream cut short an ERROR but left the same outage at WARNING when it came as a 503 before the response, or as a read that timed out, so an alert on ERROR saw only some of an outage's requests.
    A provider's unavailable, connection and timeout failures now log at ERROR in every phase of the call, with the traceback only where a retry would have covered it.
    Throttles and the caller's own refused key stay WARNING.
  • A stream the reader closes was retried.
    A failure that surfaced as the reader closed the stream (GeneratorExit at the yield) started a second model call that nobody would read; the helper now notes the close and re-raises.
  • classify_model_error could raise inside the handlers that report a failure, which would cut the stream with no error event, log line or metrics row.
    It now returns "unknown" and logs why.
  • The widget did not recognize its own request timeout.
    AbortSignal.timeout aborts with a TimeoutError, not an AbortError, so a stalled request showed the browser's own text in the banner.
  • The CLI's error printers raised on a message that was not a string, and a corrupt cost (1e305) filled the usage line; both now cope, and a cost of a billion dollars or more is shown as no cost by the CLI and the widget.
  • The bad-usage log lines read "(: ..." for a check on the whole object, and a negative count that also made the cost negative was logged as a price table defect (ERROR); they now say "usage", and any count problem is the provider's (WARNING).
  • Tests (from the test reviewer's mutation work): log level and traceback per phase, whose key says "your API key", the cancel log's session, an Anthropic stream lost inside the SDK's own httpx retried end to end, a wrapped error placed by its cause, the cost line's half-up rounding and tier edges in the table both languages read, a 60 s deadline on every streamed turn so a retry loop fails instead of hanging CI, and botocore's backoff sleep skipped (the file runs in about 10 s instead of 29 s).

Round 3: what the review found, and what changed

  • A model failure that landed as the reader left was logged only by asyncio ("Task exception was never retrieved", with no request context).
    The helper now logs it with the endpoint, model, request and session.
  • A task canceled while the model's stream was open could be retried.
    The stream's own failure can replace the CancelledError, which the helper then treated as an ordinary failure; it now checks the task's cancelling() count too.
    (Under Starlette's cancel scopes the retry's sleep would have raised it again, so production was safe; a plain task.cancel() was not.)
  • The widget showed Safari's "Load failed" and Chrome's "network error" as the browsers worded them; a TypeError with a known network wording now reads "Network error. Please check your connection."
    Other TypeErrors, and errors of other kinds, keep their text.
  • The CLI printed "Error: None" for a null server message; it now says "Unknown error" or "Unknown warning".
  • An error whose text could not be printed dropped the failure line (and the reader's error id matched nothing) and cut the stream in the ValueError branches.
    The failure line, the retry line and those messages now use exception_text.
  • One unreadable link aborted the classifier's cause walk, so a throttle behind an unreadable wrapper came out unknown; each link is now classified on its own, and an unclassifiable error is logged once however many handlers classify it.
  • The _stream_failure_event docstring contradicted itself (the list after the colon were the cases that do get a traceback), after_retry's and the needs_traceback comments described the wrong effect, and the cost cutoff's comment gave the wrong reason; all corrected.
  • The changelog and this release's description said an outage "was logged as an error only for a reply that used no tool" (before this release it was always a warning), described the widget's timeout text wrongly (the banner says "Request timed out. Please try again."; "Connection timeout" is added only to a reply that had text), claimed the CLI always shows the unavailable message at the server's read timeout (its own 120 s timeout ends at about the same moment), and said "above" one billion dollars where the code drops a cost at or above it.
    It also now says a model served through OpenRouter gets no retry, and that the NWB origins are exact in the community's cors_origins while the worker admits the suffix.
  • Smaller: "Cancelled." is "Canceled." in the CLI; httpx2 is called a separate package in five comments that called it vendored or a fork; the 503 tests are "error answer" tests, not "refusal" tests; a check in the outage line that its kinds already imply is gone.
  • Tests (from the test reviewer's 128 mutants): boundary rows for the one-billion-dollar cutoff, botocore's retry asserted to exist, a connection that could not be made is an outage, a second failure of another kind after a retry is an ERROR with its traceback, the new exception_text sites, the CLI fallback on all four stream paths, a failure the classifier can name but not place, and the widget's anchored network wording.

Not changed, and why

  • The redundant guards in _arrived_mid_stream (three mutants no test can tell apart, since classification screens the same errors first): the function is meant to be right on its own, and a later change to the classifier should not silently make a failure look mid-stream.
  • An OpenRouter or LiteLLM failure inside a stream is not retried: the OpenAI SDK's in-stream error has no status, so it is "unknown"; a design boundary the docstring and changelog now state.
  • An exhaustive committed check of the formatters over all 3,000,001 values: it was a one-off script; the table holds the cases where the rounding differs, which is what would catch a regression.
  • A real-graph version of the stream-close test: the failure has to land while the reader is between events, which depends on thread scheduling, so it can only be made with sleeps; the stand-in makes that moment certain and its docstring says why.
  • The worker's error.name === 'AbortError' check next to AbortSignal.timeout (workers/osa-worker/index.js): it has the same shape as the widget's bug, but its error.message.includes('timeout') fallback is expected to catch the case (not verified), and the worker is outside this release's changes.
  • frontend/test-widget-paced-streaming.js "the reader saw the reply grow through N different lengths" failed once in six runs under 56 busy processes on this machine; it is on develop already and unrelated to this branch.

Testing

The Python suites (tests/test_api, test_metrics, test_cli, test_core, test_frontend) and all 23 widget suites pass.
That run leaves out test_chat_resume_endpoint.py: 19 of its 21 tests fail with 401 identically on a clean develop here (they did before this branch).
Each new assertion was shown to fail against a mutant of the code it guards.

It runs inside the handlers that report a failure, so an exception from it cut
the stream with no error event, log line or metrics row. An error it cannot read
is now unknown and the reason is logged. Also corrects the wording of three
comments about the httpx fork the Anthropic SDK depends on, and the throttle
reasoning in worth_retrying_now.

Tested: tests/test_core/test_model_errors.py (new TestItNeverRaises cases).
A failure that surfaced as the stream was closed (GeneratorExit at the yield)
started a second model call nobody would read. The retry helper now notes the
close and re-raises. Also spells canceling the American way in a test name.

Tested: new TestTheReaderClosesTheStream fails without the guard and passes with it.
…st both fail

A check on the whole object has no field, so its line read "(: ..."; it now says
"usage". Counts that also make the cost invalid are the provider's, so they log
at WARNING, and only a cost-only failure (a price table defect) logs at ERROR.

Tested: tests/test_api/test_reply_usage.py (TestWhatTheOperatorReads).
An outage before the response began, or a read that timed out, was a WARNING
while the same outage mid-stream was an ERROR, so an alert on ERROR saw only
some requests. Unavailable, connection and timeout failures from a provider are
now ERROR (without a traceback unless a retry would have covered it); throttles
and the caller's own refused key stay WARNING.

Tested: tests/test_api/test_stream_failures.py asserts the level per phase.
The CLI and the widget printed any finite cost; a corrupt figure (1e305) filled the
line. Both now treat a cost at or above one billion dollars as no cost. The CLI's
print_error and print_warning also accept a message that is not a string.

Tested: shared table row in tests/fixtures/usage_lines.json (Python and widget),
print_error(None) in tests/test_cli/test_main.py.
AbortSignal.timeout aborts with a TimeoutError, not the AbortError the widget
checked for, so a stalled request fell through to the generic failure text. Both
names now read as the request timeout, streamed and not streamed.

Tested: new block in frontend/test-widget-paced-streaming.js (287 checks pass).
Without the half-up step, 31 of the 3,000,001 whole micro-dollar values print
differently, and none was in the shared table. Adds rows for three of them and for
the edges at $0.0001, $0.01 and $1.

Tested: Python and widget suites; mutants without the half-up step and with the
under-$0.0001 edge moved fail both.
classify_model_error reads mid_stream from the error it found, not the wrapper;
no test would have noticed the wrapper being read instead.

Tested: the new case fails with the wrapper read and passes as written.
Tested: tests/test_api/test_reply_usage.py; the any-for-all mutant fails.
…lure tests

- log level and traceback of a failure that was worth a retry but came too late or
  after a tool, and of an OpenRouter outage before the response
- a community key's throttle is not called the reader's, and another failure on
  the reader's key is not called a throttle
- the cancel log names the session
- an Anthropic stream lost inside the SDK's own httpx is retried end to end
- every streamed turn has a 60 s deadline so a retry loop fails instead of
  hanging, and the cancel tests poll for 30 s
- botocore's backoff sleep is skipped (the file ran 29 s and now runs about 10 s;
  the requests are still made and counted)

Tested: tests/test_api/test_stream_failures.py, 121 pass; each new assertion fails
against a mutant of the code it guards.
Outage logging at ERROR in every phase, the widget's own request timeout, the
CLI and cost hardening, the classifier that cannot raise, and the stream the
reader closes. Docs only; the code and tests are in the commits before it.
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://fix-release-0.8.17-review-2-demo.osc.earth
Branch fix/release-0.8.17-review-2
Commit 403ded5

This preview will be updated automatically when you push new commits.

…try a canceled task

A failure that landed as the reader closed the stream was re-raised into a task nobody
awaits, so the only trace was asyncio's "Task exception was never retrieved" with no
request context; the helper now logs it with the endpoint, model, request and session.
A task canceled while the model's stream is open can end in the stream's own failure
in place of the CancelledError; the helper treated that as an ordinary failure and
retried. It now checks the task's cancelling() count as well as the close.

Tested: two new tests in TestTheReaderClosesTheStream; each fails without its guard.
… error once

One unreadable link (a wrapper whose __str__ raises) aborted the walk, so a readable
cause behind it (a throttle) came out unknown. A failure to say where a failure came
from discarded a known kind. The handlers that each classify one failure also logged an
unclassifiable one once each; it is now logged once per exception. Adds exception_text,
str() with a placeholder, for the log lines that report a failure. Also states that the
errors OpenRouter raises in a stream carry no status, instead of "never" marked.

Tested: tests/test_core/test_model_errors.py; the dedupe and the per-link isolation each
fail a test without them.
…ep a traceback

The docstring's colon list named the cases that get a traceback but read as examples of
the exception, omitted the caller's-key throttle wording, and ended in a ragged line;
after_retry keeps the traceback rather than raising the level, and the comment above
needs_traceback described the level. Comments only.
A __str__ that raises dropped the logging module's line (it prints "--- Logging error
---" and moves on), leaving the reader's error id matching nothing, and cut the stream in
the ValueError branches that put str(e) in the message. The failure line and those
messages now carry exception_text.

Tested: new test in tests/test_api/test_stream_failures.py; fails with the raw error in
the line.
data.get("message", default) keeps an explicit null, so the CLI printed "Error: None".
Also lets the error and warning printers take a message that is not a string.

Tested: two new stream tests in tests/test_cli/test_main.py; both fail with the old
fallback.
Tested: tests/test_cli (the config reset test reads the message).
The comment said Python's integer arithmetic could not take a larger cost, which is not
so; the cutoff keeps the CLI and the widget printing the same digits. Comment only.
… languages

Only a 1e305 row covered the cutoff, so moving it by one step passed. Rows for just under
it and for exactly it.

Tested: a <= mutant fails the Python and the widget suite.
…the browser

Only a TypeError that mentions "fetch" was taken for a network failure, so Safari's
"Load failed" and "The network connection was lost." and Chrome's "network error"
(a body read cut short) reached the banner as the browsers worded them. A TypeError that
matches the known wordings now reads "Network error. Please check your connection."; other
TypeErrors and errors of other kinds keep their text. Also states in the timeout helper's
comment only what is known: the widget aborts a request only by its own timeout.

Tested: new block in frontend/test-widget-paced-streaming.js (295 checks pass); the old
fetch-only check and a check that ignores the error's kind each fail it.
The earlier-warning sentence was wrong (an outage was always a warning before this
release); what the widget shows for its own timeout is the banner, plus "Connection
timeout" only on a reply that had text; the CLI's own 120 s timeout may win; a cost at or
above one billion is dropped; the OpenRouter boundary of the retry; the null CLI message,
the network wording and the cancel guard; the NWB origins are exact in the community's
cors_origins while the worker admits the suffix. Docs only.
…e, tidy test text

The Anthropic SDK depends on the published httpx2 package (anthropic 1.6.0 requires
httpx2>=2.0), which the comments called a vendored copy or a fork. A 503 or 500 answer
before the response is an error answer, not a refusal (a refusal is a 4xx the request
caused). The OpenRouter 5xx test said the client's own retries cover it, which its own
request count contradicts; the redundant 30 s wait_for in one test goes, since every
streamed turn has a deadline. Comments, test names and ids only.

Tested: the four touched test files, 246 pass.
The "Retrying ..." warning put the raw error in the log line, so an error whose __str__
raises dropped it (and, under a handler that raises, ended the stream instead of
retrying). It now uses exception_text, as the failure line does. Also drops a check in
the outage test that the kinds it names already imply.

Tested: new test in the next commit.
- botocore's retry of a refused request is asserted to exist, not only to equal itself
- a connection that could not be made is an outage (ERROR)
- a second failure of another kind after a retry is an ERROR with its traceback
- the retry line and the ValueError branches survive an error that cannot print
- the CLI's null message fallback for all four stream paths
- a failure the classifier can name but not place keeps its kind and is not retried
- the widget's network wording is anchored
- the close stand-in's docstring says what it is for

Tested: each new test fails against a mutant of the code it guards; 455 pass in the
touched Python files and 296 widget checks pass.
@neuromechanist neuromechanist changed the title Release 0.8.17 review, round 2: outages at ERROR in every phase, widget timeout, test gaps Release 0.8.17 review, rounds 2 and 3: outages at ERROR in every phase, widget timeout and network text, test gaps Oct 7, 2026
@neuromechanist
neuromechanist merged commit 4791753 into develop Oct 7, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the fix/release-0.8.17-review-2 branch October 7, 2026 04:04
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