Skip to content

refactor(rust): let the adk resolve the agent card url - #461

Merged
edenreich merged 2 commits into
mainfrom
refactor/issue-459-20261003-1720
Oct 3, 2026
Merged

edenreich merged 2 commits into
mainfrom
refactor/issue-459-20261003-1720

Conversation

@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

Summary

Still relevant - rust-adk 0.16.2 (released today) contains the fix from inference-gateway/rust-adk#195, so the generated main.rs no longer has to resolve the advertised card URL itself.

  • Bumped the inference-gateway-adk pin in internal/vendor/vendor.go from 0.16.1 to 0.16.2.
  • Dropped the agent_url resolution block and the AgentCardOverrides import from internal/templates/languages/rust/main.rs.tmpl; the builder now calls .with_agent_card_from_file(".well-known/agent-card.json", None) and the ADK applies the precedence A2A_AGENT_URL > the card file's own non-empty interface URL > http(s)://localhost:<A2A_SERVER_PORT>/a2a.
  • The manifest-declared URL branch is preserved without template code: config/agent.json already writes spec.card.supportedInterfaces[0].url into the generated card file, which is exactly the branch the ADK reads. A2A_AGENT_URL still lands in config.agent_url through the existing envy::prefixed("A2A_") load, so the env override is unchanged.
  • Reworked the Rust case in TestMainTemplates_DefaultCardURLToJSONRPCEndpoint to assert the generated main delegates to the ADK (card file passed with None, no A2A_AGENT_URL handling left in main.rs). The three URL sources stay covered: env and derived-default precedence is pinned by rust-adk's own advertised_agent_url_precedence test, and the manifest-declared / empty-interface card output stays pinned by TestAgentCardTemplate_EmitsV101Shape and TestAgentCardTemplate_DefaultsSupportedInterfaces.

Go ADK: no change

Checked inference-gateway/adk at v0.32.1 - nothing populates the card's interface URL from cfg.AgentURL, so the Go template's cmp.Or block in main.go.tmpl has to stay. Its test cases are untouched.

Behaviour note

One edge changes for Rust: a manifest with spec.server.scheme: https, no spec.card.supportedInterfaces[].url and no A2A_AGENT_URL previously advertised https://localhost:<port>/a2a; the ADK derives the scheme from A2A_TLS_ENABLE instead, so it now advertises http://... unless TLS is on - which is the more accurate advertisement for a server not actually serving TLS. No example hits this (every Rust example uses scheme: http), and setting A2A_AGENT_URL or a manifest interface URL pins it either way.

Verified with go build ./..., go vet ./..., go test ./... and by generating examples/rust-agent-ai.yaml.

no docs ticket: internal-only refactor - the documented A2A_AGENT_URL behaviour and its default are unchanged.

Closes #459

Comment thread internal/vendor/vendor.go Outdated
// mirrored here.
var GoBuiltins = map[string]string{
"github.com/inference-gateway/adk": "v0.32.1",
"github.com/inference-gateway/adk": "v0.31.1",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@claude This was on purpose, we use the latest version of the adk, make sure it works.

	"github.com/inference-gateway/adk":  "v0.32.1",

@inference-gateway-maintainer inference-gateway-maintainer Bot Oct 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Claude finished @edenreich's task in 2m 18s —— View job


Go ADK pin restored to v0.32.1

You were right - the branch commit had quietly downgraded github.com/inference-gateway/adk from v0.32.1 to v0.31.1 in internal/vendor/vendor.go:108. That was unintended collateral; this PR is a Rust-only refactor and should not have touched the Go pin. Restored in 6a1aad5.

  • Confirm the regression in the diff
  • Restore v0.32.1 (also the latest release of inference-gateway/adk)
  • Verify it works
  • Commit

Verification

  • go build ./..., go vet ./..., go test ./... - all green.
  • Generated examples/go-agent-ai.yaml into a scratch dir: go.mod now pins github.com/inference-gateway/adk v0.32.1, go mod tidy resolves it, and go build ./... on the generated project succeeds.
  • Generated main.go keeps the existing resolution line unchanged under v0.32.1: cfg.A2A.AgentURL = cmp.Or(cfg.A2A.AgentURL, "", "http://localhost:"+cfg.A2A.ServerConfig.Port+"/a2a").

The Rust pin stays at inference-gateway-adk 0.16.2 (also the latest), which is what the refactor actually depends on - that line is already on main from #460, so vendor.go in this PR is now a no-op diff against origin/main.

@edenreich

Copy link
Copy Markdown
Contributor

@claude

Checked inference-gateway/adk at v0.32.1 - nothing populates the card's interface URL from cfg.AgentURL, so the Go template's cmp.Or block in main.go.tmpl has to stay. Its test cases are untouched.

But the examples works as expected? or we have here a bug?

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @edenreich's task in 1m 29s —— View job


No bug - the Go examples serve the right URL

  • Read the Go main.go.tmpl resolution block
  • Check what Go adk v0.32.1 does with cfg.AgentURL vs the card file
  • Verify by generating examples/go-agent-ai.yaml

The Go template resolves the URL and then injects it into the card itself, so the served card is correct - it just does the work in generated code instead of delegating to the ADK.

Generated main.go from examples/go-agent-ai.yaml:

// line 182
cfg.A2A.AgentURL = cmp.Or(cfg.A2A.AgentURL, "", "http://localhost:"+cfg.A2A.ServerConfig.Port+"/a2a")
...
// line 247, inside WithAgentCardFromFile overrides
{"url": cfg.A2A.AgentURL, "protocolBinding": "JSONRPC", "protocolVersion": "1.0"},

The card file on disk has "url": "" (config/agent.json only writes a non-empty value when the manifest declares spec.card.supportedInterfaces[0].url), and the WithAgentCardFromFile override map replaces it at startup. Same for the extended card (main.go.tmpl:419). So the served /.well-known/agent-card.json always carries A2A_AGENT_URL > manifest URL > http://localhost:<port>/a2a.

Why the Go block can't be dropped

Checked inference-gateway/adk at v0.32.1: cfg.AgentURL is only read/written by config.Config and SetAgentURL - nothing copies it into the card's supportedInterfaces. The ADK's own examples do the same thing the template does, in app code:

  • examples/minimal/server/main.go:148 - URL: fmt.Sprintf("http://localhost:%s", cfg.A2A.ServerConfig.Port)
  • examples/ai-powered/server/main.go:231 - URL: agentURL

So this is the Go ADK's design (caller supplies the advertised URL), not a defect. rust-adk 0.16.2 added the convenience via inference-gateway/rust-adk#195, which is the asymmetry this PR exploits - Rust now passes None and lets the ADK fill it in.

The one thing worth filing (not a bug in this PR)

Both languages ship a card file with "url": "" when the manifest declares no interface URL - correct at runtime (both override it), but a stale artifact for anything that reads the file statically. Pre-existing on main for Go and unchanged by this PR; the Rust side now at least has the ADK fill it in-process. If you want symmetry, the lazy follow-up is a feature request on inference-gateway/adk mirroring rust-adk#195, after which main.go.tmpl loses the cmp.Or line and the override entry the same way.

Tests green: go test ./internal/templates/ -run 'TestMainTemplates_DefaultCardURLToJSONRPCEndpoint|TestAgentCardTemplate'. No code changes made - this was a question.

@edenreich
edenreich merged commit f5e438a into main Oct 3, 2026
1 check passed
@edenreich
edenreich deleted the refactor/issue-459-20261003-1720 branch October 3, 2026 17:41
inference-gateway-releaser Bot added a commit that referenced this pull request Oct 3, 2026
## [0.65.4](v0.65.3...v0.65.4) (2026-10-03)

### ♻️ Improvements

* **rust:** let the adk resolve the agent card url ([#461](#461)) ([f5e438a](f5e438a))

### 🐛 Bug Fixes

* serve and advertise the a2a json-rpc endpoint at /a2a in every language ([#457](#457)) ([71e2c82](71e2c82))
* **typescript:** register every a2a method the agent card advertises ([#458](#458)) ([7149295](7149295))

### 🔧 Miscellaneous

* **deps:** bump template pins to latest ([#460](#460)) ([503a054](503a054))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.65.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] Refactor generated Rust agent card URL now that rust-adk defaults it

1 participant