Commit cecb36c
committed
feat(agent): expose per-call maxTokens on agent() config
BaseAgentConfig now carries an optional maxTokens field. When set, it's
forwarded to every generateText / streamText call the agent makes —
generate(), session.send(), and stream(). Unset preserves current
behavior (providers fall back to their defaults, typically 4-8k).
The driver: agency-style sessions (e.g. paracosm's commander +
department agents) had no way to cap tail spend on a misbehaving
model. Per-call maxTokens was accessible on generateText / generateObject
directly, but not on agent sessions, so high-volume session-backed
call sites defaulted to provider caps on every invocation.
Two tests pin the behavior: maxTokens flows through agent.generate()
and session.send() when configured, and stays undefined on the
generateText call when omitted.1 parent 7885a91 commit cecb36c
3 files changed
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
383 | 387 | | |
384 | 388 | | |
385 | 389 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
205 | 230 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1191 | 1191 | | |
1192 | 1192 | | |
1193 | 1193 | | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
1194 | 1206 | | |
1195 | 1207 | | |
1196 | 1208 | | |
| |||
0 commit comments