Bringing your own LangGraph agent to kagent#
You can bring your own LangGraph agent to kagent by configuring the KAgentCheckpointer in your LangGraph agent code. The KAgentCheckpointer stores the LangGraph state in kagent and enables distributed execution and session recovery.
Prerequisites#
Install kagent by following the quick start guide.
Building a LangGraph agent#
The following example builds a simple LangGraph agent from the kagent code repository. The sample app is built with LangGraph SDK and performs a currency exchange lookup task. It uses Google's Gemini model as the underlying LLM provider.
-
Clone the kagent code repository.
git clone https://github.com/kagent-dev/kagent.gitcd kagent -
Optional: If you do not have a Docker registry, you can use the
make helm-install
command to create one as part of installing kagent in your kind cluster. -
Build the custom agent image and push it to your local Docker registry.
cd pythondocker build . -f samples/langgraph/currency/Dockerfile\-t localhost:5001/langgraph-currency:latest \--build-arg DOCKER_REGISTRY=localhost:5001 \--build-arg VERSION=latest \--push
Creating a BYO Agent resource#
Now that you have your own custom agent image, you can create a BYO Agent resource for kagent to manage.
-
Save the API key for your LLM provider, such as Gemini, in an environment variable.
export GOOGLE_API_KEY=your-api-key-here -
Create a secret with the API key.
kubectl create secret generic kagent-google -n kagent \--from-literal=GOOGLE_API_KEY=$GOOGLE_API_KEY \--dry-run=client -oyaml | kubectl apply -f - -
Create a BYO Agent resource.
kubectl apply -f - <<EOFapiVersion: kagent.dev/v1alpha2kind: Agentmetadata:name: langgraph-agentnamespace: kagentspec:description: This is LangGraph currency agent.type: BYObyo:deployment:image: localhost:5001/langgraph-currency:latestenv:- name: GOOGLE_API_KEYvalueFrom:secretKeyRef:name: kagent-googlekey: GOOGLE_API_KEYEOF
Testing the A2A endpoint#
The A2A endpoint is exposed on the port 8083
of the kagent controller service.
-
Enable port-forwarding on the
kagent-controller
service.Note that you could also expose the A2A endpoint publicly by using a gateway.
kubectl port-forward svc/kagent-controller 8083:8083 -n kagent -
To test that the agent is available and has an agent card, send a request to the
.well-known/agent.json
endpoint. Note the API endpoint follows the pattern/api/a2a/{namespace}/{agent-name}/.well-known/agent.json
.curl localhost:8083/api/a2a/kagent/langgraph-agent/.well-known/agent.jsonExample output: This JSON object describes the agent as per the A2A protocol.
{"name": "langgraph_agent","description": "This is Langgraph currency agent.","url": "http://127.0.0.1:8083/api/a2a/kagent/langgraph-agent/","version": "","capabilities": {"streaming": true,"pushNotifications": false,"stateTransitionHistory": true},"defaultInputModes": ["text"],"defaultOutputModes": ["text"],"skills": []}
Invoking the agent#
You can invoke the agent through the kagent dashboard or kagent CLI.
Dashboard#
Launch the dashboard with kagent dashboard
, find your langgraph-agent
, and start chatting. For complete steps, see the Your First Agent guide.

kagent CLI#
To use the kagent CLI, make sure that the controller is still being port-forwarded.
Then, use the invoke command. For more options, run kagent help invoke
.
kagent invoke --agent langgraph-agent --task "Show me latest exchange rate between EUR and USD"
Example output: The output includes both the response as well as the details of the response. The formatting is in JSON but can be quite long, depending on the call and the agent configuration.
{"artifacts": [{"artifactId": "4d8a78c8-7e15-41c2-9b00-6bd27a156663","parts": [{"kind": "text","text": "The latest exchange rate between EUR and USD is 1 EUR = 1.1793 USD."}]}],...