Skip to content

feat: add a2a-python SUT code generation - #139

Merged
jmesnil merged 5 commits into
a2aproject:1.0-devfrom
jmesnil:a2a-python-sut
Mar 26, 2026
Merged

jmesnil merged 5 commits into
a2aproject:1.0-devfrom
jmesnil:a2a-python-sut

Conversation

@jmesnil

@jmesnil jmesnil commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Add a Python code emitter that generates a runnable SUT project from Gherkin scenarios using the a2a-python SDK, mirroring the existing a2a-java pipeline.

New files:

  • codegen/python_emitter.py — maps Actions to TaskUpdater API calls
  • codegen/a2a-python/*.j2 — Jinja2 templates (sut_agent.py, pyproject.toml)
  • tests/unit/codegen/test_python_emitter.py — 6 unit tests
  • sut/a2a-python/ — generated SUT project (16 scenarios)

Modified:

  • codegen/generator.py — register a2a-python emitter
  • Makefile — add codegen-a2a-python-sut target
  • AGENTS.md — document new emitter and commands
  • .gitignore — scope a2a-python ignore to root only

TCK result: 76.5% compatibility (remaining failures are SDK-level).

Add a Python code emitter that generates a runnable SUT project from
Gherkin scenarios using the a2a-python SDK, mirroring the existing
a2a-java pipeline.

New files:
- codegen/python_emitter.py — maps Actions to TaskUpdater API calls
- codegen/a2a-python/*.j2 — Jinja2 templates (sut_agent.py, pyproject.toml)
- tests/unit/codegen/test_python_emitter.py — 6 unit tests
- sut/a2a-python/ — generated SUT project (16 scenarios)

Modified:
- codegen/generator.py — register a2a-python emitter
- Makefile — add codegen-a2a-python-sut target
- AGENTS.md — document new emitter and commands
- .gitignore — scope a2a-python ignore to root only

TCK result: 76.5% compatibility (remaining failures are SDK-level).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the A2A TCK's code generation capabilities by introducing a Python-based System Under Test (SUT) pipeline. This new feature allows for the automatic generation of runnable Python SUT projects from Gherkin scenarios, directly mirroring the existing Java SUT generation. The primary impact is enabling comprehensive conformance testing against the a2a-python SDK, ensuring broader compatibility and validation of the A2A specification across different language implementations.

Highlights

  • New Python Code Emitter: Introduced a new Python code emitter to generate System Under Test (SUT) projects for the a2a-python SDK, mirroring the existing Java pipeline.
  • Jinja2 Templates for Python SUT: Added Jinja2 templates (sut_agent.py.j2, pyproject.toml.j2) to facilitate the generation of the a2a-python SUT project structure and agent logic.
  • Unit Tests for Python Emitter: Included comprehensive unit tests for the new Python code emitter to ensure its correctness and reliability.
  • Build System and Documentation Updates: Integrated the a2a-python emitter into the code generation pipeline, updated the Makefile with a new build target, and documented the new capabilities in AGENTS.md.
Changelog
  • .gitignore
    • Updated ignore rules to specifically target root-level a2a-python and a2a-java-sdk directories.
  • AGENTS.md
    • Documented the new python_emitter.py and its associated Jinja2 templates.
    • Added the sut/a2a-python/ directory to the project structure description.
    • Included the new make codegen-a2a-python-sut command.
  • Makefile
    • Added codegen-a2a-python-sut to the .PHONY list.
    • Defined a new codegen-a2a-python-sut target to generate the Python SUT.
  • codegen/generator.py
    • Imported emit_python_project from the new python_emitter.
    • Registered a2a-python as a target emitter, mapping it to emit_python_project.
Activity
  • Initial commit introducing the Python SUT code generation feature.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a Python code emitter for generating an a2a-python SUT, which is a great addition mirroring the existing Java pipeline. The implementation is well-structured, with clear separation of concerns between parsing, model definition, and code generation. The new emitter is properly integrated with the build system and documented.

My main feedback is to modernize the asyncio server startup logic in the generated sut_agent.py file. The current implementation uses asyncio.get_event_loop(), which is deprecated. I've provided a suggestion to refactor this using asyncio.run(), which is the recommended approach for Python 3.7+ and will make the generated code more robust and future-proof.

Comment thread codegen/a2a-python/sut_agent.py.j2 Outdated
jmesnil and others added 2 commits March 17, 2026 17:52
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The project requires Python >= 3.11 where get_event_loop() is deprecated.
Use async def main() with asyncio.run() and add graceful gRPC shutdown.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jmesnil

jmesnil commented Mar 17, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant feature: a Python code emitter for generating a runnable SUT project from Gherkin scenarios, mirroring the existing Java pipeline. The implementation is well-structured, including the core emitter logic, Jinja2 templates, unit tests, and documentation. My review identifies a potential bug in the code generation for DataPartDef which could result in syntax errors in the generated code. I have also provided a suggestion to improve a command in the documentation to follow best practices. Overall, this is a strong contribution.

Comment thread codegen/python_emitter.py Outdated
Comment thread .agents/skills/a2a-python-sut/SKILL.md
jmesnil and others added 2 commits March 17, 2026 18:12
…ted code

Use json_format.Parse() with a JSON string literal instead of
json_format.ParseDict() with inline Python dict, which breaks on
JSON values like null/true/false.

Add ruff config to the generated pyproject.toml to suppress rules
inherent to generated code (import order, unused imports, branch count).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… code, refine skills

- Use json_format.Parse() with a JSON string literal instead of
  json_format.ParseDict() with inline Python dict, fixing JSON
  null/true/false handling.
- Add ruff config to generated pyproject.toml to suppress rules
  inherent to generated code (import order, unused imports, branch count).
- Refine diagnose-failure, run-tck, and a2a-python-sut skills based on
  session learnings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jmesnil
jmesnil merged commit 4b3f39f into a2aproject:1.0-dev Mar 26, 2026
1 check passed
jmesnil added a commit that referenced this pull request May 19, 2026
Add a Python code emitter that generates a runnable SUT project from
Gherkin scenarios using the a2a-python SDK, mirroring the existing
a2a-java pipeline.

New files:
- codegen/python_emitter.py — maps Actions to TaskUpdater API calls
- codegen/a2a-python/*.j2 — Jinja2 templates (sut_agent.py,
pyproject.toml)
- tests/unit/codegen/test_python_emitter.py — 6 unit tests
- sut/a2a-python/ — generated SUT project (16 scenarios)

Modified:
- codegen/generator.py — register a2a-python emitter
- Makefile — add codegen-a2a-python-sut target
- AGENTS.md — document new emitter and commands
- .gitignore — scope a2a-python ignore to root only

TCK result: 76.5% compatibility (remaining failures are SDK-level).

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
millsmillsymills pushed a commit to millsmillsymills/a2a-tck that referenced this pull request Jul 9, 2026
Add a Python code emitter that generates a runnable SUT project from
Gherkin scenarios using the a2a-python SDK, mirroring the existing
a2a-java pipeline.

New files:
- codegen/python_emitter.py — maps Actions to TaskUpdater API calls
- codegen/a2a-python/*.j2 — Jinja2 templates (sut_agent.py,
pyproject.toml)
- tests/unit/codegen/test_python_emitter.py — 6 unit tests
- sut/a2a-python/ — generated SUT project (16 scenarios)

Modified:
- codegen/generator.py — register a2a-python emitter
- Makefile — add codegen-a2a-python-sut target
- AGENTS.md — document new emitter and commands
- .gitignore — scope a2a-python ignore to root only

TCK result: 76.5% compatibility (remaining failures are SDK-level).

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
millsmillsymills pushed a commit to millsmillsymills/a2a-tck that referenced this pull request Jul 9, 2026
Add a Python code emitter that generates a runnable SUT project from
Gherkin scenarios using the a2a-python SDK, mirroring the existing
a2a-java pipeline.

New files:
- codegen/python_emitter.py — maps Actions to TaskUpdater API calls
- codegen/a2a-python/*.j2 — Jinja2 templates (sut_agent.py,
pyproject.toml)
- tests/unit/codegen/test_python_emitter.py — 6 unit tests
- sut/a2a-python/ — generated SUT project (16 scenarios)

Modified:
- codegen/generator.py — register a2a-python emitter
- Makefile — add codegen-a2a-python-sut target
- AGENTS.md — document new emitter and commands
- .gitignore — scope a2a-python ignore to root only

TCK result: 76.5% compatibility (remaining failures are SDK-level).

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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