Commit 6cd5399
committed
fix: cap gateway turns and stream text to Telegram incrementally
Two fixes for multi-turn tool-calling sessions feeling unresponsive:
1. Set max_turns to 5 for gateway sessions. Previously None (default
1000), so the agent could do dozens of tool-call round-trips before
responding. Now after 5 LLM→tool turns it stops and replies with
what it has, asking the user if they want to continue.
2. Send assistant text to Telegram as it arrives instead of buffering
everything until the stream ends. When a ToolRequest follows text
in the same message, the text is flushed immediately — the user
sees 'Let me check...' right away, then the typing indicator while
tools run, then the next response as a separate message. Only the
final trailing text (after the last tool round-trip) waits for
stream end.
Before: user waits 30+ seconds seeing only 'typing', gets one
giant message at the end (or nothing if it times out).
After: user sees incremental messages as the agent works through
each step, with clear activity indicators between them.1 parent 6afcf67 commit 6cd5399
1 file changed
+57
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
306 | 312 | | |
307 | 313 | | |
308 | 314 | | |
309 | | - | |
| 315 | + | |
310 | 316 | | |
311 | 317 | | |
312 | 318 | | |
| |||
356 | 362 | | |
357 | 363 | | |
358 | 364 | | |
359 | | - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
360 | 372 | | |
361 | 373 | | |
362 | 374 | | |
| |||
373 | 385 | | |
374 | 386 | | |
375 | 387 | | |
376 | | - | |
377 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
378 | 393 | | |
379 | | - | |
380 | 394 | | |
381 | 395 | | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
382 | 411 | | |
383 | 412 | | |
384 | 413 | | |
| |||
462 | 491 | | |
463 | 492 | | |
464 | 493 | | |
465 | | - | |
| 494 | + | |
| 495 | + | |
466 | 496 | | |
467 | 497 | | |
468 | 498 | | |
469 | | - | |
470 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
471 | 520 | | |
472 | 521 | | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | 522 | | |
483 | 523 | | |
484 | 524 | | |
| |||
0 commit comments