Commit f34dd4c
fix(llm): cap auto-detected max_output_tokens when it fills the entire context window
When litellm's model registry reports max_output_tokens >= max_input_tokens
(e.g. Nemotron: both 262144), the SDK would request the entire context window
for output, leaving zero tokens for input. Every provider call was rejected,
the condenser misinterpreted this as context overflow, and crashed on the
near-empty history with NoCondensationAvailableException.
Cap auto-detected max_output_tokens to half the context window when it would
otherwise consume the full window. Explicitly user-set values are not affected.
Co-authored-by: openhands <openhands@all-hands.dev>1 parent 0b4be6f commit f34dd4c
File tree
2 files changed
+40
-11
lines changed- openhands-sdk/openhands/sdk/llm
- tests/sdk/llm
2 files changed
+40
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1210 | 1210 | | |
1211 | 1211 | | |
1212 | 1212 | | |
1213 | | - | |
1214 | | - | |
1215 | | - | |
1216 | | - | |
1217 | | - | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
1218 | 1223 | | |
1219 | | - | |
| 1224 | + | |
1220 | 1225 | | |
1221 | | - | |
| 1226 | + | |
1222 | 1227 | | |
1223 | | - | |
| 1228 | + | |
1224 | 1229 | | |
1225 | 1230 | | |
1226 | 1231 | | |
1227 | 1232 | | |
1228 | 1233 | | |
1229 | 1234 | | |
1230 | 1235 | | |
1231 | | - | |
| 1236 | + | |
1232 | 1237 | | |
1233 | 1238 | | |
1234 | 1239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1168 | 1168 | | |
1169 | 1169 | | |
1170 | 1170 | | |
1171 | | - | |
1172 | | - | |
| 1171 | + | |
| 1172 | + | |
1173 | 1173 | | |
1174 | 1174 | | |
1175 | 1175 | | |
| |||
1186 | 1186 | | |
1187 | 1187 | | |
1188 | 1188 | | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
1189 | 1213 | | |
1190 | 1214 | | |
1191 | 1215 | | |
| |||
0 commit comments