feat(a2a): add agent acknowledgment command and enhance registry discovery#22389
Conversation
|
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! |
Summary of ChangesHello, 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 improves the A2A and general agent discovery systems by introducing a mechanism for manual agent trust, refining agent registration logic, and standardizing policy management. These changes bolster trust validation, enhance registry policies, and ensure idempotent client management, laying further groundwork for robust agent interactions. Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces an acknowledge-agent command for the A2A server, enhances agent discovery, and centralizes a policy priority constant. A critical security vulnerability has been identified in the trust validation for remote agents; using the agent's URL as a hash allows for a 'Time-of-Check to Time-of-Use' (TOCTOU) bypass, enabling content modification after acknowledgment. This requires addressing by implementing a content-based cryptographic hash for trust validation. Additionally, a logic flaw exists in packages/core/src/agents/registry.ts due to duplicated agent registration code, leading to redundant operations.
|
Size Change: +100 B (0%) Total Size: 26.2 MB
ℹ️ View Unchanged
|
…overy - Introduces 'acknowledge-agent' JSON-RPC command to manually trust agents in A2A server. - Updates core registry to ensure all project agents are discoverable by name before registration. - Prevents duplicate loading errors by skipping redundant 'loadAgent' calls in the registry. - Adds manual YOLO policy rule support (priority 998) for consistent server/CLI behavior. - Includes comprehensive unit tests for the new command and registry registration.
0502e5d to
e5004a8
Compare
|
I think the correct order of things to do here is:
|
e38cc82 to
41024b3
Compare
Make A2AClientManager not static.
41024b3 to
c1b4cc6
Compare
…try and RemoteInvocation
Summary
Building on the recently submitted Branch 3 infrastructure, this PR enhances the
A2A and general agent discovery systems with robust trust validation, improved
registry policies, and idempotent client management. It refactors
A2AClientManagerfrom a global singleton to an instance-based object tied tothe
Configinstance, resolving state conflicts in multi-task serverenvironments.
File-based Changes
packages/core/src/agents/a2a-client-manager.ts&a2a-client-manager.test.tsgetInstance(). Theconstructor now requires a
Configinstance.communication manager, preventing "already loaded" errors.
registry.ts®istry.test.tsloadAgentsto populateallDefinitionsfor all discovered project agents.reloadandregisterRemoteAgentto use the instance-specificA2AClientManagerviathis.config.getA2AClientManager().remote-invocation.ts&remote-invocation.test.tsRemoteAgentInvocationto acceptAgentLoopContextin its constructor and retrieve theA2AClientManagerfrom the config instance.subagent-tool-wrapper.tsRemoteAgentInvocationconstructor.packages/core/src/config/config.ts&config.test.tsa2aClientManageras a private property of theConfigclass.getA2AClientManager()getter.mcpClientManagerpattern.packages/a2a-server/src/config/config.tsGEMINI_YOLO_MODEis active.settings.ts&settings.test.tsexperimental.enableAgentsto theSettingsinterface and verified its loading via tests.Testing
Automated Tests
a2a-client-manager.test.ts: Refactored to use direct instantiation instead of singleton access.remote-invocation.test.ts: Updated to verify instance-based manager lookup.registry.test.ts: Updated mocks to handle the newgetA2AClientManagerand constructor pattern.config.test.ts: Added coverage for instance-specific manager initialization and fixed proxy test failures.settings.test.ts(a2a-server): Verified thatexperimental.enableAgentsis correctly loaded from settings.Manual Test (gRPC V0 Compatibility)
Prepare the Go Server (a2a-go repo)
examples/helloworld/server/grpc/main.go."0.1"ina2a/core.go.go run examples/helloworld/server/grpc/main.go(listens on port 9001).Prepare the Gemini CLI
.gemini/agents/grpc-test-agent.mdwith URL:http://localhost:9001/.well-known/agent-card.json."enableAgents": truein theexperimentalblock of.gemini/settings.json.Verify
Start server:
Step 1: Acknowledge the agent (Manual Step):
To trust the agent, you must manually add its entry to your local acknowledgments file:
~/.gemini/acknowledgments/agents.json.Example entry:
{ "/absolute/path/to/your/workspace": { "grpc-test-agent": "http://localhost:9001/.well-known/agent-card.json" } }(For remote agents, the "hash" is the
agentCardUrl).Step 2: Trigger call:
Related Issues
Closes #22199