Skip to content

Preserve provider error classification on streamed failures#38

Merged
senamakel merged 3 commits into
tinyhumansai:mainfrom
M3gA-Mind:harness/stream-error-retry-classification
Jul 8, 2026
Merged

Preserve provider error classification on streamed failures#38
senamakel merged 3 commits into
tinyhumansai:mainfrom
M3gA-Mind:harness/stream-error-retry-classification

Conversation

@M3gA-Mind

Copy link
Copy Markdown
Contributor

On the streaming path, StreamAccumulator::finish mapped ModelStreamItem::ProviderFailed to TinyAgentsError::Model, stringifying away the structured ProviderError. Since is_retryable treats Model(_) as retryable, a permanent streamed failure (401 auth, insufficient_quota, model_not_found, 400) was retried and fallback-churned as transient.

Keep the ProviderError struct in a new failed_provider slot and return TinyAgentsError::Provider from finish() so the retry layer sees status/code/retryable — matching the unary path. Unstructured Failed(String) still maps to Model. Adds tests for the streamed 401 (non-retryable) and unstructured-failure paths.

Closes tinyhumansai/openhuman#4637

StreamAccumulator::finish mapped ModelStreamItem::ProviderFailed to
TinyAgentsError::Model, stringifying away the structured ProviderError.
is_retryable treats Model(_) as retryable, so a permanent streamed
failure (401 auth, insufficient_quota, model_not_found, 400) was retried
and fallback-churned as transient. Keep the ProviderError struct in a new
failed_provider slot and return TinyAgentsError::Provider from finish() so
the retry layer sees status/code/retryable, matching the unary path.
Unstructured Failed(String) still maps to Model.
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 21 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 694661d3-1a2f-428a-915d-e0fa3d9825e0

📥 Commits

Reviewing files that changed from the base of the PR and between b1f0d82 and 73f16c3.

📒 Files selected for processing (5)
  • src/harness/model/mod.rs
  • src/harness/model/test.rs
  • src/harness/providers/openai/test.rs
  • src/harness/stream/mod.rs
  • tests/e2e_harness_provider_contracts.rs

Comment @coderabbitai help to get the list of available commands.

collapsible_if in StreamAccumulator::push_tool_chunk and a duplicated
#[cfg(test)] on the stream test module both fail CI's
cargo clippy --all-targets -- -D warnings under rust 1.96. Behavior-neutral.
@M3gA-Mind

Copy link
Copy Markdown
Contributor Author

CI guardian: the Rust SDK check was red on a pre-existing main clippy failure under stable rust 1.96 (a collapsible_if in StreamAccumulator::push_tool_chunk and a duplicated #[cfg(test)] on the stream test module), inherited by this branch. Pushed a behavior-neutral lint fix so CI can go green; no change to this PR's own logic.

…r wording

This PR changes StreamAccumulator::finish to return the structured
TinyAgentsError::Provider (preserving status/code/retryable) instead of a
flattened Model string. The e2e contract assertion still expected the old
"<provider> provider error (<code>)" wording; update it to the new
ProviderError Display ("<provider> returned HTTP <status> (<code>): <msg>").
@M3gA-Mind

Copy link
Copy Markdown
Contributor Author

CI guardian follow-up: with the clippy blocker cleared, CI surfaced a real test failure that was masked behind it — tests/e2e_harness_provider_contracts.rs:284 still asserted the old flattened error wording (mock provider error (internal): nope). This PR intentionally switched StreamAccumulator::finish to return the structured TinyAgentsError::Provider, whose Display renders mock returned HTTP 500 (internal): nope — and the sibling unit tests in model/test.rs/openai/test.rs were already updated, so this e2e assertion was just a missed leftover. I updated it to the new wording (no behavior change). Full cargo test and cargo test --all-features pass locally under rust 1.96. Please sanity-check the assertion matches your intended error contract.

@senamakel
senamakel merged commit 7f7c476 into tinyhumansai:main Jul 8, 2026
2 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.

[TinyAgents][T1] Streamed provider failures lose retry classification (retried as transient)

2 participants