Commit d468acb
fix: ConsoleLogger.warn() severity + add rate-limit sleep span (#17623)
## Description
Fixes two bugs surfaced in a community thread investigating high latency
(~67s wall-clock) in a 10-step agent:
1. **`ConsoleLogger.warn()` called `console.info()` instead of
`console.warn()`** — warn-level logs were misclassified as info/stdout,
making rate-limit warnings invisible in log backends filtering by
severity.
2. **Rate-limit sleep had no OTel span** — the hardcoded 10s `delay()`
when `x-ratelimit-remaining-tokens < 2000` only emitted a warn log
(which was invisible per bug #1). Added a `rate-limit-sleep` child span
with `{ remainingTokens, delayMs }` metadata so the sleep is visible in
traces.
3. **Fixed lockfile resolution** — `agent-sdks/openai` had a stale
`eslint@10.3.0` lockfile entry after a merge; updated to `10.4.1`.
### Changes
- `packages/_internal-core/src/logger/index.ts`: `console.info()` →
`console.warn()` in `ConsoleLogger.warn()`
- `packages/core/src/llm/model/model.ts`: Added `rate-limit-sleep` span
in both `__text` and `__stream` paths
- `packages/core/src/llm/model/model.loop.ts`: Added `rate-limit-sleep`
span in agentic loop path
- `packages/core/src/logger/console-logger.test.ts`: Updated 3 tests to
assert `console.warn`
- `packages/core/src/llm/model/model.test.ts`: New test verifying span
creation with correct name/metadata when rate-limit fires
- `observability/sentry/src/tracing.test.ts`: Updated test that was
codifying the same `console.info` bug
- `pnpm-lock.yaml`: Fixed stale `eslint@10.3.0` → `10.4.1` for
`agent-sdks/openai`
## Related issue(s)
Community-reported latency investigation (Slack thread). No GitHub
issue.
## Type of change
- [x] Bug fix (non-breaking change that fixes an issue)
- [x] Test update
## Checklist
- [x] I have linked the related issue(s) in the description above
- [x] I have made corresponding changes to the documentation (if
applicable)
- [x] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have addressed all Coderabbit comments on this PR
Link to Devin session:
https://app.devin.ai/sessions/ce59a3645593455aa14f4397eda972d7
Requested by: @roaminro
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## ELI5
This PR fixes two observability problems: warning messages were being
sent to the wrong console stream, and a repeated 10-second pause used
for rate-limiting was invisible in traces—both are now fixed so logs and
traces accurately show warnings and delay time.
---
## Overview
This PR includes two fixes from a latency investigation:
1. ConsoleLogger.warn() now calls console.warn() (previously
console.info()), so warn-level logs are classified correctly by log
backends.
2. The hardcoded 10s rate-limit backpressure sleep (triggered when
x-ratelimit-remaining-tokens < 2000) is now wrapped in a
"rate-limit-sleep" OpenTelemetry child span with attributes
remainingTokens and delayMs and the warn log now includes
remainingTokens.
---
## Changes
- packages/_internal-core/src/logger/index.ts
- ConsoleLogger.warn() uses console.warn() instead of console.info().
- packages/core/src/llm/model/model.ts
- In MastraLLMV1.__text and __stream: create a "rate-limit-sleep" child
span around the 10s sleep, record remainingTokens and delayMs, end the
span after sleep, and include remainingTokens in the warn message.
- packages/core/src/llm/model/model.loop.ts
- In MastraLLMVNext.stream (onStepFinish): add the same
"rate-limit-sleep" child span and warn message including
remainingTokens.
- Tests
- packages/core/src/logger/console-logger.test.ts: updated assertions to
expect console.warn for warn-level logs.
- observability/sentry/src/tracing.test.ts: updated to spy on
console.warn for DSN-missing warning.
- packages/core/src/llm/model/model.test.ts: added regression test
verifying creation and lifecycle of the rate-limit-sleep span
(attributes remainingTokens and delayMs), the warn log, and that the
span ends after the 10s fake-timer sleep.
- Documentation/changesets
- .changeset/* files updated to document the ConsoleLogger fix and
rate-limit span instrumentation.
---
## Impact
- Warn-level logs will be routed and classified correctly by logging
backends.
- Rate-limit backpressure delays are now visible in distributed traces
as "rate-limit-sleep" spans containing remainingTokens and delayMs,
aiding latency investigations where repeated 10s sleeps caused
unaccounted trace time.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Romain <97863888+roaminro@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Abhi Aiyer <abhiaiyer91@gmail.com>1 parent f5519fc commit d468acb
8 files changed
Lines changed: 121 additions & 12 deletions
File tree
- .changeset
- observability/sentry/src
- packages
- _internal-core/src/logger
- core/src
- llm/model
- logger
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
109 | | - | |
| 108 | + | |
110 | 109 | | |
111 | 110 | | |
112 | 111 | | |
| |||
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
118 | | - | |
| 117 | + | |
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
122 | 121 | | |
123 | 122 | | |
124 | | - | |
| 123 | + | |
125 | 124 | | |
126 | 125 | | |
127 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
| 300 | + | |
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
274 | 279 | | |
| 280 | + | |
275 | 281 | | |
276 | 282 | | |
277 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
877 | 877 | | |
878 | 878 | | |
879 | 879 | | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
880 | 954 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
261 | 266 | | |
| 267 | + | |
262 | 268 | | |
263 | 269 | | |
264 | 270 | | |
| |||
608 | 614 | | |
609 | 615 | | |
610 | 616 | | |
611 | | - | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
612 | 623 | | |
| 624 | + | |
613 | 625 | | |
614 | 626 | | |
615 | 627 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | | - | |
29 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
113 | 116 | | |
114 | 117 | | |
115 | 118 | | |
| 119 | + | |
116 | 120 | | |
117 | 121 | | |
118 | 122 | | |
| |||
126 | 130 | | |
127 | 131 | | |
128 | 132 | | |
| 133 | + | |
129 | 134 | | |
130 | 135 | | |
131 | 136 | | |
| |||
188 | 193 | | |
189 | 194 | | |
190 | 195 | | |
| 196 | + | |
191 | 197 | | |
192 | 198 | | |
193 | 199 | | |
194 | 200 | | |
195 | 201 | | |
196 | 202 | | |
197 | 203 | | |
198 | | - | |
199 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
200 | 207 | | |
201 | 208 | | |
202 | 209 | | |
203 | 210 | | |
| 211 | + | |
204 | 212 | | |
205 | 213 | | |
206 | 214 | | |
| |||
0 commit comments