Repository navigation
Commit 67cadb8
committed
Throttle Albert API: per-model documented limits, debounce, fail-fast on daily quota
- Distinguish daily quota (rpd/tpd) from transient (rpm/tpm) 429s. On daily
quota (e.g. "2460000 input tokens per day exceeded"), raise
TerminalRateLimitError immediately instead of burning 3 retries that all
return 429.
- Surface Albert's 429 body in the TUI message ("Daily quota exhausted on
X. Server: ...") instead of a generic "rate limit exceeded".
- Log the 429 body in _handle_429 for diagnostic visibility.
- Per-model documented limits (DOCUMENTED_MODEL_LIMITS) used by the
throttler instead of the max-across-routers, which incorrectly picked
the embeddings router (500 rpm) for chat models like Qwen3-Coder
(50 rpm). Throttler.acquire and usage_snapshot accept model_name.
- Pre-call debounce: enforce 60/rpm + 0.05s minimum spacing between two
acquires (Simon Roux's _wait_for_slot pattern). Plus _blocked_until for
Retry-After-driven backoff.
- New /rpm slash command: live RPM/TPM gauge for the active model with
bar, debounce, active backoff, and limit source (documented vs guessed).
- /limits now also shows the documented EXP/PROD tier for the active
model alongside live /v1/me/info per-router data.
- Fail-fast on the next 429 once the auto-fallback trigger is reached
(is_fallback_trigger_reached): stop wasting retries on a primary the
agent loop will replace at the next turn.
- Skip auto-continue when the assistant returned an empty response (no
content, no tool_calls). Avoids the observed pattern of 15+ requests
at 20k input tokens each producing 0 output tokens.
- Reset throttler singletons between tests to avoid state leakage.1 parent 3ff24ad commit 67cadb8
10 files changed
Lines changed: 499 additions & 35 deletions
File tree
- albert_code
- cli
- textual_ui
- core
- llm
- backend
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
104 | 112 | | |
105 | 113 | | |
106 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
723 | 723 | | |
724 | 724 | | |
725 | 725 | | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
730 | 745 | | |
731 | 746 | | |
732 | 747 | | |
| |||
944 | 959 | | |
945 | 960 | | |
946 | 961 | | |
| 962 | + | |
947 | 963 | | |
948 | 964 | | |
949 | 965 | | |
| |||
985 | 1001 | | |
986 | 1002 | | |
987 | 1003 | | |
988 | | - | |
| 1004 | + | |
989 | 1005 | | |
990 | 1006 | | |
991 | 1007 | | |
| |||
997 | 1013 | | |
998 | 1014 | | |
999 | 1015 | | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
1000 | 1102 | | |
1001 | 1103 | | |
1002 | 1104 | | |
| |||
1725 | 1827 | | |
1726 | 1828 | | |
1727 | 1829 | | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
1728 | 1844 | | |
1729 | 1845 | | |
1730 | 1846 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
147 | 162 | | |
148 | 163 | | |
149 | 164 | | |
| |||
588 | 603 | | |
589 | 604 | | |
590 | 605 | | |
| 606 | + | |
591 | 607 | | |
592 | 608 | | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
593 | 614 | | |
594 | 615 | | |
595 | 616 | | |
596 | 617 | | |
597 | 618 | | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
598 | 627 | | |
599 | 628 | | |
600 | 629 | | |
| |||
889 | 918 | | |
890 | 919 | | |
891 | 920 | | |
892 | | - | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
893 | 924 | | |
894 | 925 | | |
895 | 926 | | |
| |||
938 | 969 | | |
939 | 970 | | |
940 | 971 | | |
941 | | - | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
942 | 975 | | |
943 | 976 | | |
944 | 977 | | |
| |||
0 commit comments