Repository navigation
Conversation
Moves the number_guessing_game sample from a2a-sdk 0.3.0 to 1.1.0. - Pin a2a-sdk[http-server]==1.1.0 (Starlette now comes with the extra). - Agent cards: AgentCard/AgentSkill/AgentInterface constructors, supported_interfaces instead of url; drop state_transition_history. - Executors: enqueue the initial Task first (replaces Alice's submit()), Part(text=...), requires_input() without final, a2a.helpers imports. - Server: DefaultRequestHandler with agent_card, routes from create_agent_card_routes/create_jsonrpc_routes in a Starlette app. - Client: create_client per call (each sync wrapper runs its own event loop), SendMessageRequest/CancelTaskRequest, read the Task from the StreamResponse (ClientTaskManager is gone), TASK_STATE_* enum names. - README: SDK version, SendMessage, task aggregation row. - ruff format on the touched files. Part of a2aproject#462 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Nn19mXGNFoFZgk3SaYC7Y
Clears the super-linter findings on the files changed by this pull request (ruff 0.15.8 with .ruff.toml, markdownlint-cli 0.48.0). No behaviour change; one printed character changes (see RUF001). - MD060: README tables use the compact style (delimiter rows spaced, one padding run removed); cell text unchanged. - INP001: agent_Alice/Bob/Carol.py start with `#!/usr/bin/env python3`, as the repo's standalone scripts do; an __init__.py would trigger N999 on the capitalised file names. - D205: module docstrings start with their summary sentence (the bare file-name line is dropped); send_followup summary split from its description. - D103: docstring for agent_Bob.main(). - RUF002: en dashes and a Unicode hyphen in docstrings replaced with "-". - RUF001: Carol's "Received well done – completing task" now prints "-". - ANN201: send_text_async/send_text/send_followup -> Task | Message, extract_text -> str, build_starlette_app -> Starlette. - ANN001: agent_card: AgentCard | dict, executor: AgentExecutor (imported under TYPE_CHECKING for TC002). - BLE001 (_print_guesses): `# noqa: BLE001`, as in adk_currency_agent and multitenancy. - BLE001 + S110 (initial debug print): contextlib.suppress(Exception), as in birthday_planner_adk; same exceptions swallowed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Nn19mXGNFoFZgk3SaYC7Y
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Moves
samples/python/agents/number_guessing_gamefroma2a-sdk==0.3.0toa2a-sdk[http-server]==1.1.0, following the 1.0 migration guide and the helloworld 1.1.x sample. The game, the file layout and the agents' output stay the same.Changes, all inside the sample folder:
requirements.txt:a2a-sdk[http-server]==1.1.0. In 1.x, Starlette comes only with thehttp-serverextra.AgentCard/AgentSkill/AgentInterfaceconstructors.supported_interfacesreplacesurl, andstateTransitionHistoryis dropped because 1.x no longer has it.Taskfirst, as 1.x requires. For Alice this replacesupdater.submit(). Also:Part(text=...),requires_input()(nofinalargument), and imports froma2a.helpers/a2a.server.*.utils/server.py:DefaultRequestHandler(..., agent_card), andcreate_agent_card_routes+create_jsonrpc_routesin aStarletteapp (replacesA2AStarletteApplication). The JSON-RPC path stays/a2a/v1.utils/protocol_wrappers.py:create_client()per call. In 1.x aClientFactorykeeps onehttpx.AsyncClient, which fails with "Event loop is closed" because each sync wrapper runs its ownasyncio.run.SendMessageRequestandCancelTaskRequest.Taskis read from theStreamResponse, sinceClientTaskManageris gone.agent_Bob.py:TaskState.TASK_STATE_INPUT_REQUIRED. States are printed withTaskState.Name(...)so the log stays readable (state=TASK_STATE_INPUT_REQUIRED).SendMessage, and the task aggregation row.ruff format(repo.ruff.toml) on the touched files. This accounts for most of the line count in Bob and Carol.SDK version:
a2a-sdk1.1.0, the same exact pin as helloworld, multitenancy and sign_and_verify_agent_card.How it was tested
Python 3.12, fresh venv:
The game played to the end on 1.1.0. Last lines of Bob's output:
The "Try again" / "Well done!" multi-turn exchange between Bob and Carol completed as on 0.3.0. In a second run, the 400-attempt limit was reached and Bob's
CancelTaskreached Carol ([Carol] Task … canceled on request of peer agent). The same scripted game was played on 0.3.0 before the change for comparison. The only difference in output is the state name (TaskState.input_required→TASK_STATE_INPUT_REQUIRED).ruff format --check --config .ruff.toml samples/python/agents/number_guessing_game/passes.ruff checkreports nothing new: 47 findings remain, all of which were already onmain(48 there). They are mostly docstring style, EN DASH characters and missing__init__.py(INP001) in files this PR does not otherwise need to touch.Not tested: Alice's
cancelpath (nothing calls it), Windows, Python 3.10/3.11, and a 0.3 client against the new servers (v0.3 compat is not enabled).AI assistance was used to prepare this change. The game was run end to end locally on the new pin.
CONTRIBUTINGGuide.Part of #462 🦕
🤖 Generated with Claude Code
https://claude.ai/code/session_015Nn19mXGNFoFZgk3SaYC7Y