Skip to content

feat(protocol): add opt-in connection retries for extensions - #884

Draft
morningducke wants to merge 7 commits into
scaleapi:mainfrom
morningducke:fix/protocol-connect-retries
Draft

morningducke wants to merge 7 commits into
scaleapi:mainfrom
morningducke:fix/protocol-connect-retries

Conversation

@morningducke

@morningducke morningducke commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What and why

A transient connection failure can stop clock or tool-access setup before the environment receives the request. Extension calls make one attempt by default. Callers can now opt in where recovering from a failed connection is useful.

from agentenv_protocol import client

with client.retry_extension_connections():
    state = await client.invoke_extension(url, card, "urn:agentenv:clock/v1", method="state")

An opted-in call retries httpx.ConnectError and httpx.ConnectTimeout before sending request headers. Up to three attempts share the connection timeout, with waits of 0.5 and 1 second when the budget allows. Read and write failures, HTTP error responses and cancellation propagate to the caller. A failed redirect target cannot replay the original request.

The framework opts in when arming the clock, reading its state, syncing a service clock, changing the clock rate, and enabling or disabling tools. Data RPCs, card and manifest lookups, and MCP sessions make one attempt even inside the context. The protocol README documents the API. The framework guide should describe the retry behavior of those setup steps.

How it was tested

  • The protocol suite and six framework caller modules passed 2,327 tests with one skipped example website test. A clean test merge with fix(protocol): keep direct RPC connections alive while awaiting a reply #883 passed 2,343 with the same skip. Ruff, the pinned uv lockfile check and the plugin API compatibility check passed.
  • The built protocol wheel has the same three mandatory dependencies as the base. Trio is a development extra. Wheel tests passed on asyncio without sniffio, uvloop, native Trio, and Trio with HTTPX 0.27.0 and AnyIO 3.6.2. Each peer observed the TLS socket close on cancellation.
  • Against one temporary E2B server, the first TCP attempt for each call raised an injected timeout. Both the stock client and the default PR client made one attempt and sent zero requests. With retries enabled, clock setup took 1.121 seconds and tool disable took 0.861 seconds. The server handled each request exactly once. The sandbox was terminated.

GitHub Actions run for this revision

@socket-security

socket-security Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedpypi/​trio@​0.35.073100100100100

View full report

@morningducke morningducke changed the title fix(protocol): retry connection establishment within the request deadline feat(protocol): add opt-in connection retries for extensions Nov 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant