Skip to content

Commit 5baf9d3

Browse files
fix: enable SDK polling for fallback (#414)
1 parent 5e1b929 commit 5baf9d3

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

src/opencode_a2a/client/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ async def _build_client(self) -> Client:
295295
card = await self.get_agent_card()
296296
config = ClientConfig(
297297
streaming=True,
298-
polling=False,
298+
polling=self._polling_fallback_policy.enabled,
299299
httpx_client=await self._get_httpx_client(),
300300
supported_transports=list(self._settings.supported_transports),
301301
use_client_preference=self._settings.use_client_preference,

tests/client/test_client_facade.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,46 @@ def create(
154154
assert actual is fake_sdk_client
155155

156156

157+
@pytest.mark.asyncio
158+
async def test_build_client_enables_sdk_polling_when_polling_fallback_enabled(
159+
monkeypatch: pytest.MonkeyPatch,
160+
) -> None:
161+
client = A2AClient(
162+
"http://agent.example.com",
163+
settings=A2AClientSettings(polling_fallback_enabled=True),
164+
)
165+
fake_sdk_client = _FakeClient()
166+
factory_calls: dict[str, object] = {}
167+
168+
class _FakeFactory:
169+
def __init__(self, config: ClientConfig, consumers: list[object] | None = None):
170+
factory_calls["config"] = config
171+
factory_calls["consumers"] = consumers
172+
173+
def create(
174+
self,
175+
_card: object,
176+
consumers: list[object] | None = None,
177+
interceptors: list[object] | None = None,
178+
extensions: list[str] | None = None,
179+
) -> _FakeClient:
180+
return fake_sdk_client
181+
182+
monkeypatch.setattr(client_module, "ClientFactory", _FakeFactory)
183+
monkeypatch.setattr(
184+
client_module,
185+
"build_agent_card_resolver",
186+
lambda *_args: _FakeCardResolver("agent-card"),
187+
)
188+
189+
actual = await client._build_client()
190+
191+
config = factory_calls["config"]
192+
assert isinstance(config, ClientConfig)
193+
assert config.polling is True
194+
assert actual is fake_sdk_client
195+
196+
157197
@pytest.mark.asyncio
158198
async def test_send_returns_last_event(monkeypatch: pytest.MonkeyPatch) -> None:
159199
client = A2AClient("http://agent.example.com")

0 commit comments

Comments
 (0)