Repository navigation
Commit e6fb7e4
daewoongoh
fix: revalidate rate-limit before agent dispatch after preparation and during retries
When agent preparation takes longer than the configured rate-limit window or
when title generation dispatches during retry backoff, the agent can dispatch
too soon without waiting. Add revalidation logic that defers dispatch when
another request has recorded on the shared clock since the agent's initial
reservation.
Track this task's own rate-limit reservations in ownRateLimitReservation. Before
dispatch (both in the rate-limited path and skipProviderRateLimit path), call
reserveAgentDispatchSlot() which silently waits out the window from any other
request that recorded meanwhile, then records synchronously.
Added 4 concurrent-dispatch tests:
- Title while agent prepares longer than window
- No wait when only agent's own reservation exists
- Retry during rate-limit wait (rate-limited path)
- Retry during rate-limit wait (skipProviderRateLimit path)
These tests detect when the fix is reverted, failing the dispatch-timing
assertions for all scenarios except when only the agent's reservation exists.1 parent 76c4c47 commit e6fb7e4
2 files changed
Lines changed: 149 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
| 440 | + | |
| 441 | + | |
440 | 442 | | |
441 | 443 | | |
442 | 444 | | |
| |||
5808 | 5810 | | |
5809 | 5811 | | |
5810 | 5812 | | |
5811 | | - | |
| 5813 | + | |
5812 | 5814 | | |
5813 | 5815 | | |
5814 | 5816 | | |
| |||
5840 | 5842 | | |
5841 | 5843 | | |
5842 | 5844 | | |
5843 | | - | |
| 5845 | + | |
5844 | 5846 | | |
5845 | 5847 | | |
5846 | 5848 | | |
5847 | 5849 | | |
5848 | 5850 | | |
5849 | 5851 | | |
5850 | 5852 | | |
| 5853 | + | |
| 5854 | + | |
| 5855 | + | |
| 5856 | + | |
| 5857 | + | |
| 5858 | + | |
| 5859 | + | |
| 5860 | + | |
| 5861 | + | |
| 5862 | + | |
| 5863 | + | |
| 5864 | + | |
| 5865 | + | |
| 5866 | + | |
| 5867 | + | |
| 5868 | + | |
| 5869 | + | |
| 5870 | + | |
| 5871 | + | |
| 5872 | + | |
| 5873 | + | |
| 5874 | + | |
| 5875 | + | |
| 5876 | + | |
| 5877 | + | |
| 5878 | + | |
| 5879 | + | |
| 5880 | + | |
| 5881 | + | |
| 5882 | + | |
| 5883 | + | |
| 5884 | + | |
5851 | 5885 | | |
5852 | 5886 | | |
5853 | 5887 | | |
| |||
5917 | 5951 | | |
5918 | 5952 | | |
5919 | 5953 | | |
5920 | | - | |
5921 | | - | |
5922 | | - | |
| 5954 | + | |
| 5955 | + | |
| 5956 | + | |
5923 | 5957 | | |
5924 | | - | |
| 5958 | + | |
5925 | 5959 | | |
5926 | 5960 | | |
5927 | 5961 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
4024 | 4025 | | |
4025 | 4026 | | |
4026 | 4027 | | |
| 4028 | + | |
| 4029 | + | |
| 4030 | + | |
| 4031 | + | |
| 4032 | + | |
| 4033 | + | |
| 4034 | + | |
| 4035 | + | |
| 4036 | + | |
| 4037 | + | |
| 4038 | + | |
| 4039 | + | |
| 4040 | + | |
| 4041 | + | |
| 4042 | + | |
| 4043 | + | |
| 4044 | + | |
| 4045 | + | |
| 4046 | + | |
| 4047 | + | |
| 4048 | + | |
| 4049 | + | |
| 4050 | + | |
| 4051 | + | |
| 4052 | + | |
| 4053 | + | |
| 4054 | + | |
| 4055 | + | |
| 4056 | + | |
| 4057 | + | |
| 4058 | + | |
| 4059 | + | |
| 4060 | + | |
| 4061 | + | |
| 4062 | + | |
| 4063 | + | |
| 4064 | + | |
| 4065 | + | |
| 4066 | + | |
| 4067 | + | |
| 4068 | + | |
| 4069 | + | |
| 4070 | + | |
| 4071 | + | |
| 4072 | + | |
| 4073 | + | |
| 4074 | + | |
| 4075 | + | |
| 4076 | + | |
| 4077 | + | |
| 4078 | + | |
| 4079 | + | |
| 4080 | + | |
| 4081 | + | |
| 4082 | + | |
| 4083 | + | |
| 4084 | + | |
| 4085 | + | |
| 4086 | + | |
| 4087 | + | |
| 4088 | + | |
| 4089 | + | |
| 4090 | + | |
| 4091 | + | |
| 4092 | + | |
| 4093 | + | |
| 4094 | + | |
| 4095 | + | |
| 4096 | + | |
| 4097 | + | |
| 4098 | + | |
| 4099 | + | |
| 4100 | + | |
| 4101 | + | |
| 4102 | + | |
| 4103 | + | |
| 4104 | + | |
| 4105 | + | |
| 4106 | + | |
| 4107 | + | |
| 4108 | + | |
| 4109 | + | |
| 4110 | + | |
| 4111 | + | |
| 4112 | + | |
| 4113 | + | |
| 4114 | + | |
| 4115 | + | |
| 4116 | + | |
| 4117 | + | |
| 4118 | + | |
| 4119 | + | |
| 4120 | + | |
| 4121 | + | |
| 4122 | + | |
| 4123 | + | |
| 4124 | + | |
| 4125 | + | |
| 4126 | + | |
| 4127 | + | |
| 4128 | + | |
| 4129 | + | |
| 4130 | + | |
| 4131 | + | |
| 4132 | + | |
| 4133 | + | |
| 4134 | + | |
4027 | 4135 | | |
4028 | 4136 | | |
4029 | 4137 | | |
| |||
0 commit comments