Skip to content

feat: upgrade a2a-go to v2.2.0 (#14) - #18

Merged
pavelanni merged 5 commits into
mainfrom
feature/a2a-go-v2-upgrade
Apr 11, 2026
Merged

pavelanni merged 5 commits into
mainfrom
feature/a2a-go-v2-upgrade

Conversation

@pavelanni

@pavelanni pavelanni commented Apr 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Upgrade from github.com/a2aproject/a2a-go v0.3.x to github.com/a2aproject/a2a-go/v2 v2.2.0
  • Agent Cards now serve supportedInterfaces (A2A v1.0 spec) instead of url/protocolVersion (v0.3.0)
  • Executor rewritten from queue-based event writing to iter.Seq2 yield pattern
  • Enables compatibility with the a2a CLI tool (a2a send, a2a discover)

Key changes

Component Before (v1) After (v2)
Agent Card URL + ProtocolVersion SupportedInterfaces
Parts a2a.TextPart{Text: "..."} a2a.NewTextPart("...")
Executor Execute(ctx, reqCtx, queue) error Execute(ctx, execCtx) iter.Seq2[Event, error]
Send params MessageSendParams SendMessageRequest
Header injection CallMeta ServiceParams via interceptor

Closes #14

Test plan

  • make build succeeds
  • make test — all tests pass
  • Deploy to OpenShift and verify a2a discover shows correct card format
  • Verify a2a send works against deployed agent
  • Verify docsclaw chat still works against deployed agent

Summary by CodeRabbit

  • Documentation

    • Updated README with A2A CLI install and discovery instructions and a simplified single-line example request
    • Added design notes outlining the planned library migration
  • New Features

    • Agent card endpoint now serves dynamic agent URLs based on the incoming request
  • Chores

    • Upgraded A2A library to v2.2.0 and applied related internal updates

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]>
@coderabbitai

coderabbitai Bot commented Apr 11, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@pavelanni has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 32 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f4f71577-8974-4a17-a0a3-afc453581eb8

📥 Commits

Reviewing files that changed from the base of the PR and between dead797 and 88cd9e6.

📒 Files selected for processing (1)
  • README.md
📝 Walkthrough

Walkthrough

Upgrades the codebase to github.com/a2aproject/a2a-go/v2 v2.2.0, updating imports, go.mod, README, and docs; adapts AgentCard representation, message part APIs, client service-params injection, and rewrites the executor from queue-based error returns to a generator-style iterator yielding A2A events.

Changes

Cohort / File(s) Summary
Dependency Management
go.mod
Switch to github.com/a2aproject/a2a-go/v2 v2.2.0; add golang.org/x/mod; remove some gRPC genproto indirect deps.
Docs & README
README.md, docs/dev/2026-04-10-a2a-go-v2-upgrade-design.md
README A2A usage updated (CLI discover, compact curl example); new upgrade design doc describing v1→v2 API changes and migration notes.
Agent Card & Discovery
internal/bridge/agentcard.go, internal/cmd/serve.go, internal/bridge/dynamiccard.go
AgentCard now uses SupportedInterfaces created with a2a.NewAgentInterface; dynamic card handler added to rewrite interface URLs per request; removed hardcoded protocol version field.
Client & Delegation
internal/bridge/client.go
Migrate meta injection to ServiceParams via a CallInterceptor (serviceParamsInjector); use v2 part constructors (NewTextPart, NewDataPart) and a2a.SendMessageRequest; agent interface slice uses pointers.
Executor Runtime
internal/bridge/executor.go
Executor API changed from Execute(ctx, reqCtx, queue) error to Execute(ctx, execCtx) iter.Seq2[a2a.Event, error]; emits events via iterator yields (Submitted/Working/Artifact/Completed/Failed/Rejected/Cancelled); added generator-style Cancel.
Message & Part Handling
internal/bridge/message.go, internal/cmd/chat.go, other internal uses
Parts handling refactored to use part.Text() / part.Data() instead of type assertions; imports updated to v2 package paths; document ID and review-type extraction adjusted.

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...
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~55 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: upgrade a2a-go to v2.2.0' clearly and concisely summarizes the main change—upgrading the a2a-go dependency from v0.3.x to v2.2.0, which aligns with the primary objective of the entire changeset.
Linked Issues check ✅ Passed The PR comprehensively fulfills all coding requirements from issue #14: imports updated to v2 paths across all files, bridge components adapted to v2 APIs (SupportedInterfaces, iter.Seq2 executor, SendMessageRequest), cmd files updated to v2 types, and all test suite validations mentioned.
Out of Scope Changes check ✅ Passed All changes are directly related to the v2 upgrade objective. The addition of DynamicCardHandler in dynamiccard.go is in-scope as it supports the new SupportedInterfaces URL rewriting requirement tied to the protocol upgrade.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/a2a-go-v2-upgrade

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 91aba4a and dead797.

📒 Files selected for processing (2)
  • internal/bridge/dynamiccard.go
  • internal/cmd/serve.go

Comment on lines +30 to +37
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

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.

Suggested change
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.

Comment thread internal/cmd/serve.go
Comment on lines 430 to 433
cardHandler := bridge.SignedCardHandler(
os.Getenv("AGENT_CARD_SIGNED_PATH"),
unsignedHandler,
dynamicCardHandler,
log.Logger,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

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]>
@pavelanni
pavelanni merged commit 210f827 into main Apr 11, 2026
2 checks passed
@pavelanni
pavelanni deleted the feature/a2a-go-v2-upgrade branch April 11, 2026 01:17
@pavelanni pavelanni mentioned this pull request Apr 14, 2026
2 tasks done
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.

Upgrade a2a-go to v2

1 participant