Repository navigation
feat: upgrade a2a-go to v2.2.0 (#14) - #18
Conversation
The a2a-go project ships a CLI (`a2a discover`) that can inspect Agent Cards. Full `a2a send` support requires upgrading to a2a-go v2 (#14) to serve the new supportedInterfaces card format. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Migrate from github.com/a2aproject/a2a-go v0.3.x to github.com/a2aproject/a2a-go/v2 v2.2.0. Key changes: - AgentCard uses SupportedInterfaces instead of URL/ProtocolVersion - Executor uses iter.Seq2 yield pattern instead of event queue - Parts use NewTextPart/NewDataPart constructors and .Text() accessor - SendMessageRequest replaces MessageSendParams - Client endpoints use *AgentInterface pointers - ServiceParams replaces CallMeta for header injection Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 1 minutes and 32 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughUpgrades the codebase to Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Exec as AgentExecutor
participant ExecCtx as ExecutorContext
participant Task
participant Iterator as Event Iterator
Caller->>Exec: Execute(ctx, execCtx)
activate Exec
Exec->>ExecCtx: read ServiceParams (auth, delegation)
Exec->>Task: process task (may be nil)
activate Task
Task-->>Exec: result / error
deactivate Task
alt no task stored
Exec->>Iterator: yield(SubmittedTaskEvent)
end
alt success
Exec->>Iterator: yield(WorkingEvent)
Exec->>Iterator: yield(ArtifactEvent)
Exec->>Iterator: yield(CompletedEvent)
else failure
Exec->>Iterator: yield(FailedEvent)
end
Exec-->>Caller: return Iterator
deactivate Exec
Caller->>Iterator: iterate()
Iterator-->>Caller: events...
Estimated code review effort🎯 4 (Complex) | ⏱️ ~55 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Rewrite SupportedInterfaces URLs at serve time using the incoming request's Host header and X-Forwarded-Proto. This ensures the card always reflects how the caller reached the agent (Route, port-forward, internal service) without requiring manual URL configuration. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/bridge/dynamiccard.go`:
- Around line 30-37: The code currently overwrites each interface URL with
baseURL, dropping any configured path/query; instead parse the existing iface
URL and replace only its scheme and host. In the loop over
cardCopy.SupportedInterfaces (variables: iface, copied, copied.URL), use
net/url.Parse on iface.URL (or copied.URL), set parsed.Scheme = scheme and
parsed.Host = r.Host, then set copied.URL = parsed.String(); if parsing fails,
fall back to baseURL. This preserves path and query while updating scheme/host.
In `@internal/cmd/serve.go`:
- Around line 430-433: Signed-card mode currently returns cached bytes from
bridge.SignedCardHandler when AGENT_CARD_SIGNED_PATH exists, which bypasses the
new per-request Host / X-Forwarded-Proto URL rewrite and leaves
supportedInterfaces with baked-in URLs; modify SignedCardHandler so that before
returning cached content it applies the per-request URL rewrite (inspect request
Host and X-Forwarded-Proto and update supportedInterfaces in the cached card
bytes) or delegate to dynamicCardHandler to produce a per-request rewritten card
(and re-sign/regenerate cached bytes if desired), ensuring supportedInterfaces
reflect the incoming request rather than the static baked URL.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 52f5d02f-edb1-4db2-b154-2f5b39b1a002
📒 Files selected for processing (2)
internal/bridge/dynamiccard.gointernal/cmd/serve.go
| baseURL := scheme + "://" + r.Host | ||
|
|
||
| // Rewrite all interface URLs to use the caller's base URL. | ||
| rewritten := make([]*a2a.AgentInterface, len(cardCopy.SupportedInterfaces)) | ||
| for i, iface := range cardCopy.SupportedInterfaces { | ||
| copied := *iface | ||
| copied.URL = baseURL | ||
| rewritten[i] = &copied |
There was a problem hiding this comment.
Preserve the configured interface path when rewriting URLs.
Overwriting copied.URL with scheme://host drops any path the card was configured with. Cards that intentionally point to /a2a or are exposed behind a route prefix will be rewritten to the wrong endpoint, so discovery succeeds but sends can go to the wrong path. Rewrite just the scheme/host and keep the existing path/query when one is present.
Suggested direction
import (
"encoding/json"
"log/slog"
"net/http"
+ "net/url"
"github.com/a2aproject/a2a-go/v2/a2a"
)
@@
rewritten := make([]*a2a.AgentInterface, len(cardCopy.SupportedInterfaces))
for i, iface := range cardCopy.SupportedInterfaces {
copied := *iface
- copied.URL = baseURL
+ if copied.URL == "" {
+ copied.URL = baseURL
+ } else if u, err := url.Parse(copied.URL); err == nil {
+ u.Scheme = scheme
+ u.Host = r.Host
+ copied.URL = u.String()
+ } else {
+ copied.URL = baseURL
+ }
rewritten[i] = &copied
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| baseURL := scheme + "://" + r.Host | |
| // Rewrite all interface URLs to use the caller's base URL. | |
| rewritten := make([]*a2a.AgentInterface, len(cardCopy.SupportedInterfaces)) | |
| for i, iface := range cardCopy.SupportedInterfaces { | |
| copied := *iface | |
| copied.URL = baseURL | |
| rewritten[i] = &copied | |
| baseURL := scheme + "://" + r.Host | |
| // Rewrite all interface URLs to use the caller's base URL. | |
| rewritten := make([]*a2a.AgentInterface, len(cardCopy.SupportedInterfaces)) | |
| for i, iface := range cardCopy.SupportedInterfaces { | |
| copied := *iface | |
| if copied.URL == "" { | |
| copied.URL = baseURL | |
| } else if u, err := url.Parse(copied.URL); err == nil { | |
| u.Scheme = scheme | |
| u.Host = r.Host | |
| copied.URL = u.String() | |
| } else { | |
| copied.URL = baseURL | |
| } | |
| rewritten[i] = &copied | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@internal/bridge/dynamiccard.go` around lines 30 - 37, The code currently
overwrites each interface URL with baseURL, dropping any configured path/query;
instead parse the existing iface URL and replace only its scheme and host. In
the loop over cardCopy.SupportedInterfaces (variables: iface, copied,
copied.URL), use net/url.Parse on iface.URL (or copied.URL), set parsed.Scheme =
scheme and parsed.Host = r.Host, then set copied.URL = parsed.String(); if
parsing fails, fall back to baseURL. This preserves path and query while
updating scheme/host.
| cardHandler := bridge.SignedCardHandler( | ||
| os.Getenv("AGENT_CARD_SIGNED_PATH"), | ||
| unsignedHandler, | ||
| dynamicCardHandler, | ||
| log.Logger, |
There was a problem hiding this comment.
Signed-card mode bypasses the new per-request URL rewrite.
bridge.SignedCardHandler serves cached file bytes when AGENT_CARD_SIGNED_PATH exists, so dynamicCardHandler only runs when the signed file is missing. In signed deployments, supportedInterfaces will still advertise whatever URL was baked into the file, which defeats the new Host / X-Forwarded-Proto rewrite behavior this PR is introducing.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@internal/cmd/serve.go` around lines 430 - 433, Signed-card mode currently
returns cached bytes from bridge.SignedCardHandler when AGENT_CARD_SIGNED_PATH
exists, which bypasses the new per-request Host / X-Forwarded-Proto URL rewrite
and leaves supportedInterfaces with baked-in URLs; modify SignedCardHandler so
that before returning cached content it applies the per-request URL rewrite
(inspect request Host and X-Forwarded-Proto and update supportedInterfaces in
the cached card bytes) or delegate to dynamicCardHandler to produce a
per-request rewritten card (and re-sign/regenerate cached bytes if desired),
ensuring supportedInterfaces reflect the incoming request rather than the static
baked URL.
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Pavel Anni <[email protected]>
Summary
github.com/a2aproject/a2a-gov0.3.x togithub.com/a2aproject/a2a-go/v2v2.2.0supportedInterfaces(A2A v1.0 spec) instead ofurl/protocolVersion(v0.3.0)iter.Seq2yield patterna2aCLI tool (a2a send,a2a discover)Key changes
URL+ProtocolVersionSupportedInterfacesa2a.TextPart{Text: "..."}a2a.NewTextPart("...")Execute(ctx, reqCtx, queue) errorExecute(ctx, execCtx) iter.Seq2[Event, error]MessageSendParamsSendMessageRequestCallMetaServiceParamsvia interceptorCloses #14
Test plan
make buildsucceedsmake test— all tests passa2a discovershows correct card formata2a sendworks against deployed agentdocsclaw chatstill works against deployed agentSummary by CodeRabbit
Documentation
New Features
Chores