Repository navigation
fix(a2a): build the status agent card from the request that asked for it - #12918
Merged
diegosouzapw merged 2 commits intoSep 10, 2026
Merged
diegosouzapw merged 2 commits into
diegosouzapw merged 2 commits into
Conversation
/api/a2a/status loads the agent-card route handler in-process and calls GET() with no argument, so the card handler sees `request === undefined`. getBaseUrl() then cannot read `request.nextUrl.origin` and falls back to the hardcoded `http://localhost:20128`, which is exactly the hostname the S2 fix removed. A gateway reached at any other host advertises a card whose `url` points at localhost, and the dashboard shows that URL. Forward the status route's own request to the card handler, so the card is built from the origin the caller actually used. Reported as cheaper-inference#12887. The crash described there (card `null`) no longer reproduces on the tip: 0023a9e gave getBaseUrl() a `request?` guard, so the TypeError is gone. The wiring it masked is still missing, and the wrong-host URL is what remains.
diegosouzapw
merged commit Sep 10, 2026
ee21e7d
into
cheaper-inference:release/v3.8.51
8 of 16 checks passed
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
… it (cheaper-inference#12918) Boarded with 13 sibling PRs into one worktree off release/v3.8.51 and validated as a set: 132 focused tests pass across all 15 test files in the batch, typecheck:core is clean, check-changelog-integrity reports no lost base bullets, and check-file-size is green. Your PR merged without conflict against its siblings. Thank you — the write-up made this reviewable: measuring the behaviour on the release tip and showing the before/after table meant the defect could be confirmed rather than taken on faith.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
/api/a2a/statusbuilds its agent-card section by importing the/.well-known/agent.jsonroute handler and calling it in-process. It callsGET()with no argument, so the card handler getsrequest === undefinedandgetBaseUrl()cannot readrequest.nextUrl.origin. The card is then builtagainst the hardcoded
http://localhost:20128— the exact hostname the S2 fixremoved from that helper.
Effect: a gateway reached at any other host (LAN IP, reverse proxy, container
hostname) serves a status payload whose
agent.urlpoints at localhost, and theA2A dashboard shows that URL. The dedicated
/.well-known/agent.jsonendpoint iscorrect, because Next passes it a real request — only the in-process call is wrong.
Fix: forward the status route's own request to the card handler.
Verifying the report first (#12887)
The report says the missing argument makes
getBaseUrl()throw aTypeError,the surrounding
try/catchswallows it, and the panel rendersagent: null, skills: []. That half no longer reproduces on the tip.0023a9ec0changed the helper toso there is no throw any more and the card is returned. What that guard did was
mask the missing wiring: instead of a visible
null, the endpoint now reports aconfidently wrong URL. That is what this PR fixes;
getBaseUrl()is left alone.Why no test caught it
tests/unit/a2a-enabled-route.test.tscallsstatusRoute.GET()with no argumenttoo — the same shape as the bug — and asserts only
status/enabled/online,never the card. The route file is also outside
tsconfig.typecheck-core.json'sfileslist, so the missing argument was never a type error.Test
tests/unit/a2a-status-agent-card-12887.test.tscalls the status route with a realNextRequestforhttp://gateway.test:9999/api/a2a/status(withOMNIROUTE_BASE_URLunset) and assertsagent.url === "http://gateway.test:9999/a2a".The origin is deliberately not localhost, so the hardcoded fallback cannot pass by
accident; the two branches produce different strings.
before the fix: 4 pass, 1 fail — the new test,
actual: 'http://localhost:20128/a2a'after the fix: 5 pass, 0 fail
Mutation
Reverting the one wired line —
agentModule.GET(request)back toagentModule.GET()— turns the new test red again with the sameactual: 'http://localhost:20128/a2a'. The assertion is on the status route'soutput, not on
getBaseUrl()in isolation, so it pins the call site rather thanthe helper.
Closes #12887