Skip to content

Commit 75c3e8d

Browse files
conradleeclaude
andcommitted
Fix flaky test_a2a_error_handling test
The test was using a fixed 0.1-second sleep and assuming the task would fail within that time. In slower CI environments or under Python 3.10, this timing assumption could fail. Changed to use the same retry loop pattern used by all other a2a tests: - Poll the task status up to 50 times (5 seconds total) - Break early when the task reaches 'failed' state - Raise clear error if timeout is reached This matches the pattern established in previous commits (a253fad, etc.) that fixed similar flakiness in other a2a tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent e640bda commit 75c3e8d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/test_a2a.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,14 @@ def raise_error(_: list[ModelMessage], info: AgentInfo) -> ModelResponse:
515515
task_id = result['id']
516516

517517
# Wait for task to fail
518-
await anyio.sleep(0.1)
519-
task = await a2a_client.get_task(task_id)
518+
max_attempts = 50 # 5 seconds total
519+
for _ in range(max_attempts):
520+
task = await a2a_client.get_task(task_id)
521+
if 'result' in task and task['result']['status']['state'] == 'failed':
522+
break
523+
await anyio.sleep(0.1)
524+
else: # pragma: no cover
525+
raise AssertionError(f'Task did not fail within {max_attempts * 0.1} seconds')
520526

521527
assert 'result' in task
522528
assert task['result']['status']['state'] == 'failed'

0 commit comments

Comments
 (0)