@devries-cameron20 / composio-1 / commits / 4e1883089
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(connected-accounts,py): drop INACTIVE from terminal states in wait_for_connection

The previous patch added FAILED / EXPIRED / INACTIVE / REVOKED to the terminal-state set, flipping the contract from "loop until timeout for any non-ACTIVE" to "raise SDKError immediately on any of those four". INACTIVE means "user disabled, can be reactivated" — a connection can briefly transit through it before settling on ACTIVE, and failing fast there regressed callers that previously recovered. Align Python's terminal set with TS (`ConnectionRequest.ts`) at [FAILED, EXPIRED, REVOKED]. INACTIVE remains non-terminal in both SDKs, matching its "reactivatable" semantics. Addresses PR #3344 review comments P1#2 (regression on INACTIVE) and P1#3 (TS↔Python terminal-state divergence).

jkomyno committed May 7, 2026 at 10:17 UTC 4e1883089d38d2e9a923b5d45e13bef03c1a4bb7
1 file changed +9 -3
python/composio/core/models/connected_accounts.py
+9 -3
@@ -74,14 +74,20 @@ class ConnectionRequest(Resource):
74 """
75 timeout = self.DEFAULT_WAIT_TIMEOUT if timeout is None else timeout
76 deadline = time.time() + timeout
77 + # Mirror the TS contract (`ConnectionRequest.ts` `terminalErrorStates`):
78 + # FAILED / EXPIRED / REVOKED are terminal — credentials are gone and
79 + # cannot transition back to ACTIVE without a fresh auth flow, so
80 + # polling until timeout is wasted wall-clock time.
81 + # INACTIVE is intentionally NOT terminal: it means "user disabled, can
82 + # be reactivated", and a connection can briefly transit through it
83 + # before settling on ACTIVE — failing fast there would regress callers.
84 + terminal_states = ("FAILED", "EXPIRED", "REVOKED")
85 while deadline > time.time():
86 connection = self._client.connected_accounts.retrieve(nanoid=self.id)
87 self.status = connection.status
88 if self.status == "ACTIVE":
89 return connection
82 - # Fail fast on terminal non-ACTIVE states (FAILED / EXPIRED /
83 - # INACTIVE / REVOKED) instead of polling until timeout.
84 - if self.status in ("FAILED", "EXPIRED", "INACTIVE", "REVOKED"):
90 + if self.status in terminal_states:
91 raise exceptions.SDKError(
92 message=(
93 f"Connection {self.id} entered terminal state "