Commit 73c93cf
fix(backend): resolve production failures with comprehensive token handling and conversation safety fixes (#11394)
## Summary
Resolves multiple production failures including execution
**6239b448-0434-4687-a42b-9ff0ddf01c1d** where AI Text Generator failed
with `'NoneType' object is not iterable`.
This implements comprehensive fixes addressing both the root cause
(unrealistic token limits) and masking issues (Sentry SDK bug +
conversation history null safety).
## Root Cause Analysis
Three interconnected issues caused production failures:
### 1. Unrealistic Perplexity Token Limits ❌
- **PERPLEXITY_SONAR**: 127,000 max_output_tokens (equivalent to ~95,000
words!)
- **PERPLEXITY_SONAR_DEEP_RESEARCH**: 128,000 max_output_tokens
- **Problem**: Newsletter generation defaulted to 127K output tokens
- **Result**: Exceeded OpenRouter's 128K total limit, causing API
failures
### 2. Sentry SDK OpenAI Integration Bug 🐛
- **Location**: `sentry_sdk/integrations/openai.py:157`
- **Bug**: `for choice in response.choices:` failed when `choices=None`
- **Impact**: Masked real token limit errors with confusing TypeError
### 3. Conversation History Null Safety Issues 1 parent 02757d6 commit 73c93cf
File tree
4 files changed
+19
-14
lines changed- autogpt_platform/backend
- backend/blocks
4 files changed
+19
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | | - | |
| 260 | + | |
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| |||
797 | 797 | | |
798 | 798 | | |
799 | 799 | | |
800 | | - | |
| 800 | + | |
801 | 801 | | |
802 | 802 | | |
803 | 803 | | |
| |||
904 | 904 | | |
905 | 905 | | |
906 | 906 | | |
907 | | - | |
| 907 | + | |
908 | 908 | | |
909 | 909 | | |
910 | 910 | | |
| |||
Lines changed: 8 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
| |||
173 | 176 | | |
174 | 177 | | |
175 | 178 | | |
176 | | - | |
| 179 | + | |
177 | 180 | | |
178 | 181 | | |
179 | 182 | | |
| |||
605 | 608 | | |
606 | 609 | | |
607 | 610 | | |
608 | | - | |
609 | | - | |
| 611 | + | |
| 612 | + | |
610 | 613 | | |
611 | | - | |
| 614 | + | |
612 | 615 | | |
613 | 616 | | |
614 | 617 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
0 commit comments