Kagent

From akillness/jeo-skills · View interactive version

Kagent is an AI agent skill from the GitHub repository akillness/jeo-skills. Use when configuring, invoking, testing, or troubleshooting kagent Kubernetes-native AI agents, Agent and Harness CRDs, gRPC/A2A Sessions, or Substrate sandboxes. Covers discovering agents and templates, managing conversations via Sessions, streaming tasks over A2A, executing commands and transferri

How to use this skill

Skill file

kagent

When to use this skill

Use when configuring, invoking, testing, or troubleshooting kagent agents, custom resources, conversations, or sandboxes. kagent is a Kubernetes-native framework for building, deploying, and operating AI agents.

Route-outs

Instructions

1. Offline environment preflight

Before proposing any live cluster or API operations, run the local offline preflight helper:

python3 "$SKILL_DIR/scripts/preflight.py" --json

This discovers local kagent, kubectl, helm, and docker binaries without network calls or process execution.

2. Work with agents and templates

Discover and manage agent definitions in Kubernetes:

# Discover agent definitions and reusable templates
kagent agent list
kagent agent get <name>
kagent agent template list
kagent agent template get <template-name>

3. Manage Sessions and invoke tasks via A2A

Conversations and runtime lifecycles are managed through Sessions (backed by PostgreSQL and gRPC, not Kubernetes CRDs):

# Create a conversation session (always provide a unique request-id for idempotent retries)
kagent agent session create --agent <name> --request-id <unique-request-id>

# List and inspect sessions
kagent agent session list
kagent agent session get <session-id>

# Invoke an agent conversation through A2A
kagent agent invoke --session <session-id> --task "Analyze recent pod failures in the prod namespace"
# Stream response tokens:
kagent agent invoke --session <session-id> --task "Generate migration YAML" --stream

# Delete a session (cleans up runtime resources while preserving the agent CRD)
kagent agent session delete <session-id>

4. Use standalone Substrate sandboxes for isolated tasks

When a task needs an isolated environment to run code, process data, or produce artifacts without agent conversation overhead, use kagent sandboxes:

# Discover available sandbox templates
kagent sandbox templates -n <namespace> -o json

# Create a sandbox with bounded TTL
kagent sandbox create <template-name> -n <namespace> --request-id <unique-request-id> --ttl 15m -o json

# Transfer input files (streaming upload up to 64 MiB)
kagent sandbox upload <sandbox-id> ./input.py /data/workspace/input.py

# Execute command inside sandbox
kagent sandbox exec <sandbox-id> -- python3 /data/workspace/input.py

# Download output artifacts
kagent sandbox download <sandbox-id> summary.json ./summary.json

# Delete sandbox when done
kagent sandbox delete <sandbox-id>

See Working in sandboxes for full CLI commands, MCP tool mappings, recovery workflows, and agent setup instructions.

5. Architectural boundaries and safety gates

Read Architecture and CRDs to understand resource ownership:

Examples

Example 1: Creating and invoking an agent session

# 1. Create a session with an idempotent request ID
kagent agent session create --agent k8s-debugger --request-id req-$(date +%s)
# Output returns session ID: sess-0192a4bc

# 2. Invoke the agent to diagnose cluster issues
kagent agent invoke --session sess-0192a4bc --task "Check crashed pods in ingress-nginx namespace" --stream

# 3. Clean up the session when finished
kagent agent session delete sess-0192a4bc

Example 2: Running offline data transformation in a sandbox

# 1. Create a Python sandbox for 10 minutes
kagent sandbox create python-runner -n default --request-id req-sandbox-$(date +%s) --ttl 10m -o json

# 2. Stage the input script
kagent sandbox upload 8f24bc91 ./process.py process.py

# 3. Execute the script within workspace
kagent sandbox exec 8f24bc91 -- python3 process.py

# 4. Download generated output and clean up
kagent sandbox download 8f24bc91 output.json ./output.json
kagent sandbox delete 8f24bc91

Best practices

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.