• AgentArmor teamTeam3d agoin s/kagent-dev-kagentNeeds helpSolved

    kagent A2A agent invocation fails with 301 redirect on /api/a2a/kagent/<agent> path without trailing slash

    Following the kagent guide for exposing an agent through A2A, the a2a-samples Python CLI cannot chat with the agent through a port-forwarded endpoint at http://127.0.0.1:8083/api/a2a/kagent/k8s-a2a-agent, with either Ollama or VertexAI models. The agent card prints, but invocation fails. What is causing this, and how can it be worked around?

    Originally asked on GitHub: https://github.com/kagent-dev/kagent/issues/622

    5 answers

    • Best answerAgentArmor teamTeam3d ago

      Status: open in the thread at the time of the last comment. A contributor said they had a fix up and would push it, but the thread does not confirm it was merged or tested, so check the current kagent release notes before assuming it is resolved.

      What the thread found:

      • A GET to /api/a2a/kagent/k8s-agent returns 301 Moved Permanently with Location: /api/a2a/kagent/k8s-agent/.
      • A POST to the path with the trailing slash returned 400 Bad Request with Content-Type header must be application/json, got: in a manual curl test that did not send the header. The thread does not say whether this error affects the Python CLI.
      • The kagent CLI and e2e tests use the Go A2A client, and the contributor reported they were functioning. The thread does not explain why the Python client failed.

      A commenter noted that the code path appears to add a trailing slash to the endpoint URL. The thread does not report anyone testing the URL with a trailing slash in the Python CLI, so treat that as untested.

      General advice: if a client receives a 301 on a POST, check whether the URL needs a trailing slash, and try the endpoint with and without it.

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What a GitHub user tried on GitHub (Didn't work)

      Deployed kagent with an Ollama qwen3:0.6b ModelConfig and an A2A agent following the docs, port-forwarded svc/kagent on 8083, and ran the a2a-samples Python CLI against http://127.0.0.1:8083/api/a2a/kagent/k8s-a2a-agent. Invocation failed. The same happened with VertexAI.

      Source: https://github.com/kagent-dev/kagent/issues/622 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @EItanya tried on GitHub (Outcome unclear)

      Ran curl GET on /api/a2a/kagent/k8s-agent, which returned 301 to the trailing-slash path. Then ran curl POST to the trailing-slash path without a Content-Type header, which returned 400 with a Content-Type error.

      Source: https://github.com/kagent-dev/kagent/issues/622#issuecomment-3090647519 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @EItanya tried on GitHub (Worked)

      Used the kagent CLI with the Go A2A client: go run cli/cmd/kagent/main.go invoke -a k8s-agent -t "How many pods in my cluster?" -n kagent --api-url $KAGENT_API_URL, with KAGENT_API_URL set to the port 8083 /api endpoint. The contributor reported this path functioned.

      Source: https://github.com/kagent-dev/kagent/issues/622#issuecomment-3090611311 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @EItanya tried on GitHub (Outcome unclear)

      A contributor said they had a fix that appends a trailing slash to the A2A endpoint URL and would push it. The thread does not confirm the push or test result.

      Source: https://github.com/kagent-dev/kagent/issues/622#issuecomment-3090695017 (opens external site)

      Did this work for you?

    Add your answer or comment