Commit e12b659
committed
fix(llm): propagate per-scope LLM timeout + retry policy to the provider (#2452)
The per-operation LLM request settings were resolved into HindsightConfig but
never reached the provider that uses them, so configuring them was a silent
no-op:
- *_llm_timeout (retain/reflect/consolidation) and the global llm_timeout never
reached the provider impl; it fell back to HINDSIGHT_API_LLM_TIMEOUT/120s, so
HINDSIGHT_API_RETAIN_LLM_TIMEOUT=300 did nothing ("LiteLLM call exceeded
timeout=120.0s").
- reflect_llm_max_retries/initial_backoff/max_backoff and
consolidation_llm_initial_backoff/max_backoff were never consumed; reflect and
consolidation used the hardcoded call()/call_with_tools() defaults (10/5),
ignoring the documented "falls back to llm_max_retries" contract.
Fix: resolve each operation's effective request defaults (per-op override else
global) in MemoryEngine and carry them on the LLMProvider:
- timeout is threaded config -> LLMProvider -> create_llm_provider -> provider
impl for the providers that honour a configurable request timeout (LiteLLM,
LiteLLM Router, OpenAI-compatible, Nous). None preserves each provider's own
default, so Anthropic/Gemini keep their bespoke timeouts and the no-config
path is byte-identical.
- max_retries/initial_backoff/max_backoff become LLMProvider instance defaults
that call()/call_with_tools() use when the per-call arg is omitted. Explicit
per-call args (retain's resolved values, reflect's fast structured-extraction
path) still win; providers built without config (from_env, tests) keep the
10/5 method fallback.
The four operation scopes (default/retain/reflect/consolidation) and multi-LLM
chain members all share their operation's resolved values via a small
_LLMCallDefaults bundle.
max_concurrent is intentionally left as-is (process-global semaphores read from
env at startup, server-level only); the docs are clarified to call out that
distinction.
Also fixes a pre-existing breakage in test_llm_router_provider's __new__-based
helper (missing _default_headers after #2466) so the suite is green.
Tests: tests/test_llm_timeout_propagation.py covers provider-impl timeout
threading, the call() retry-policy fallback/override, and per-op
resolution/fallback in MemoryEngine.1 parent 82b01ac commit e12b659
6 files changed
Lines changed: 345 additions & 18 deletions
File tree
- hindsight-api-slim
- hindsight_api/engine
- tests
- hindsight-docs/docs/developer
- skills/hindsight-docs/references/developer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
256 | 257 | | |
257 | 258 | | |
258 | 259 | | |
| |||
280 | 281 | | |
281 | 282 | | |
282 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
283 | 290 | | |
284 | 291 | | |
285 | 292 | | |
| |||
378 | 385 | | |
379 | 386 | | |
380 | 387 | | |
| 388 | + | |
381 | 389 | | |
382 | 390 | | |
383 | 391 | | |
| |||
397 | 405 | | |
398 | 406 | | |
399 | 407 | | |
| 408 | + | |
400 | 409 | | |
401 | 410 | | |
402 | 411 | | |
| |||
411 | 420 | | |
412 | 421 | | |
413 | 422 | | |
| 423 | + | |
414 | 424 | | |
415 | 425 | | |
416 | 426 | | |
| |||
457 | 467 | | |
458 | 468 | | |
459 | 469 | | |
| 470 | + | |
460 | 471 | | |
461 | 472 | | |
462 | 473 | | |
| |||
483 | 494 | | |
484 | 495 | | |
485 | 496 | | |
| 497 | + | |
486 | 498 | | |
487 | 499 | | |
488 | 500 | | |
| |||
515 | 527 | | |
516 | 528 | | |
517 | 529 | | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
518 | 534 | | |
519 | 535 | | |
520 | 536 | | |
| |||
543 | 559 | | |
544 | 560 | | |
545 | 561 | | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
546 | 573 | | |
547 | 574 | | |
548 | 575 | | |
| |||
556 | 583 | | |
557 | 584 | | |
558 | 585 | | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
559 | 595 | | |
560 | 596 | | |
561 | 597 | | |
| |||
706 | 742 | | |
707 | 743 | | |
708 | 744 | | |
| 745 | + | |
709 | 746 | | |
710 | 747 | | |
711 | 748 | | |
| |||
762 | 799 | | |
763 | 800 | | |
764 | 801 | | |
765 | | - | |
766 | | - | |
767 | | - | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
768 | 805 | | |
769 | 806 | | |
770 | 807 | | |
| |||
779 | 816 | | |
780 | 817 | | |
781 | 818 | | |
782 | | - | |
783 | | - | |
784 | | - | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
785 | 825 | | |
786 | 826 | | |
787 | 827 | | |
| |||
806 | 846 | | |
807 | 847 | | |
808 | 848 | | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
809 | 863 | | |
810 | 864 | | |
811 | 865 | | |
| |||
908 | 962 | | |
909 | 963 | | |
910 | 964 | | |
911 | | - | |
912 | | - | |
913 | | - | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
914 | 968 | | |
915 | 969 | | |
916 | 970 | | |
| |||
923 | 977 | | |
924 | 978 | | |
925 | 979 | | |
926 | | - | |
927 | | - | |
928 | | - | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
929 | 986 | | |
930 | 987 | | |
931 | 988 | | |
| |||
935 | 992 | | |
936 | 993 | | |
937 | 994 | | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
938 | 1009 | | |
939 | 1010 | | |
940 | 1011 | | |
| |||
1178 | 1249 | | |
1179 | 1250 | | |
1180 | 1251 | | |
| 1252 | + | |
1181 | 1253 | | |
1182 | 1254 | | |
1183 | 1255 | | |
| |||
1192 | 1264 | | |
1193 | 1265 | | |
1194 | 1266 | | |
| 1267 | + | |
1195 | 1268 | | |
1196 | 1269 | | |
1197 | 1270 | | |
| |||
1245 | 1318 | | |
1246 | 1319 | | |
1247 | 1320 | | |
| 1321 | + | |
1248 | 1322 | | |
1249 | 1323 | | |
1250 | 1324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
392 | 418 | | |
393 | 419 | | |
394 | 420 | | |
| |||
397 | 423 | | |
398 | 424 | | |
399 | 425 | | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
400 | 430 | | |
401 | 431 | | |
402 | 432 | | |
| |||
416 | 446 | | |
417 | 447 | | |
418 | 448 | | |
| 449 | + | |
419 | 450 | | |
420 | 451 | | |
421 | 452 | | |
422 | 453 | | |
423 | 454 | | |
424 | 455 | | |
425 | 456 | | |
| 457 | + | |
426 | 458 | | |
427 | 459 | | |
428 | 460 | | |
| |||
431 | 463 | | |
432 | 464 | | |
433 | 465 | | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
434 | 469 | | |
435 | 470 | | |
436 | 471 | | |
| |||
442 | 477 | | |
443 | 478 | | |
444 | 479 | | |
445 | | - | |
| 480 | + | |
446 | 481 | | |
447 | 482 | | |
448 | 483 | | |
| |||
1023 | 1058 | | |
1024 | 1059 | | |
1025 | 1060 | | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
1026 | 1084 | | |
1027 | 1085 | | |
1028 | 1086 | | |
| |||
1042 | 1100 | | |
1043 | 1101 | | |
1044 | 1102 | | |
| 1103 | + | |
1045 | 1104 | | |
1046 | | - | |
| 1105 | + | |
1047 | 1106 | | |
1048 | 1107 | | |
1049 | 1108 | | |
| |||
1085 | 1144 | | |
1086 | 1145 | | |
1087 | 1146 | | |
| 1147 | + | |
1088 | 1148 | | |
1089 | | - | |
| 1149 | + | |
1090 | 1150 | | |
1091 | 1151 | | |
1092 | 1152 | | |
| |||
1122 | 1182 | | |
1123 | 1183 | | |
1124 | 1184 | | |
| 1185 | + | |
1125 | 1186 | | |
1126 | | - | |
| 1187 | + | |
1127 | 1188 | | |
1128 | 1189 | | |
1129 | 1190 | | |
| |||
1159 | 1220 | | |
1160 | 1221 | | |
1161 | 1222 | | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
1162 | 1227 | | |
1163 | | - | |
1164 | 1228 | | |
1165 | 1229 | | |
1166 | 1230 | | |
| |||
0 commit comments