feat: Add HTTP caching headers to Agent Card endpoint#761
feat: Add HTTP caching headers to Agent Card endpoint#761kabir wants to merge 1 commit intoa2aproject:mainfrom
Conversation
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 introduces HTTP caching mechanisms to the Agent Card endpoint, significantly improving performance and reducing server load by allowing clients and intermediaries to cache the Agent Card content. By implementing Cache-Control, ETag, and Last-Modified headers, the system now adheres to the A2A specification's caching requirements, providing a more efficient and compliant way to serve static agent information. 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 effectively implements HTTP caching for the Agent Card endpoint by adding Cache-Control, ETag, and Last-Modified headers, as specified. The implementation is well-structured, introducing a dedicated AgentCardCacheMetadata bean to compute and cache these headers at startup. The changes are correctly propagated to both JSON-RPC and REST transports, and the new functionality is validated with a new test case.
I have one suggestion to improve the consistency of ETag generation across different environments. Otherwise, the changes look good.
server-common/src/main/java/io/a2a/server/AgentCardCacheMetadata.java
Outdated
Show resolved
Hide resolved
|
@kabir the CI failure looks genuine |
|
@jmesnil Yep, investigating |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively implements HTTP caching for the Agent Card endpoint as per the A2A specification. The changes are well-structured, introducing an AgentCardCacheMetadata bean to encapsulate the caching logic and cleanly integrating it into the REST and JSON-RPC layers. The tests are also comprehensive, including a new test for the caching headers and appropriate overrides for gRPC.
To improve robustness, I recommend failing fast during application startup in AgentCardCacheMetadata if required dependencies are missing, rather than causing a NullPointerException at runtime.
Overall, this is a great addition that improves performance and compliance with the specification.
Implements A2A specification section 8.6 caching requirements: - Cache-Control header with configurable max-age (CARD-CACHE-001) - ETag header derived from Agent Card content hash (CARD-CACHE-002) - Last-Modified header with initialization timestamp (CARD-CACHE-003) **Implementation:** - Created AgentCardCacheMetadata bean in server-common to compute and cache HTTP headers at initialization - Enhanced HTTPRestResponse to support additional headers via Map - Updated RestHandler and JSON-RPC A2AServerRoutes to include caching headers - Caching headers applied to both REST and JSON-RPC transports (gRPC out of scope per spec) **Configuration:** - Max-age configurable via `a2a.agent-card.cache.max-age` (default: 3600 seconds) - ETag calculated as MD5 hash of serialized Agent Card JSON - Last-Modified set to bean initialization time in RFC 1123 format **Testing:** - Added testAgentCardHeaders() to AbstractA2AServerTest - Validates all three caching headers are present and correctly formatted - gRPC test overrides to skip (HTTP-only requirement) Fixes a2aproject#749 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
@jmesnil Should be fine now |
Implements A2A specification section 8.6 caching requirements:
Implementation:
Configuration:
a2a.agent-card.cache.max-age(default: 3600 seconds)Testing:
Fixes #749 🦕