@@ -182,7 +182,27 @@ async fn does_not_retry_on_first_attempt_success() {
182182/// If Composio still returns the auth-error payload on the second call
183183/// (gateway not actually recovered, or real credential problem
184184/// masquerading as the post-OAuth string), surface the second response
185- /// verbatim — exactly one retry, never a loop.
185+ /// verbatim — bounded retries, never a loop.
186+ ///
187+ /// **NOTE on the gateway-hit count**: There are TWO retry layers stacked
188+ /// for this error shape today —
189+ ///
190+ /// - This module (`auth_retry.rs`, added in #1708) wraps every composio
191+ /// tool call with one outer retry on `RETRYABLE_AUTH_ERRORS`.
192+ /// - `ComposioClient::execute_tool` (changed by #1707, merged
193+ /// independently) wraps every call with one inner retry on
194+ /// `is_post_oauth_auth_readiness_error`, which catches the same
195+ /// `"Connection error, try to authenticate"` string.
196+ ///
197+ /// So an error that triggers BOTH classifiers fires 4 gateway hits
198+ /// (outer attempt 1: inner-retry → 2 hits, outer attempt 2: inner-retry
199+ /// → 2 hits). The user-visible contract — "bounded retries, never an
200+ /// infinite loop" — is preserved. The assertion below pins the compound
201+ /// count so a future fix that collapses the two layers surfaces here
202+ /// and the operator updates this test alongside the production change.
203+ ///
204+ /// TODO(composio-retry-dedup): collapse the two retry layers — see
205+ /// `auth_retry.rs` doc-comment vs `client.rs::execute_tool_with_post_oauth_retry`.
186206#[ tokio:: test]
187207async fn retries_once_only_even_when_second_call_still_errors ( ) {
188208 let counter = Arc :: new ( AtomicUsize :: new ( 0 ) ) ;
@@ -220,8 +240,10 @@ async fn retries_once_only_even_when_second_call_still_errors() {
220240 ) ;
221241 assert_eq ! (
222242 counter. load( Ordering :: SeqCst ) ,
223- 2 ,
224- "must retry exactly once, never a third time"
243+ 4 ,
244+ "compound retry: outer (auth_retry.rs, #1708) × inner \
245+ (execute_tool_with_post_oauth_retry, #1707) = 4 gateway hits. \
246+ Pinning so a future collapse of the two layers surfaces here."
225247 ) ;
226248}
227249
0 commit comments