Skip to content

feat(a2a): propagate agent settings to experimental A2A server#21405

Closed
alisa-alisa wants to merge 10 commits intogrpc-v0-branch4from
grpc-v0-branch5
Closed

feat(a2a): propagate agent settings to experimental A2A server#21405
alisa-alisa wants to merge 10 commits intogrpc-v0-branch4from
grpc-v0-branch5

Conversation

@alisa-alisa
Copy link
Copy Markdown
Contributor

@alisa-alisa alisa-alisa commented Mar 6, 2026

Summary

This final PR completes the gRPC V0 integration by propagating the new agent settings to the experimental A2A server environment. It addresses critical security feedback regarding "secure by default" defaults and trust-gated environment variable expansion.

Details

  • A2A Server Integration: Updated the experimental A2A server's configuration logic to respect the enableAgents and agents settings, allowing for native remote agent discovery and gRPC communication within the server.
  • Secure-by-Default Configuration: Updated the experimental A2A server to default enableAgents to false, matching the security posture of the core CLI and requiring explicit user opt-in for agent discovery.
  • Trust-Gated Variable Expansion: Implemented a secure configuration loading pattern where workspace-provided settings (including the new agents block) are loaded as "raw" values and only expanded via environment variables if the workspace is explicitly trusted. This prevents sensitive credential leakage (like GEMINI_API_KEY) from malicious repositories.
  • Type-Safe Refactoring: Resolved a naming collision by aliasing the server-specific AgentSettings to CoderAgentSettings, improving code clarity and maintainability.
  • Manual Validation Path: Documented the full end-to-end verification flow using the A2A-Go reference implementation.

Why this is needed

This PR ensures that the new gRPC and security features are fully accessible not just via the CLI, but also through the experimental Agent-to-Agent server, enabling programmatic access to the same secure agent infrastructure without introducing new attack vectors.

Related Issues

Resolves #18642.

How to Validate (Manual Repro)

1. Prepare the Go Server (a2a-go repo)

  1. Switch to V0 Handler in examples/helloworld/server/grpc/main.go.
  2. Set protocol Version to "0.1" in a2a/core.go.
  3. Run: go run examples/helloworld/server/grpc/main.go (listens on port 9001).

2. Prepare the Gemini CLI

  1. Create .gemini/agents/grpc-test-agent.md with URL: http://localhost:9001/.well-known/agent-card.json.
  2. Ensure "enableAgents": true in the experimental block of .gemini/settings.json.

3. Verify

  1. Start server: npm run start -w @google/gemini-cli-a2a-server
  2. Trigger call:
    curl -N -X POST http://localhost:56474/ \
      -H "Content-Type: application/json" \
      -d '{
        "jsonrpc": "2.0",
        "id": "1",
        "method": "message/stream",
        "params": {
          "message": {
            "kind": "message",
            "role": "user",
            "parts": [{ "kind": "text", "text": "Hello, call the grpc-test-agent tool and say hi" }],
            "messageId": "test-final-attempt"
          }
        }
      }'

@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli Bot commented Mar 6, 2026

Hi @alisa-alisa, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this.

We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines.

Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed.

Thank you for your understanding and for being a part of our community!

@alisa-alisa
Copy link
Copy Markdown
Contributor Author

This review is part of a big PR: #21348

@alisa-alisa alisa-alisa marked this pull request as ready for review March 6, 2026 14:38
@alisa-alisa alisa-alisa requested a review from a team as a code owner March 6, 2026 14:38
@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 finalizes the gRPC V0 integration by enabling the experimental A2A server to properly consume and utilize agent-related settings. This ensures that the server can leverage the new secure agent infrastructure and gRPC features, providing a programmatic interface equivalent to the CLI for agent management and communication.

Highlights

  • Agent Settings Propagation: Implemented the propagation of agent settings (enableAgents and agents) from the server's configuration to the core Config instance within the experimental A2A server.
  • A2A Server Integration: Updated the experimental A2A server's configuration logic to respect enableAgents and agents settings, enabling native remote agent discovery and gRPC communication.
  • Validation Path: Documented a comprehensive manual validation path using the A2A-Go reference implementation to verify end-to-end functionality.
Changelog
  • packages/a2a-server/src/config/config.test.ts
    • Added tests to verify that agent settings are correctly passed to the Config instance.
    • Added a test to confirm enableAgents defaults to true if not explicitly specified.
  • packages/a2a-server/src/config/config.ts
    • Modified the loadConfig function to include enableAgents (with a default of true) and agents settings when initializing the core Config.
  • packages/a2a-server/src/config/settings.test.ts
    • Added a test case to ensure experimental and agent settings are loaded correctly from the settings file.
  • packages/a2a-server/src/config/settings.ts
    • Imported the AgentSettings type from @google/gemini-cli-core.
    • Extended the Settings interface to include optional experimental (with enableAgents) and agents properties.
Activity
  • No human activity has been recorded on this pull request yet.
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.

Copy link
Copy Markdown
Contributor

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

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 correctly propagates agent settings to the experimental A2A server by updating the configuration loading logic and adding corresponding tests. However, it introduces significant security concerns: defaulting enableAgents to true enables an SSRF attack vector via malicious agent definitions, and the new agents settings are vulnerable to insecure environment variable expansion when loaded from untrusted workspace directories, potentially leading to sensitive credential leakage. Additionally, there is a high-severity naming collision for the AgentSettings type within packages/a2a-server/src/config/config.ts that needs to be addressed for better maintainability.

Comment thread packages/a2a-server/src/config/config.ts Outdated
Comment thread packages/a2a-server/src/config/settings.ts
Comment thread packages/a2a-server/src/config/config.ts
@gemini-cli gemini-cli Bot added area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Mar 6, 2026
@alisa-alisa alisa-alisa force-pushed the grpc-v0-branch5 branch 2 times, most recently from f2b3367 to cfae184 Compare March 6, 2026 15:41
@alisa-alisa alisa-alisa force-pushed the grpc-v0-branch4 branch 2 times, most recently from 6453c5f to a3ef0a5 Compare March 9, 2026 18:45
import { v4 as uuidv4 } from 'uuid';
import { logger } from '../utils/logger.js';
import type { AgentSettings } from '../types.js';
import { type AgentSettings as CoderAgentSettings } from '../types.js';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why alias this type? Is there a collision?

@alisa-alisa alisa-alisa force-pushed the grpc-v0-branch5 branch 2 times, most recently from 22160ff to 7875e33 Compare March 10, 2026 22:09
@alisa-alisa alisa-alisa force-pushed the grpc-v0-branch4 branch 2 times, most recently from 6576088 to e8be953 Compare March 11, 2026 14:20
@alisa-alisa alisa-alisa force-pushed the grpc-v0-branch5 branch 2 times, most recently from 216277a to 6f4dea9 Compare March 11, 2026 15:53
alisa-alisa and others added 6 commits March 12, 2026 10:50
…rect gRPC URL

- Pass empty string to resolver.resolve() to prevent SDK from appending
  /.well-known/agent-card.json to direct card URLs
- Simplify normalizeAgentCard to only handle proto field name aliases
  (supportedInterfaces → additionalInterfaces, protocolBinding → transport)
- Use gRPC-specific URL from additionalInterfaces for credentials
- Remove dead helper functions and unnecessary behaviors
- Add shallow copy to prevent SDK object mutation
@alisa-alisa alisa-alisa force-pushed the grpc-v0-branch4 branch 2 times, most recently from 7f2ab59 to 9f5c35d Compare March 12, 2026 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants