#13951: Improve error logging for better debugging in gateway logs
agents
size: XS
Cluster:
Wizard Enhancements and Config Fixes
Fixes #13868
This pull request improves error logging for provider errors in the Pi Embedded Runner to ensure better visibility and debugging of issues in the gateway logs. The changes focus on capturing both general provider errors and specific HTTP errors with detailed context.
**Enhanced error logging:**
* Added logging for non-failover provider errors in `run.ts` to ensure they are captured in gateway logs before being propagated to the user. The log includes provider, model, session key, and a truncated error message.
* Added immediate logging of provider HTTP errors in `run/attempt.ts` when an error with HTTP status 400 or above is detected. The log records provider, model, session ID, run ID, HTTP status, error message, and error type for improved debugging.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Added comprehensive error logging to capture provider errors that weren't being logged before, improving visibility into gateway issues.
- Logs non-failover provider errors in `run.ts` before throwing, capturing provider, model, session key, and truncated error text
- Logs HTTP errors with status >= 400 in `attempt.ts` at the source, including provider, model, session/run IDs, HTTP status, error message, and error type
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The changes only add logging statements without modifying any control flow or error handling logic. Both logging additions are defensive and follow existing patterns in the codebase. The truncation to 2000 characters prevents log spam, and the logs provide valuable debugging context.
- No files require special attention
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#19020: bugfix(gateway): Handle invalid model provider API config gracefully\…
by funkyjonx · 2026-02-17
74.6%
#12314: fix: treat HTTP 5xx server errors as failover-worthy
by hsssgdtc · 2026-02-09
73.9%
#16307: fix: surface billing/auth FailoverErrors as user-friendly messages
by petter-b · 2026-02-14
73.9%
#2541: fix(agents): add error handling to orphaned message cleanup
by Episkey-G · 2026-01-27
73.9%
#13960: fix(ui): preserve structured config validation error details
by constansino · 2026-02-11
73.1%
#11174: Fix/fried chicken error
by jfgrissom · 2026-02-07
72.9%
#6039: fix: improve type safety in gateway registration
by Bharadwajreddy1406 · 2026-02-01
72.7%
#8522: feat(control-ui): Add Model Requests panel for real-time API monito...
by GiantAxeWhy · 2026-02-04
72.7%
#10034: Don't crash gateway on transient unhandled fetch failures
by gigq · 2026-02-06
72.0%
#3322: fix: merge provider config api into registry model
by nulone · 2026-01-28
71.7%