fix(agent): surface provider stream failure causes in logs and spans - #4550
Conversation
A provider body read that fails mid-stream is wrapped as RuntimeProviderStreamFailure with a private cause, so the server log and the chat span reported only the wrapper. Log a bounded, credential-redacted cause chain (name, message, code) as errorCauses on "Agent stream error", classify the wrapper as RuntimeProviderStreamFailure on spans, and record the cause class as error.cause.type. The client SSE error is unchanged. Refs veryfront/veryfront-issue-inbox#1615
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. Warning Review limit reachedNext included review available in 24 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change adds wrapped-cause classification and bounded cause summaries for provider stream failures. Agent runtime logs now include sanitized causes. OpenTelemetry spans record cause types. Regression tests cover client responses, logs, and spans. ChangesProvider stream diagnostics
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant AgentRuntime
participant ProviderStream
participant TelemetryError
participant Logger
participant OpenTelemetry
AgentRuntime->>ProviderStream: consume stream
ProviderStream-->>AgentRuntime: provider stream failure
AgentRuntime->>TelemetryError: classify and summarize cause
TelemetryError-->>AgentRuntime: failure type and errorCauses
AgentRuntime->>Logger: record Agent stream error
AgentRuntime->>OpenTelemetry: record error status and cause type
AgentRuntime-->>ProviderStream: expose generic Provider stream failed response
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📦 Client bundle boundary
A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in |
Code Review: 88/100 — Good, minor suggestionsFocused, well-tested fix for a real incident (#4547): surfaces the previously-private cause of Strengths
Concerns
No blocking issues found; the redaction/bounding logic is sound and the tests genuinely exercise the failure mode described in the PR. Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dac7fd303e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e0352760e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed361697e3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…d transient codes
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
@codex review |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d20b46ff4e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3632eca327
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |



Description
When a provider body read fails mid-stream, the runtime logged only
Agent stream error/RuntimeProviderStreamFailure: Provider stream failed, and thechat <model>span recordedexception.type="Error",exception.message="Error". The real cause sat in a private WeakMap. In the production incident behind #4547 it wasRangeError: Anthropic partial_json exceeded 4096 deltas, and finding it took replaying captured streams.Now:
Agent stream errorcarrieserrorCauses: up to 4 wrapped errors, where every field is either a fixed classification or an exact allowlisted text.nameis an allowlisted error class (elseError/Unknown).codeis a known transient network token (e.g.ECONNRESET), otherwise omitted.messageis included only when it equals a member ofLOGGABLE_CAUSE_MESSAGES, the complete set of texts the Anthropic parser emits with its fixed limits plus the transport'serror reading a body from connection. Any other message is withheld asmessageRedacted: true. Prompts, model output, customer data, identifiers and hostnames cannot reach the logs.exception.type/ status isRuntimeProviderStreamFailure(only for the real wrapper, not for errors that merely use the name), pluserror.cause.type(for exampleRangeError,TypeError,ECONNRESET). Spans carry only this fixed classification, never cause text.Related Issue(s)
Fixes veryfront/veryfront-issue-inbox#1615
Part of veryfront/veryfront-issue-inbox#1622
Verification
src/agent/runtime/provider-stream-failure-diagnostics.test.ts(3 steps, written to fail first):error.cause.typeare set, with no cause text on any span.src/observability/telemetry-error.test.tsgained 3 steps (35/35 pass).src/observability/tracing(316 steps),agent-span-error-redaction,chat-stream-handler,runtime-stream-cancel,provider-replay-emission,runtime-bridge,retry-policy,src/utils/logger.deno fmt --check,deno lintanddeno checkpass on the changed files, and so doeslint:module-boundaries.Notes
error.cause.typeis added in the shared span failure path, so any span failing with a standardcausegets it too. It is always a fixed label.error.typenow also sayRuntimeProviderStreamFailureinstead ofError. This affects telemetry only.Type of Change
Checklist