diff --git a/.agents/skills/agent-toolkit-components/SKILL.md b/.agents/skills/agent-toolkit-components/SKILL.md new file mode 100644 index 00000000..6005a8e5 --- /dev/null +++ b/.agents/skills/agent-toolkit-components/SKILL.md @@ -0,0 +1,76 @@ +--- +name: agent-toolkit-components +description: Connect agent code to the components of an installed Intel® Agent Toolkit. Use when someone says "connect my agent to the toolkit", "give my LangGraph agent a key", "use Redis or pgvector for memory", "run code in a sandbox", "deploy my agent in its own namespace", or reports connection resets, 401s, WRONGPASS, vector dimension errors or sandbox SDK timeouts. Covers the LiteLLM endpoint and per-agent virtual keys, Redis Stack and pgvector memory, Agent Sandbox code execution (Python SDK, ServiceAccount token, RBAC, Kata microVMs), OpenShell policy sandboxes, KubeRay, Langfuse tracing and OpenTelemetry, for LangGraph, CrewAI, the OpenAI SDK or custom agents. +--- + +# Use the Intel® Agent Toolkit components from agent code + +This file is a summary. The exact steps, commands and fixes are in the `references/` file that each table row points to: open that file before you answer. + +## 1. See what is installed + +```bash +kubectl get ns litellm redis pgvector agent-sandbox-system openshell-system ray-system langfuse --ignore-not-found +``` + +A component that was never installed has no namespace. One switched off after install keeps running until it is torn down. The switches live in `env//config.agent-toolkit.yaml`; see the agent-toolkit-configuration skill. `kubectl` must point at the cluster (`export KUBECONFIG=/env//kubeconfig.yaml`; see `AGENTS.md`). + +## 2. Pick endpoints and credentials + +| Service | In-cluster endpoint | Credential: Secret (namespace) → key | +|---|---|---| +| LiteLLM (OpenAI API) | `http://litellm.litellm.svc.cluster.local:4000/v1` | Mint a virtual key with `litellm-master-key` (litellm) → `master_key` | +| Redis Stack | `redis-stack-server.redis.svc.cluster.local:6379` | `redis-stack-server-credentials` (redis) → `REDIS_URL` | +| pgvector | `pgvector.pgvector.svc.cluster.local:5432`, db `agentdb` | `pgvector-credentials` (pgvector) → `DATABASE_URL`, `POSTGRES_DSN` | +| Agent Sandbox router | `http://sandbox-router-svc.agent-sandbox-system.svc.cluster.local:8080` | A ServiceAccount token, checked by TokenReview: the pod's own token, or `kubectl create token -n ` | +| OpenShell gateway | `openshell.openshell-system.svc.cluster.local:8080` (mTLS, through the CLI) | `openshell-client-tls` (openshell-system), full admin | +| Ray | `ray://ray-cluster-head-svc.ray-system.svc.cluster.local:10001` | Dashboard: `ray-dashboard-auth` (ray-system) | +| Langfuse | `http://langfuse-web.langfuse.svc.cluster.local:3000` | `langfuse-api-keys` (litellm) → `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY` | +| OpenTelemetry | `opentelemetry-collector.monitoring.svc.cluster.local:4317` (gRPC), `:4318` (HTTP) | none | + +Read a value into a variable, never to the screen: `VAL=$(kubectl get secret -n -o jsonpath='{.data.}' | base64 -d)`. To see which keys a Secret has: `kubectl get secret -n -o go-template='{{range $k,$v := .data}}{{$k}}{{"\n"}}{{end}}'`. + +## 3. Put the agent where it can reach them + +The toolkit services are in an Istio ambient mesh with STRICT mTLS, and LiteLLM admits only listed namespaces. A pod outside the mesh, or one the policy does not allow, gets a **connection reset** and no error message. Follow `references/namespace-onboarding.md`: +1. label the namespace `istio.io/dataplane-mode=ambient`; +2. add it to `litellm_allowed_namespaces`; +3. copy the Secrets; +4. add sandbox RBAC if needed. + +## 4. Wire each service + +Steps marked **(changes the cluster)** in the references create or change objects. Show the user the command and get an OK first. + +| Service | Reference | +|---|---| +| LiteLLM: keys, URLs, model names, guardrail responses | `references/litellm.md` | +| Redis and pgvector: URLs, schema, the 1536-dimension tables | `references/memory.md` | +| Agent Sandbox and Kata: SDK code, RBAC, router authentication, isolation | `references/sandbox.md` | +| OpenShell: CLI, sandboxes, allowed binaries | `references/openshell.md` | +| KubeRay, Langfuse, OpenTelemetry | `references/ray-and-tracing.md` | + +## Rules + +- One virtual key per agent, limited to its models, with a budget. Never give agent code the master key. +- Mount credentials from Secrets (`secretKeyRef`). Never paste them into code, chat or logs. +- Tearing a component down and installing it again makes new credentials: Redis and pgvector passwords, OpenShell certificates and key, and the Ray dashboard password. Re-read or re-copy them afterwards. A plain re-run of install keeps them, and LiteLLM virtual keys survive both. +- Code inside an Agent Sandbox reaches only the public internet. It cannot reach LiteLLM, Redis, pgvector, cluster DNS or the Kubernetes API, by design. Pass data in and out through the SDK. +- Behind a proxy, set `NO_PROXY=.svc,.cluster.local,localhost,127.0.0.1` in agent pods. +- Use model names from `GET /v1/models`, not from examples. + +## Fast answers + +| Symptom | Cause | Fix | +|---|---|---| +| Connection reset to any toolkit service | Namespace not in the mesh, or not allowed by LiteLLM | `references/namespace-onboarding.md` | +| LiteLLM 400, 401, 403 or 429 about the key | Read `error.type` in the body: `budget_exceeded`, `expired_key`, `key_model_access_denied`, `auth_error` or `token_not_found_in_db`. The status code for each differs between LiteLLM versions. | Check the key with `/key/info`; `references/litellm.md` | +| LiteLLM 500 `Blocked by the content-safety guardrail: ...` | Guardrail decision (or the guard is down) | Read the reason; agent-toolkit-troubleshoot skill, GRD-1 | +| `WRONGPASS invalid username-password pair` | An old password (Redis was reinstalled), or a client that sends an empty username | Use the current `REDIS_URL` | +| `expected 1536 dimensions, not N` | The pre-created pgvector tables are 1536-d | Create a table with your dimension | +| Sandbox SDK `SandboxWarmPoolNotFoundError`, or 403 `... in the namespace "default"` | Wrong namespace (the SDK default is `default`) or wrong warm pool name | `namespace="agent-sandbox-system"`, `warmpool="python-pool"` | +| Sandbox SDK 403 `cannot create resource "sandboxclaims"` | No RBAC for the pod's ServiceAccount | Role in `references/sandbox.md` | +| `SandboxRequestError` with `status_code` 401 | No ServiceAccount token, an expired one, or one made with `--audience` | `extra_headers={"Authorization": f"Bearer {token}"}` with the pod's token; `references/sandbox.md` | +| OpenShell `policy_denied` | The calling program is not in the provider's `binaries` | `references/openshell.md` | + +Anything else: use the agent-toolkit-troubleshoot skill. diff --git a/.agents/skills/agent-toolkit-components/references/litellm.md b/.agents/skills/agent-toolkit-components/references/litellm.md new file mode 100644 index 00000000..6fa11816 --- /dev/null +++ b/.agents/skills/agent-toolkit-components/references/litellm.md @@ -0,0 +1,92 @@ +# LiteLLM: the agents' model endpoint + +LiteLLM is the OpenAI-compatible gateway in front of every model. It provides virtual keys, budgets, the content-safety guardrail, and a Langfuse trace for every call. + +## Endpoints + +| From | Base URL | +|---|---| +| A pod in an allowed namespace (`namespace-onboarding.md`) | `http://litellm.litellm.svc.cluster.local:4000/v1` | +| Outside the cluster, `routing_mode: subdomain` (default) | `https://litellm./v1` | +| Outside the cluster, `routing_mode: path` (main track) | `https:///litellm/v1` | +| A laptop without DNS | `kubectl port-forward -n litellm svc/litellm 4000:4000`, then `http://localhost:4000/v1` | + +The non-secret config map `litellm-credentials` in `litellm` names this install's API host (`api_url` or `hostname`, depending on the version) and admin UI (`ui_url`, the full address): `kubectl get cm litellm-credentials -n litellm -o jsonpath='{.data}'`. + +Path mode with the toolkit default `litellm_public_paths: []` publishes no API route at all on the main track: the gateway gets one route per listed path. If `https:///litellm/v1/models` redirects to a sign-in page, set `litellm_public_paths` to the API paths (agent-toolkit-configuration skill). + +From outside, trust the gateway CA when TLS is self-signed: `env//logs/toolkit-manager-ca.crt` under the Toolkit Manager root. Pass it to curl with `--cacert`, or to Python with `REQUESTS_CA_BUNDLE` / `SSL_CERT_FILE`. + +## Keys + +- **Master key**: Secret `litellm-master-key`, key `master_key`, namespace `litellm`. Admin only, for minting and managing keys. Never put it in agent code or config. +- **Virtual key**: one per agent, limited to the models it needs, with a budget and an expiry. + +Mint a virtual key and store it as Secret `-litellm` in the agent's namespace **(changes the cluster)**. The keys go into variables and are never printed or written to a file: + +```bash +MK=$(kubectl get secret litellm-master-key -n litellm -o jsonpath='{.data.master_key}' | base64 -d) +KEY=$(curl -s --cacert env//logs/toolkit-manager-ca.crt "https://litellm./key/generate" \ + -H "Authorization: Bearer $MK" -H 'Content-Type: application/json' \ + -d '{"key_alias":"","models":[""],"max_budget":10,"duration":"30d"}' | jq -ej .key) && + printf %s "$KEY" | kubectl create secret generic -litellm -n --from-file=OPENAI_API_KEY=/dev/stdin +unset MK KEY +``` + +`jq -e` makes a failed call stop before the Secret is created (the response has no `key`; repeat the call with `jq .error` to see why). Keep `-j`: it leaves out the trailing newline, which would end up in the key. + +Or through a port-forward, with `http://localhost:4000/key/generate`. This works even when `litellm_public_paths` limits what the external host publishes. + +Mount the Secret's `OPENAI_API_KEY` in the agent pod. Manage keys (updates and deletes change the cluster) with `GET /key/list?return_full_object=true`, `GET /key/info?key=`, `POST /key/update` and `POST /key/delete` (`{"keys": [...]}` or `{"key_aliases": [...]}`). Keys and spend live in the platform PostgreSQL, so they survive a toolkit teardown. + +Admin UI: on the main track `https://litellm-ui./ui/` (path mode: `https:///litellm/ui/`), with Keycloak sign-in. On the release track `https://litellm./ui/`, user `admin`, password = master key. The trailing slash is required. + +## Model names + +Always take names from the live list rather than from docs: + +```bash +KEY=$(kubectl get secret -litellm -n -o jsonpath='{.data.OPENAI_API_KEY}' | base64 -d) +curl -s http://localhost:4000/v1/models -H "Authorization: Bearer $KEY" | jq -r '.data[].id' +``` + +Usually present with the toolkit defaults: + +| Name | What | +|---|---| +| `qwen2-5-coder-14b` | The default chat model (`llm_services_autodeploy_models`) | +| `hybrid-router` | Picks a model per request by cost and latency (`hybrid_router_enabled`) | +| `vllm-sr/auto` | vLLM Semantic Router, only with `vllm_sr_enabled: true` | +| `qwen3guard` | The guard model. It is used by the guardrail; agents should not call it. | + +More models: `./model-manager deploy ` from the Toolkit Manager root (catalog: `env//models.yaml`) **(changes the cluster)**. Embedding models serve `/v1/embeddings`. None is deployed by default. + +## Client configuration + +The OpenAI SDK, LangChain `ChatOpenAI`, CrewAI and LangGraph all read: + +```bash +export OPENAI_BASE_URL=http://litellm.litellm.svc.cluster.local:4000/v1 +export OPENAI_API_KEY= +export NO_PROXY=.svc,.cluster.local,localhost,127.0.0.1 # when the pod has proxy variables +``` + +- Set the client timeout to at least 180 s. CPU inference under load is slow. +- Requests from one client IP are rate-limited at the external gateway (600 a minute). In-cluster calls do not pass that gateway. +- Every request, embeddings included, is screened by the guardrail when it is on. A block is HTTP 500 with a message starting `Custom code guardrail execution failed: Blocked by the content-safety guardrail:`. Handle it as "refused", not as a crash. The reasons are listed in the agent-toolkit-troubleshoot skill (`references/inference.md`, GRD-1). +- Tag traces for Langfuse with LiteLLM metadata, for example `extra_body={"metadata": {"trace_user_id": "", "session_id": ""}}` in the OpenAI Python SDK. + +## Reading errors + +Classify a LiteLLM error by `error.type` and `error.message` in the JSON body, not by the status code alone. The codes differ between LiteLLM versions; for example, an over-budget key is 400 on the release track and 429 on the main track. + +| `error.type` or message | Meaning | +|---|---| +| `budget_exceeded` | The key's budget is spent | +| `expired_key` | The key has expired | +| `key_model_access_denied` (or `team_model_access_denied`) | The key may not use this model | +| `auth_error` (no key sent) or `token_not_found_in_db` (unknown or deleted key) | Missing or invalid key | +| `Invalid model name passed in model=...` (400) | Not a registered name; check `/v1/models` | +| 500 with the guardrail prefix | Guardrail decision | +| 429 with no LiteLLM error body | The external gateway's rate limit (600 a minute per client IP) | +| Other 500, 503, 504 | Model or gateway problem (agent-toolkit-troubleshoot skill) | diff --git a/.agents/skills/agent-toolkit-components/references/memory.md b/.agents/skills/agent-toolkit-components/references/memory.md new file mode 100644 index 00000000..287a3ff7 --- /dev/null +++ b/.agents/skills/agent-toolkit-components/references/memory.md @@ -0,0 +1,88 @@ +# Redis Stack and pgvector from agent code + +Both services are inside the Istio ambient mesh with STRICT mTLS. A client pod must run in an ambient namespace (`namespace-onboarding.md`), otherwise the connection is reset. They have no external endpoint. From a laptop, use `kubectl port-forward`. + +## Redis Stack: short-term memory + +Use it for session and chat state, LangGraph checkpoints, semantic caches and RediSearch vector indexes. It is open-source Redis 8.10.3 with search and JSON built in (toolkit revisions before #43, including the ones Toolkit Manager `release-1.2` and `release-2.0` pin, install Redis Stack 7.4): one replica, password required, no TLS (the mesh encrypts traffic). + +| | Value | +|---|---| +| Host | `redis-stack-server.redis.svc.cluster.local:6379` | +| Secret | `redis-stack-server-credentials` in ns `redis` | +| Keys | `REDIS_URL`, `REDIS_PASSWORD` | +| URL form | `redis://default:@redis-stack-server.redis.svc.cluster.local:6379` | +| Storage | 10Gi PVC `db-redis-stack-server-0` (`redis_stack_persistence_size`, fixed after the first install) | + +```bash +export REDIS_URL=$(kubectl get secret redis-stack-server-credentials -n redis -o jsonpath='{.data.REDIS_URL}' | base64 -d) # holds the password; do not echo +``` + +```python +import os, redis +r = redis.Redis.from_url(os.environ["REDIS_URL"]) +r.ping() +``` + +The same `REDIS_URL` works for LangGraph's Redis checkpointer and for RedisVL or LangChain `RedisVectorStore`. + +- Use the URL as stored (`redis://default:@...`). `WRONGPASS invalid username-password pair` usually means an old password after Redis was reinstalled; some clients also fail when the username is empty. +- A namespace other than `redis` (`redis_stack_namespace`) changes the host. Set it before the first install. + +## pgvector: long-term memory and RAG store + +PostgreSQL 16 with the `vector` extension. + +| | Value | +|---|---| +| Host | `pgvector.pgvector.svc.cluster.local:5432` | +| Database / user | `agentdb` / `agentuser` (`pgvector_database`, `pgvector_username`) | +| Secret | `pgvector-credentials` in ns `pgvector` | +| Keys | `DATABASE_URL` (URL), `POSTGRES_DSN` (libpq `key=value`), `host`, `port`, `database`, `username`, `password` | +| Storage | 20Gi PVC `data-pgvector-0` (`pgvector_storage_size`, fixed after the first install) | + +```bash +DATABASE_URL=$(kubectl get secret pgvector-credentials -n pgvector -o jsonpath='{.data.DATABASE_URL}' | base64 -d) # holds the password; do not echo +``` + +- `psycopg.connect(os.environ["POSTGRES_DSN"])` works as is. +- SQLAlchemy and LangChain `PGVector` need the scheme `postgresql+psycopg://`. Replace the `postgresql://` prefix of `DATABASE_URL`. +- `agentuser` is the database superuser; there is no separate `postgres` role. +- Do not change `pgvector_database` or `pgvector_username` after the first install. The database was initialised with the old names, and validation then fails with `FATAL: role "" does not exist`. + +### Tables created at install + +| Table | Purpose | Notable columns | +|---|---|---| +| `agent_memory` | Long-term memory | `agent_id`, `user_id`, `session_id`, `content`, `embedding VECTOR(1536)`, `metadata JSONB` | +| `agent_events` | Audit and event log | `event_type`, `payload JSONB`, `duration_ms` | +| `agent_cache` | Semantic cache | `cache_key` (unique), `embedding VECTOR(1536)`, `value JSONB`, `hit_count`, `expires_at` | + +The embedding columns are fixed at **1536 dimensions** with HNSW cosine indexes. An embedding model with another size fails with `expected 1536 dimensions, not N`. Create your own table with the right dimension (for example `VECTOR(768)` for a 768-dimension model), or alter the column before storing data. + +## Embeddings + +Embeddings through LiteLLM need an embedding model deployed in the inference layer. None is deployed by default. Deploy one with `./model-manager deploy ` from the Toolkit Manager root **(changes the cluster)**, then use the name that `GET /v1/models` returns. If `/v1/embeddings` then fails with HTTP 400, see LLM-3 in the agent-toolkit-troubleshoot skill (`references/inference.md`): some versions register embedding models in LiteLLM in a way that breaks this call. + +## Wiring credentials into an agent pod + +The Secrets live in the service namespaces. Copy them into the agent namespace **(changes the cluster)**, or sync them with your secret manager, then reference them: + +```yaml +env: + - name: REDIS_URL + valueFrom: {secretKeyRef: {name: redis-stack-server-credentials, key: REDIS_URL}} + - name: DATABASE_URL + valueFrom: {secretKeyRef: {name: pgvector-credentials, key: DATABASE_URL}} +``` + +Tearing down and reinstalling Redis or pgvector deletes the data and generates **new passwords**. Copy the Secrets again afterwards. + +## Inspect + +```bash +kubectl get pods,pvc,svc -n redis +kubectl logs -n redis redis-stack-server-0 +kubectl get pods,pvc -n pgvector +kubectl logs -n pgvector pgvector-0 +``` diff --git a/.agents/skills/agent-toolkit-components/references/namespace-onboarding.md b/.agents/skills/agent-toolkit-components/references/namespace-onboarding.md new file mode 100644 index 00000000..7ab01d1c --- /dev/null +++ b/.agents/skills/agent-toolkit-components/references/namespace-onboarding.md @@ -0,0 +1,86 @@ +# Run an agent in its own namespace + +The toolkit namespaces (`redis`, `pgvector`, `agent-sandbox-system`, `ray-system`, `litellm`, `langfuse`) are in the Istio **ambient** mesh, and mesh-wide mTLS is **STRICT**. A pod outside the mesh, or one the policy does not allow, gets a **connection reset**. There is no HTTP error and no message saying why. + +Do these four steps for every namespace that runs agent code. Each one changes the cluster; show the user the commands first. + +## 1. Join the mesh **(changes the cluster)** + +```bash +kubectl label namespace istio.io/dataplane-mode=ambient +``` + +Ambient mode picks up running pods without a restart. Check: `kubectl get ns -L istio.io/dataplane-mode` shows `ambient`. If a pod still gets resets after a minute, restart it. + +## 2. Allow the namespace to call LiteLLM **(changes the cluster)** + +LiteLLM admits only the namespaces in `litellm_allowed_namespaces`. Add yours in `env//config.agent-toolkit.yaml`. The value **replaces** the default list, so keep the existing entries: + +```yaml +litellm_allowed_namespaces: + - "{{ gateway_namespace | default('envoy-gateway-system') }}" + - "{{ litellm_namespace | default('litellm') }}" + - "{{ agent_sandbox_namespace }}" + - "{{ kuberay_namespace }}" + - +``` + +- Copy the shipped entries from `config.yaml` in this repo rather than from this page, in case they have changed. +- Main track: the inference layer's own default also lists the model-manager Jobs namespace (`"{{ llm_services_mm_namespace | default('model-manager') }}"`), and the toolkit list drops it. Add it back if model deploys are started from Headlamp. + +Then apply from the Toolkit Manager root: + +```bash +./toolkit_manager.sh install litellm --only --env +``` + +The LiteLLM access policies are applied on every run, so no reconcile flag is needed. Check: `kubectl get authorizationpolicy litellm-ingress -n litellm -o jsonpath='{.spec.rules[*].from[*].source.namespaces}'`. + +While OpenShell is on, LiteLLM also admits every pod IP in the cluster (`litellm_allow_pod_network` follows `openshell_enabled`). Still list your namespace. If OpenShell is later turned off, that wider rule goes away on the next LiteLLM run. + +## 3. Bring the credentials **(changes the cluster)** + +Secrets are namespaced. Copy what the agent needs into `` without printing the values: + +```bash +copy_secret() { # copy_secret (needs jq) + kubectl get secret "$1" -n "$2" -o json \ + | jq 'del(.metadata.namespace,.metadata.resourceVersion,.metadata.uid,.metadata.creationTimestamp,.metadata.ownerReferences,.metadata.labels,.metadata.annotations,.metadata.managedFields)' \ + | kubectl apply -n "$3" -f - +} +copy_secret redis-stack-server-credentials redis +copy_secret pgvector-credentials pgvector +``` + +For LiteLLM, mint a virtual key for the agent and store only that key: `litellm.md` puts it straight into Secret `-litellm` in ``. Never copy `litellm-master-key`. + +Copies do not follow changes. After a component is torn down and reinstalled (new password), copy again. + +## 4. Sandbox access (only if the agent uses Agent Sandbox) **(changes the cluster)** + +Create the Role and RoleBinding in `sandbox.md` for the agent's ServiceAccount. The agent sends that ServiceAccount's own token to the router; there is no Secret to copy. + +## Who can reach what + +| From | To | Allowed when | +|---|---|---| +| Ambient pod | Redis, pgvector, sandbox router, Ray, Langfuse | Always (mTLS) | +| Ambient pod | LiteLLM `:4000` | Its namespace is in `litellm_allowed_namespaces`, or OpenShell is on | +| Pod outside the mesh | Redis, pgvector, sandbox router, Ray, Langfuse | Never (reset). Label the namespace. | +| Pod outside the mesh | LiteLLM `:4000` | Only while OpenShell is on (LiteLLM then accepts plaintext from pod IPs) | +| Agent Sandbox pod | Anything in the cluster | Never, by design (`sandbox.md`) | +| OpenShell sandbox | LiteLLM `:4000`, cluster DNS, OpenShell gateway, public internet | By the OpenShell policy | +| Outside the cluster | `https://.` | Through the shared gateway; see below | + +Your own HTTPRoute on the shared gateway inherits the gateway-wide auth policy unless the route has its own SecurityPolicy. On the release track that policy checks a LiteLLM key; on the main track it requires a Keycloak JWT bearer token. Either send that credential, or give your route its own SecurityPolicy, the way the shipped `*-no-auth` policies do **(changes the cluster)**. + +## When it still fails + +```bash +kubectl get ns -L istio.io/dataplane-mode +kubectl get authorizationpolicy -n litellm +kubectl get peerauthentication -A +kubectl logs -n istio-system -l app=ztunnel --tail=200 | grep -iE 'denied|policy|rbac' +``` + +`RBAC: access denied` in an HTTP 403 body comes from an L7 policy, which the toolkit does not create. Look for a waypoint or an AuthorizationPolicy with HTTP rules that someone added (`kubectl get authorizationpolicy -A -o yaml | grep -B3 -A10 -E 'methods|paths'`). diff --git a/.agents/skills/agent-toolkit-components/references/openshell.md b/.agents/skills/agent-toolkit-components/references/openshell.md new file mode 100644 index 00000000..190c890e --- /dev/null +++ b/.agents/skills/agent-toolkit-components/references/openshell.md @@ -0,0 +1,77 @@ +# OpenShell: policy-enforced sandboxes + +OpenShell runs agents in sandboxes where egress is denied by default and allowed by policy (L7 rules, Landlock). The LLM key never enters the sandbox: the sandbox sees a placeholder `OPENAI_API_KEY`, and the OpenShell supervisor swaps in the real key on calls to LiteLLM. + +It is off by default. Turn it on with `openshell_enabled: true` in `env//config.agent-toolkit.yaml`. It needs `agent_sandbox_enabled: true` (it uses the Agent Sandbox CRDs). + +Side effect: with OpenShell on and Istio present, LiteLLM accepts connections from **every pod in the cluster** (`litellm_allow_pod_network` follows `openshell_enabled`). The API key check still applies. + +## What is in the cluster + +| Object | Name | +|---|---| +| Gateway | StatefulSet `openshell`, Service `openshell:8080` (gRPC, mTLS) in `openshell-system` | +| Admin client certificate | Secret `openshell-client-tls` (`ca.crt`, `tls.crt`, `tls.key`), in `openshell-system` **and** copied into `openshell-sandboxes`. This is **full gateway admin**. | +| LiteLLM key used by sandboxes | Secret `openshell-genai-key` (`api_key`), LiteLLM alias `openshell-sandboxes`, budget 50 | +| Provider | `genai-gateway` (profile `eat-genai-gateway`) pointing at `litellm.litellm.svc.cluster.local:4000` | +| Sandbox pods | Namespace `openshell-sandboxes` | +| CLI installed by the installer | `~/.cache/eat/openshell-cli-v/openshell` on the installer host, for the installing user | + +Access model (default): single admin, and the client certificate is the only check. The gateway Service is ClusterIP, but no NetworkPolicy guards it and `openshell-system` is not in the mesh, so any pod in the cluster can reach `openshell.openshell-system:8080`, not only a port-forward. Whoever holds the certificate is the admin: anyone who can read `openshell-client-tls` in either namespace, or get into a sandbox's supervisor pod in `openshell-sandboxes` (`os-supervisor-*`, which mounts it; on 0.0.116 the sandbox pod itself). OIDC (`openshell_oidc_issuer`) exists but is not validated. + +## Connect the CLI + +```bash +kubectl port-forward -n openshell-system svc/openshell 8080:8080 & +# Otherwise the CLI hangs behind a proxy. Keep the existing entries: kubectl still needs them. +export NO_PROXY="127.0.0.1,localhost${NO_PROXY:+,$NO_PROXY}" no_proxy="127.0.0.1,localhost${no_proxy:+,$no_proxy}" +dir="${XDG_CONFIG_HOME:-$HOME/.config}/openshell/gateways/eat/mtls"; mkdir -p "$dir" && chmod 700 "$dir" +for k in ca.crt tls.crt tls.key; do + kubectl get secret openshell-client-tls -n openshell-system -o go-template="{{index .data \"$k\"}}" | base64 -d > "$dir/$k" +done +chmod 600 "$dir"/* +openshell gateway add https://127.0.0.1:8080 --local --name eat +openshell provider list # expect: genai-gateway eat-genai-gateway +``` + +## Run an agent in a sandbox **(changes the cluster)** + +```bash +openshell sandbox create --name demo --provider genai-gateway --detach --from python:3.12-slim \ + --env OPENAI_BASE_URL=http://litellm.litellm.svc.cluster.local:4000/v1 +openshell logs demo --source sandbox | grep DENIED # what the policy blocked +``` + +Agent code inside the sandbox calls `http://litellm.litellm.svc.cluster.local:4000/v1` with `$OPENAI_API_KEY` (the placeholder). Spend is booked to the alias `openshell-sandboxes`. + +## Which programs may call the LLM + +The provider profile allows only listed executables to reach LiteLLM: `charts/openshell/genai-gateway-provider.yaml` in this repo, field `binaries`. Shipped list: + +- `/usr/bin/curl` +- `/usr/bin/python3`, `/usr/bin/python3.12`, `/usr/local/bin/python3`, `/usr/local/bin/python3.12` +- `/sandbox/.uv/python/**` +- `/usr/lib/node_modules/opencode-ai/bin/.opencode` + +Matching uses the **resolved** path: a venv's python resolves to its base interpreter, and listed symlinks are resolved when the policy loads (globs are not). + +- Error `policy_denied` or `binary ... not allowed in policy '_provider_genai_gateway'`: inside the sandbox, find the real path (`readlink -f "$(command -v node)"`), add it to `binaries`, then re-run `./toolkit_manager.sh install openshell --only` from the Toolkit Manager root **(changes the cluster)**. The profile is updated in place. +- OpenShell 0.0.116 only: a placeholder in a request **body** (not a header) fails with `credential_injection_failed`. +- Always pass `--from `: without it, 0.1.6 uses `nvcr.io/nvidia/base/ubuntu:24.04`, which has none of the binaries above, so nothing in it can call LiteLLM. (0.0.116 used the community `base:latest`, which can change binary paths.) + +## Things to know + +- `kubectl exec` into a supervisor pod (`os-supervisor-*`; on 0.0.116 the sandbox pod) bypasses every policy and reaches the mounted admin certificate. Restrict `pods/exec`, and `get`/`list` on Secrets (the certificate is there too), in `openshell-sandboxes`. +- OpenShell 0.0.116 only: policy decisions are written inside the pod. Fluent Bit and Loki do not collect them; use `openshell logs`. +- Reinstalling OpenShell issues new client certificates (old CLI configs stop working), a new LiteLLM key and a new provider. +- If someone revokes the `openshell-sandboxes` key in LiteLLM while the Secret still exists, the installer does not mint a new one. Fix **(changes the cluster)**: `openshell provider delete genai-gateway`, `kubectl delete secret openshell-genai-key -n openshell-system`, then `./toolkit_manager.sh install openshell --only`. + +## Inspect + +```bash +kubectl get pods,pvc,secret -n openshell-system +kubectl get pods,networkpolicy -n openshell-sandboxes +kubectl logs -n openshell-system openshell-0 | sed 's/\x1b\[[0-9;]*m//g' +``` + +The gateway log repeats `WARN ... Kubernetes watcher stream error; waiting for kube-runtime recovery ... too old ... Expired` (0.0.116: `Compute driver watch stream errored`). It is harmless. diff --git a/.agents/skills/agent-toolkit-components/references/ray-and-tracing.md b/.agents/skills/agent-toolkit-components/references/ray-and-tracing.md new file mode 100644 index 00000000..ec46ad7b --- /dev/null +++ b/.agents/skills/agent-toolkit-components/references/ray-and-tracing.md @@ -0,0 +1,52 @@ +# KubeRay, Langfuse and OpenTelemetry from agent code + +## KubeRay: parallel tool execution + +Off by default. Turn it on with `kuberay_enabled: true` in `env//config.agent-toolkit.yaml`. + +| | Value | +|---|---| +| Ray client | `ray://ray-cluster-head-svc.ray-system.svc.cluster.local:10001` | +| Dashboard and jobs API | `http://ray-cluster-head-svc.ray-system.svc.cluster.local:8265`; externally `https://ray./` | +| Dashboard login | Basic auth on the external route only. Secret `ray-dashboard-auth` in `ray-system`, keys `username` (`ray`) and `password`. The in-cluster `:8265` endpoint has no auth. | +| Cluster | RayCluster `ray-cluster`: head (runs no tasks) plus worker group `default-worker` that autoscales between 1 and 4 | + +```python +import ray +ray.init("ray://ray-cluster-head-svc.ray-system.svc.cluster.local:10001") +``` + +- The client must match the cluster: `pip install "ray[default]==2.40.0"` on Python 3.12. A different Ray or Python version fails on connect. +- From a laptop: `kubectl port-forward -n ray-system svc/ray-cluster-head-svc 10001:10001`, then `ray.init("ray://localhost:10001")`. +- Ray workers can call LiteLLM; `ray-system` is in `litellm_allowed_namespaces`. +- Do not `kubectl scale raycluster` (it has no scale subresource). Set `kuberay_worker_replicas`, `kuberay_worker_min_replicas` or `kuberay_worker_max_replicas` and re-run `./toolkit_manager.sh install kuberay --only` **(changes the cluster)**. The autoscaler owns the replica count. + +## Langfuse: LLM traces with no code change + +When LiteLLM runs as the API gateway, it sends every call to Langfuse. Your agent gets traces without any SDK. + +| | Value | +|---|---| +| UI | `https://langfuse.`. Main track: Keycloak sign-in. Admin login on either track: Secret `langfuse-secrets` in `langfuse` (`admin_email`, `admin_password`) | +| In-cluster API | `http://langfuse-web.langfuse.svc.cluster.local:3000` | +| SDK keys (for your own spans) | Secret `langfuse-api-keys` in `litellm`: `LANGFUSE_HOST`, `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY` | + +To group traces per agent or session, send LiteLLM metadata with the request, for example `"metadata": {"trace_user_id": "", "session_id": ""}` in the OpenAI request body (`extra_body` in the OpenAI Python SDK). + +If traces stop appearing, check Langfuse's ClickHouse pod for restarts: `kubectl get pods -n langfuse`. A ClickHouse pod that keeps getting OOMKilled drops traces without an error on the LiteLLM side. + +## OpenTelemetry for agent spans and metrics + +| Protocol | Endpoint | +|---|---| +| OTLP gRPC | `opentelemetry-collector.monitoring.svc.cluster.local:4317` | +| OTLP HTTP | `http://opentelemetry-collector.monitoring.svc.cluster.local:4318` | + +```bash +export OTEL_EXPORTER_OTLP_ENDPOINT=http://opentelemetry-collector.monitoring.svc.cluster.local:4318 +export OTEL_SERVICE_NAME= +``` + +The collector feeds Tempo, viewed in Grafana (`https://grafana.`). + +The Agent Sandbox SDK emits its own spans when you pass `tracer_config=SandboxTracerConfig(enable_tracing=True, trace_service_name="")` to `SandboxClient` (from `k8s_agent_sandbox.models`). It needs the extra, `pip install "k8s-agent-sandbox[tracing]==1.0.10"`; without it the SDK only logs `OpenTelemetry not installed`. Its exporter speaks **gRPC**, so point it at port 4317: `OTEL_EXPORTER_OTLP_ENDPOINT=http://opentelemetry-collector.monitoring.svc.cluster.local:4317`. If the rest of your app exports over HTTP, set `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` per exporter instead. diff --git a/.agents/skills/agent-toolkit-components/references/sandbox.md b/.agents/skills/agent-toolkit-components/references/sandbox.md new file mode 100644 index 00000000..04421822 --- /dev/null +++ b/.agents/skills/agent-toolkit-components/references/sandbox.md @@ -0,0 +1,118 @@ +# Agent Sandbox and Kata from agent code + +The toolkit installs upstream `kubernetes-sigs/agent-sandbox` (version in `agent_sandbox_version`, default `v1.0.10`). Agents run model-generated code in short-lived pods from a warm pool. The Python SDK is `k8s-agent-sandbox`. Pin it to the same version as the controller: `pip install k8s-agent-sandbox==1.0.10`. The router image follows the same version: `registry.k8s.io/agent-sandbox/sandbox-router-go:`. + +## What is in the cluster + +| Object | Name | Namespace | +|---|---|---| +| Controller | Deployment `agent-sandbox-controller` | `agent-sandbox-system` | +| Router (proxy to sandbox pods) | Deployment `sandbox-router`, Service `sandbox-router-svc:8080` | `agent-sandbox-system` | +| Router authentication | No Secret. The router checks the caller's ServiceAccount token with the Kubernetes TokenReview API (`--authz-mode=tokenreview`). | | +| Python template and pool | SandboxTemplate `python-sandbox-template`, SandboxWarmPool `python-pool` (5 warm pods) | `agent-sandbox-system` | +| Kata template and pool (only when `kata_containers_enabled: true`) | SandboxTemplate `kata-sandbox-template`, SandboxWarmPool `kata-pool` (1 warm pod) | `agent-sandbox-system` | + +The namespace is fixed. Upstream manifests and both templates hard-code `agent-sandbox-system`. + +## Three things the SDK needs + +1. **`namespace="agent-sandbox-system"` on every call.** The SDK defaults to `"default"`. With the default you get one of: + - `SandboxWarmPoolNotFoundError("SandboxWarmPool requested does not exist: ...")` + - from a pod whose Role is only in `agent-sandbox-system`, an immediate 403 `cannot create resource "sandboxclaims" ... in the namespace "default"`. That is a namespace mistake, not missing RBAC. +2. **A ServiceAccount token for the router.** The router rejects a call without `Authorization: Bearer ` with HTTP 401. It only authenticates: any valid ServiceAccount token of this cluster is accepted. In a pod, use the pod's own token (`/var/run/secrets/kubernetes.io/serviceaccount/token`). From a laptop, `kubectl create token -n ` gives a one-hour token; do not add `--audience`, because the router checks the token against the API server's own audience. +3. **Kubernetes RBAC for the caller.** The SDK creates `SandboxClaim`s itself through the Kubernetes API, and the router does not do it for you. A laptop with an admin kubeconfig already has the access. An agent **pod** needs a Role and RoleBinding (below), otherwise it gets `403 ... cannot create resource "sandboxclaims"`. + +## RBAC for an in-cluster agent **(changes the cluster)** + +Replace `` and ``. This covers the Kubernetes API calls the 1.0.10 SDK makes. It does not read pods. + +```yaml +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: sandbox-client + namespace: agent-sandbox-system +rules: + - apiGroups: ["extensions.agents.x-k8s.io"] + resources: ["sandboxclaims"] + verbs: ["create", "get", "list", "watch", "patch", "delete"] + - apiGroups: ["agents.x-k8s.io"] + resources: ["sandboxes"] + verbs: ["get", "list", "watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: sandbox-client- + namespace: agent-sandbox-system +subjects: + - kind: ServiceAccount + name: + namespace: +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: sandbox-client +``` + +Check it: `kubectl auth can-i create sandboxclaims.extensions.agents.x-k8s.io -n agent-sandbox-system --as=system:serviceaccount::` + +## Code + +In a pod, connect to the router Service directly and pass the pod's token with `extra_headers`. Running this creates a SandboxClaim and deletes it again in `terminate()` **(changes the cluster)**: + +```python +from pathlib import Path +from k8s_agent_sandbox import SandboxClient +from k8s_agent_sandbox.models import SandboxDirectConnectionConfig + +token = Path("/var/run/secrets/kubernetes.io/serviceaccount/token").read_text().strip() +client = SandboxClient(connection_config=SandboxDirectConnectionConfig( + api_url="http://sandbox-router-svc.agent-sandbox-system.svc.cluster.local:8080", + extra_headers={"Authorization": f"Bearer {token}"})) +sandbox = client.create_sandbox(warmpool="python-pool", namespace="agent-sandbox-system") +try: + result = sandbox.commands.run("python3 -c 'print(6*7)'") + print(result.stdout) +finally: + sandbox.terminate() +``` + +- The kubelet rotates the token file. Read it again for each new client; a token read once at start-up expires. +- The pod's ServiceAccount token must be mounted (do not set `automountServiceAccountToken: false`). The same ServiceAccount needs the Role above. +- `warmpool="kata-pool"` runs the same code in a Kata microVM. A comment in `charts/agent-sandbox/kata-templates.yaml` shows `create_sandbox(template=...)`, which is wrong for SDK 1.0.10: the argument is `warmpool`. +- `SandboxClient()` with no config opens its own `kubectl port-forward` tunnel, but cannot send a token, so this router answers 401. From a laptop, run `kubectl port-forward -n agent-sandbox-system svc/sandbox-router-svc 8080:8080` and use `SandboxDirectConnectionConfig(api_url="http://127.0.0.1:8080", extra_headers={"Authorization": f"Bearer {token}"})` with a token from `kubectl create token default -n agent-sandbox-system`. +- `SandboxInClusterConnectionConfig` connects straight to the sandbox pod and times out: sandbox pods accept traffic only from the router. +- The Python runtime image serves `POST /execute {"command": "..."}` on port 8888 and returns `stdout`, `stderr` and `exit_code`. + +## What code inside a sandbox can and cannot do + +| | Sandbox pod | +|---|---| +| Ingress | Only from the router (`app=sandbox-router`) | +| Egress | Public IPs only. Private ranges (RFC 1918), link-local and the cluster are blocked. | +| DNS | Public resolvers `8.8.8.8` and `1.1.1.1`; no cluster DNS | +| Proxy | None. On a network where the internet is reachable only through a proxy, sandboxes have no egress. | +| Limits | 1 CPU, 1 GiB, non-root (uid 1000), all capabilities dropped | + +So code in a sandbox **cannot** reach LiteLLM, Redis, pgvector, internal package mirrors or the Kubernetes API. This is intentional. Pass inputs in with the command or files and read outputs back through the SDK. For egress that a policy controls, use OpenShell (`openshell.md`). + +A custom SandboxTemplate must keep the pod label `istio.io/dataplane-mode: none`. Without it the pod joins the mesh and the egress NetworkPolicy no longer applies. + +## Kata microVMs + +Kata is an infrastructure component. Its switches `kata_containers_enabled` and `kata_runtime` (`kata-fc`, `kata-qemu` or `both`) live in `env//global_config.yaml`, not in the toolkit config. The sandbox role uses `kata-fc` when that RuntimeClass exists, else `kata-qemu`. + +- Kata pods run only on nodes labelled `ei-kata-eligible=true`: `kubectl get nodes -L ei-kata-eligible`. +- Runtime of the warm pod: `kubectl get pod -n agent-sandbox-system -l sandbox=kata -o jsonpath='{.items[0].spec.runtimeClassName}'`. + +## Inspect + +```bash +kubectl get deploy,pods,svc -n agent-sandbox-system +kubectl get sandboxtemplate,sandboxwarmpool,sandboxclaim,sandbox -n agent-sandbox-system +kubectl logs -n agent-sandbox-system deploy/agent-sandbox-controller +kubectl logs -n agent-sandbox-system -l app=sandbox-router +``` + +`kubectl get sandboxwarmpool` shows `NAME READY DESIRED AGE` (`-o wide` adds `TEMPLATE`); there is no SIZE column. diff --git a/.agents/skills/agent-toolkit-configuration/SKILL.md b/.agents/skills/agent-toolkit-configuration/SKILL.md new file mode 100644 index 00000000..c0977eb9 --- /dev/null +++ b/.agents/skills/agent-toolkit-configuration/SKILL.md @@ -0,0 +1,91 @@ +--- +name: agent-toolkit-configuration +description: Find and change Intel® Agent Toolkit settings. Use when someone asks "how do I turn on OpenShell", "turn Kata off", "disable the guardrail", "change the default model", "my node has 128 GB", "let my namespace call LiteLLM", "I changed a setting and nothing happened" or "which file do I edit". Says which file holds a setting (env//config.agent-toolkit.yaml, global_config.yaml, config.inference.yaml, models.yaml), which file wins when a key is in several, and how a change takes effect (re-run install, litellm_reconcile, or teardown first). Covers component switches (OpenShell, KubeRay, Redis, pgvector, Agent Sandbox, Kata, guardrail, hybrid router, semantic router), the default model, sizes, namespaces and the API access mode. +--- + +# Configure Intel® Agent Toolkit + +This file is a summary. The exact steps, commands and fixes are in the `references/` file that each table row points to: open that file before you answer. + +## 1. Use the environment's files + +Settings live in `/env//` (see `AGENTS.md` to find `` and ``). `init` seeds these files once and never overwrites them. Do not edit `config.yaml` in this repo or `/configs/defaults/`; those only seed new environments. + +| File | Holds | +|---|---| +| `config.agent-toolkit.yaml` | Toolkit switches and sizes, the default model, and the LiteLLM settings the toolkit needs | +| `global_config.yaml` | Toolkit Manager settings: domain, proxy, TLS, storage, cluster, Kata, `routing_mode` | +| `config.inference.yaml` | Inference-only settings: `vllm_sr_enabled`, KServe, versions | +| `models.yaml` | The model catalog: CPU, memory and server per model | +| `nodes.yaml`, `inventory/hosts.yaml` | Nodes for multi-node and remote installs | + +Never edit `.solutions.yaml`, `kubeconfig.yaml` or `kubespray_extra_auto.yml`. + +## 2. Know which file wins + +The installer passes every file as Ansible extra vars, in this order. A later file wins: + +`config.inference.yaml` → `config.agent-toolkit.yaml` → `global_config.yaml` → `nodes.yaml` → `-- -e key=value` on the command line + +So: +- A key in `config.agent-toolkit.yaml` overrides the same key in `config.inference.yaml`. +- A key already in `global_config.yaml` (for example `kata_containers_enabled`) cannot be changed from `config.agent-toolkit.yaml`. Change it in `global_config.yaml`. +- Lists **replace** the defaults; they do not merge. When you add to `litellm_allowed_namespaces` or `litellm_public_paths`, keep the existing entries. +- Extra vars beat every role default. Search all the env files before saying a value is "the default": `grep -n '' env//*.yaml`. Do not grep this way for password or token keys; it prints their values. + +## 3. Find the key + +`references/toolkit-settings.md` lists every toolkit key, its default, when to change it, and keys that have no effect. Confirm defaults in this repo's `config.yaml` and `roles//defaults/main.yaml`; for inference keys, in `/ext/enterprise.ai-inference/roles//defaults/main.yaml`. + +| The user wants to... | Key and file | +|---|---| +| Turn on OpenShell | `openshell_enabled: true` (config.agent-toolkit). Needs Agent Sandbox. | +| Turn on KubeRay | `kuberay_enabled: true` (config.agent-toolkit) | +| Use Kata microVMs for sandboxes | `kata_containers_enabled: true`, `kata_runtime: kata-fc\|kata-qemu\|both` (global_config) | +| Change or remove the default model | `llm_services_autodeploy_models` (config.agent-toolkit); `[]` for none | +| Run on a 128 GB node | `llm_services_autodeploy_models: ["qwen2-5-coder-7b"]` before installing | +| Turn the guardrail on or off | `guardrails_enabled` (config.agent-toolkit); see section 4, it needs more than the switch | +| Turn on the semantic router | `vllm_sr_enabled: true` (config.inference) | +| Let another namespace call LiteLLM | add it to `litellm_allowed_namespaces` (config.agent-toolkit), keeping the shipped entries | +| Keep `litellm.` API-only | `litellm_public_paths: [...]` with API paths only. Main track: the admin UI stays on `litellm-ui.` behind Keycloak. Release track: a non-empty list also unpublishes the UI (port-forward only). | +| Move Redis or pgvector storage | `redis_stack_storage_class`, `pgvector_storage_class` (before the first install) | +| Set the proxy | `http_proxy`, `https_proxy`, `no_proxy` (global_config) | +| Give a model more CPU or memory | its entry in `models.yaml`, then `./model-manager deploy ` | + +## 4. Make the change take effect + +| Kind of setting | How it applies | +|---|---| +| Toolkit switch turned **on**, toolkit sizes | `./toolkit_manager.sh install agent-toolkit --env ` (or `install --only`) | +| Toolkit switch turned **off** | Re-running install removes nothing. Run `teardown --env ` **while the switch is still on**, then set it to `false`. If it is already `false`: `teardown -- -e _enabled=true`. **(deletes data: the component's namespace, volumes and credentials)** | +| `litellm_allowed_namespaces` | Applied on every run: `install litellm --only` | +| Guardrail **on** | `install agent-toolkit` (not `install litellm --only`: the guard model `qwen3guard` is deployed by `llm_services`, and the guardrail blocks every request until it is Ready) | +| Guardrail **off**, main track | The switch alone does not unregister it. Set `false`, then delete the `content_safety` guardrail in the LiteLLM admin UI (Guardrails), with the user's OK. Do not run `litellm_reconcile` before it is deleted: that removes the guard host from LiteLLM's allowed hosts while the fail-closed guardrail is still registered, which blocks every request. | +| Guardrail **off**, release track | `install litellm --only` removes it and restarts LiteLLM | +| Other LiteLLM settings (hybrid router, tier candidates, version) | `install litellm --only -- -e litellm_reconcile=true`. Pass `litellm_reconcile` on the command line only; left `true` in a file, it upgrades LiteLLM on every run. | +| `routing_mode` (main track) | It changes every published URL: gateway, Keycloak, Grafana, LiteLLM. Re-run the full `install agent-toolkit -- -e litellm_reconcile=true`. Treat the change as untested on an installed cluster. | +| Semantic router routes after a new model | `install vllm_sr --only` | +| Model CPU, memory or server | `./model-manager deploy ` (from ``) | +| Volume sizes, pgvector database or user names, namespaces | Fixed after the first install. Run `teardown ` **with the old value still in place** **(deletes data)**, then change the value, then install. Changing the value first leaves the old release and namespace orphaned. | +| Kata **on**, `kata_runtime` | `install agent-toolkit` applies it on the running cluster **(changes the cluster)**: kata-deploy restarts containerd on every node. Then the sandbox role adds the Kata template and pool. | +| Kata **off** | Re-running install removes nothing: kata-deploy, the `kata-sandbox-template` SandboxTemplate and the `kata-pool` warm pool stay. While `kata_containers_enabled` is still `true`, run `kubectl delete sandboxwarmpool kata-pool -n agent-sandbox-system`, `kubectl delete sandboxtemplate kata-sandbox-template -n agent-sandbox-system` and `./toolkit_manager.sh teardown kata_containers --env `, then set the switch to `false` **(changes the cluster; running Kata sandboxes stop)**. If it is already `false`, add `-- -e kata_containers_enabled=true` to the teardown. | +| Storage backend, Kubernetes settings | These are fixed when the cluster is built. They need `teardown kubernetes` and a reinstall, which destroys the cluster; only with the user's explicit OK **(deletes data: the whole cluster)**. | + +Install, teardown and model-manager change the cluster. Show the user the command and get an OK first. + +## Auth switch + +Find the track first (`AGENTS.md`, "Which track the installation is on"). + +- **Main track:** `auth_type` in `config.agent-toolkit.yaml`. + - `litellm_vkey` (seeded by `init agent-toolkit`): LiteLLM with virtual keys, guardrail, hybrid router, Langfuse and the OpenShell provider. + - `jwt`: Keycloak tokens straight to the AI gateway, without any of those. + - Setting `auth_type` in `config.inference.yaml` has no effect in a toolkit environment, because the toolkit file loads later. The installer's deprecation message and the inference docs say "config.inference.yaml"; that advice is for inference-only environments. + - An `auth_provider` line in `global_config.yaml` is deprecated. If present it must agree with `auth_type`, otherwise preflight stops; delete it. + - Switching from `litellm_vkey` to `jwt` after install leaves LiteLLM running. `teardown litellm -- -e litellm_enabled=true` removes it, and also Langfuse with every trace, the master key Secret and the `litellm` namespace **(deletes data)**. Warn the user first. +- **Release track:** `auth_provider: litellm` (or `keycloak`) in `global_config.yaml`. `auth_type` is ignored. + +Check which value is in effect: `grep -nE '^(auth_type|auth_provider):' env//{config.inference,config.agent-toolkit,global_config}.yaml`. +- Main track: the last file that sets `auth_type` wins, and `auth_provider` is only checked for agreement. +- Release track: only `auth_provider` counts. +- The comments seeded into `config.agent-toolkit.yaml` describe the release track ("This release reads auth_provider..."). diff --git a/.agents/skills/agent-toolkit-configuration/references/toolkit-settings.md b/.agents/skills/agent-toolkit-configuration/references/toolkit-settings.md new file mode 100644 index 00000000..4ecd1863 --- /dev/null +++ b/.agents/skills/agent-toolkit-configuration/references/toolkit-settings.md @@ -0,0 +1,75 @@ +# Toolkit settings reference + +All keys below go in `env//config.agent-toolkit.yaml` unless the table says otherwise. The shipped defaults are in `config.yaml` (seeded keys) and `roles//defaults/main.yaml` (everything else) of this repo. Read those files to confirm a default before quoting it. + +"Before first install" means the value is baked into data or volumes. Changing it later needs a teardown of that component, which deletes its data. + +## Seeded keys (`config.yaml`) + +| Key | Default | Meaning and when to change | +|---|---|---| +| `node_preflight_enabled` | `true` | Node readiness report at the start of `install` (report only, capped at 5 minutes); turn off for CI or a slow SSH fan-out. | +| `auth_type` | `litellm_vkey` | API access mode. `litellm_vkey` = LiteLLM with virtual keys (what the toolkit needs). `jwt` = Keycloak tokens straight to the AI gateway, with no LiteLLM, guardrail, hybrid router, Langfuse or OpenShell provider. Main track only; see "Auth switch" in `../SKILL.md`. | +| `guardrails_enabled` | on with LiteLLM | Content-safety guard on every LiteLLM request. Fail-closed, and adds the `qwen3guard` CPU model. Set `false` to save CPU or for latency tests. How to apply on or off differs by track; see `../SKILL.md` section 4. | +| `hybrid_router_enabled` | `true` | Publishes the LiteLLM model `hybrid-router`. Changes on an installed LiteLLM need `-- -e litellm_reconcile=true`. | +| `litellm_public_paths` | `[]` | Paths published on `litellm.`. With subdomains, `[]` = every path, including the key-management API (LiteLLM still asks for a key). To restrict it, list API paths such as `/v1/chat/completions`, `/v1/embeddings` and `/v1/models`. Main track: the toolkit's `[]` replaces the inference layer's API-only default, and the admin UI is on `litellm-ui.` regardless. Release track: a non-empty list also unpublishes the UI. With `routing_mode: path` (main track), `[]` publishes no API route at all, so always set the list explicitly. | +| `llm_services_autodeploy_models` | `["qwen2-5-coder-14b"]` | Models deployed by `install`. They are **required**: if one fails, the install fails. `[]` installs no chat model. The first entry is also the hybrid-router and semantic-router default. Names must exist in `env//models.yaml`. | +| `vllm_sr_dashboard_enabled` | `true` | vLLM Semantic Router dashboard. Matters only with `vllm_sr_enabled: true` in `config.inference.yaml`. | +| `vllm_sr_litellm_model_name` | `vllm-sr/auto` | The model name clients use for semantic routing. | +| `redis_stack_namespace` | `redis` | Before first install. | +| `redis_stack_storage_class` | `""` (cluster default) | Pin a StorageClass, for example a local one for latency. Before first install. | +| `redis_stack_persistence_size` | `10Gi` | Before first install (the volume size is fixed). | +| `pgvector_namespace` | `pgvector` | Before first install. | +| `pgvector_database`, `pgvector_username` | `agentdb`, `agentuser` | Before first install. Changing them later breaks validation (`role ... does not exist`). | +| `pgvector_storage_size` | `20Gi` | Before first install. | +| `agent_sandbox_namespace` | `agent-sandbox-system` | **Do not change.** The upstream manifests and templates hard-code it. | +| `agent_sandbox_version` | `v1.0.10` | Upstream Agent Sandbox release. Clients must use the same SDK version. Delete the `/tmp/agent-sandbox-router-*` files on the installer host before upgrading. | +| `openshell_enabled` | `false` | Policy-enforced sandboxes. Needs `agent_sandbox_enabled: true`. With Istio it also lets every pod in the cluster reach LiteLLM's port. | +| `openshell_oidc_issuer` | `""` | Empty = single admin through `kubectl port-forward`. OIDC is not validated. | +| `litellm_allow_pod_network` | follows `openshell_enabled` | Admits the pod network on LiteLLM's port. On a bring-your-own cluster also set `kubernetes_cluster_cidr` to the real pod CIDR. | +| `kuberay_enabled` | `false` | Ray cluster for parallel work. | +| `kuberay_namespace` | `ray-system` | Also appears in `litellm_allowed_namespaces`. | +| `kuberay_operator_version` | `1.3.0` | KubeRay operator chart. Change together with `kuberay_ray_image`. | +| `litellm_allowed_namespaces` | gateway, litellm, agent-sandbox-system, ray-system | Namespaces whose pods may call LiteLLM in-cluster. Add your own **ambient** agent namespace. The value replaces the default list, so keep the shipped entries. Main track: the inference default also lists `model-manager` (used by model-manager Jobs started from Headlamp); add it back if you use Headlamp deploys. Applied on every run. | +| `keycloak_agent_realm` | `agent-toolkit` | Realm name. Used only when Keycloak is installed. | + +## Other component switches (defaults in `components.yaml`, not seeded) + +| Key | Default | Notes | +|---|---|---| +| `redis_stack_enabled` | `true` | | +| `pgvector_enabled` | `true` | | +| `agent_sandbox_enabled` | `true` | OpenShell needs it. | +| `keycloak_agent_config_enabled` | on wherever Keycloak runs (on by default on the main track) | Creates the `agent-toolkit` realm. Set `false` to skip the realm. Do not set `keycloak_enabled: false` on the main track: platform sign-in, the LiteLLM UI and Langfuse sign-in depend on it. Turning the realm on without Keycloak makes the install wait and fail. A leftover `auth_provider: litellm` in `global_config.yaml` turns the realm off by default. | + +## Overridable role defaults (not seeded) + +Add these to `env//config.agent-toolkit.yaml` only when needed. Check the exact name in the role's `defaults/main.yaml` first. + +| Area | Keys | +|---|---| +| Redis | `redis_stack_auth_enabled` (`true`) | +| pgvector | `pgvector_storage_class`, `pgvector_resources`, `pgvector_parameters` (for example `{max_connections: 600}`) | +| Agent Sandbox | `agent_sandbox_python_warm_pool_size` (5; 0 disables the pool), `kata_warm_pool_size` (1), `agent_sandbox_router_image`, `agent_sandbox_python_runtime_image`, `agent_sandbox_manifest_url`, `agent_sandbox_router_manifest_base_url`, `agent_sandbox_router_manifests` (mirrors for air-gapped sites) | +| OpenShell | `openshell_release_name`, `openshell_workspace_storage_class`, `openshell_sandbox_egress_cidrs`, `openshell_sandbox_dns_cidrs`, `openshell_upstream_proxy_cidrs`, `openshell_genai_key_models` (`[]` = all models), `openshell_genai_key_max_budget` (50) | +| KubeRay | `kuberay_worker_replicas` / `kuberay_worker_min_replicas` / `kuberay_worker_max_replicas` (2 / 1 / 4), head and worker CPU and memory, `kuberay_dashboard_enabled`, `kuberay_dashboard_basic_auth` | + +## Settings that have no effect + +Nothing reads these, so changing them does nothing: +- `redis_stack_resources` +- `pgvector_version` (the image tag is fixed in the chart) +- `agent_sandbox_release_name` +- `keycloak_admin_secret` + +## Keys that live in other files + +| Key | File | Notes | +|---|---|---| +| `kata_containers_enabled`, `kata_runtime` (`kata-fc`, `kata-qemu`, `both`) | `global_config.yaml` | Infrastructure component. Needs `/dev/kvm` on the nodes. | +| `base_domain_name`, proxy settings (`http_proxy`, `https_proxy`, `no_proxy`), `gateway_tls_mode`, `existing_kubernetes`, `storage_backend` | `global_config.yaml` | Toolkit Manager settings | +| `routing_mode` (`subdomain` or `path`) | `global_config.yaml` | Main track only. Path mode serves LiteLLM at `https:///litellm/v1`. It changes every published URL (gateway, Keycloak, Grafana, LiteLLM); after install, re-run the full install with `-- -e litellm_reconcile=true`, and treat it as untested. | +| `auth_provider` | `global_config.yaml` | Release track switch (`litellm` or `keycloak`). Deprecated on the main track: if present it must agree with `auth_type`, else preflight stops. | +| `vllm_sr_enabled` | `config.inference.yaml` | vLLM Semantic Router (the toolkit sets its dashboard and model name) | +| Inference layer keys the toolkit sets (`guardrails_enabled`, `hybrid_router_enabled`, `litellm_*`, `llm_services_autodeploy_models`, `vllm_sr_*`) | `config.agent-toolkit.yaml` | Loaded after `config.inference.yaml`, so the toolkit file wins over the inference file, and `global_config.yaml` wins over both | +| Hybrid router tuning (`hybrid_router_tier_candidates`, `hybrid_router_default_model`), guardrail (`guardrail_model`, `guard_block_on_controversial`) | `config.agent-toolkit.yaml` | Inference role defaults. Check them in `/ext/enterprise.ai-inference/roles/litellm/defaults/main.yaml`. Pass `litellm_reconcile=true` with `-- -e` for one run only; left `true` in a file it upgrades LiteLLM on every run. | diff --git a/.agents/skills/agent-toolkit-install/SKILL.md b/.agents/skills/agent-toolkit-install/SKILL.md new file mode 100644 index 00000000..fb71c953 --- /dev/null +++ b/.agents/skills/agent-toolkit-install/SKILL.md @@ -0,0 +1,87 @@ +--- +name: agent-toolkit-install +description: Install, check, update or remove Intel® Agent Toolkit with Toolkit Manager (intel/toolkit-manager, toolkit_manager.sh). Use when someone says "install the Agent Toolkit", "set up agent toolkit on my server", "is my machine big enough", "my install fails", "is my install working", "add a node", "upgrade the toolkit" or "remove it / start over". Checks host prerequisites first (memory for the default models, AMX CPU, proxy, Docker, ports, Hugging Face token, Kata needs), then walks configure, init agent-toolkit, environment settings, install, validate and client access, and explains what each teardown target deletes. +--- + +# Install Intel® Agent Toolkit + +This file is a summary. The exact steps, commands and fixes are in the `references/` file that each table row points to: open that file before you answer. + +Intel® Agent Toolkit is not installed from this repository. Toolkit Manager (`intel/toolkit-manager`) clones it into `ext/enterprise.agent-toolkit/` and installs it with the layers below it. All commands run from the Toolkit Manager root. See `AGENTS.md` to find the root, the environment and the track. + +Ask before running anything that changes the host or cluster. Steps that need a terminal or a sudo password are the user's to run. + +## 1. Check prerequisites + +Go through `references/prerequisites.md` and report every row that fails before going on. The usual blockers: +- **Memory.** The default install requests about 139 GiB. On 128 GB, change the default model first (step 4). +- **Docker on the host.** Kubespray removes it and its images. +- **Proxy.** Without `http_proxy`, `https_proxy` and `no_proxy` in `global_config.yaml`, preflight stops with `No internet connectivity`. + +## 2. Get Toolkit Manager + +```bash +git clone https://github.com/intel/toolkit-manager.git && cd toolkit-manager +``` + +This is the main track; `release-2.0` behaves the same. For the 1.2 release track use `git clone -b release-1.2 ...`. The toolkit and inference revisions that `init` will clone are pinned in `configs/repos/repos.agent-toolkit.yaml`: `yq '.repos[] | [.layer,.rev]' configs/repos/repos.agent-toolkit.yaml`. + +## 3. Prepare the host (user runs this) + +```bash +./toolkit_manager.sh configure +``` + +It installs Python, yq, kubectl and helm and builds `.venv`. It asks for confirmation and needs a terminal; the user runs it. An existing kubectl or helm is kept whatever its version (warning only). + +## 4. Create the environment and set it up + +```bash +./toolkit_manager.sh init agent-toolkit # add --env for anything other than "local" +``` + +This clones the inference and toolkit repos into `ext/` and seeds `env//`. Then edit: +- `env//global_config.yaml`: `base_domain_name` (default `inteltoolkits.ai`), the proxy settings, `gateway_tls_mode`, `storage_backend`, and Kata (`kata_containers_enabled`, `kata_runtime`). +- `env//config.agent-toolkit.yaml`: components (`openshell_enabled`, `kuberay_enabled`, ...) and `llm_services_autodeploy_models`. For 128 GB set `["qwen2-5-coder-7b"]`. +- Multi-node or remote: list the nodes in `env//nodes.yaml` (`nodes_control_plane`, plus `nodes_workers` for dedicated workers, with the SSH user and key). `install` generates `inventory/hosts.yaml` from it, with `ansible_connection` set for each node. A main-track checkout older than commit `1cb0739` (10 Nov 2026) leaves `ansible_connection` out, so node tasks would run on the installer host: update it first (troubleshoot INS-21). To add or remove nodes after install, use `add-node` and `remove-node`. +- Export `HF_TOKEN` if any model is gated. + +The agent-toolkit-configuration skill explains every key. + +## 5. Install + +```bash +./toolkit_manager.sh install agent-toolkit --env +``` + +- It starts with the node readiness report on every node in `nodes.yaml` (report only, capped at 5 minutes; `node_preflight_enabled: false` turns it off). The report is in `env//logs/health-report-latest.{txt,html}`. A FAIL does not stop the install, but fix it with its hint and run the install again. +- It then installs infrastructure (Kubernetes, storage), platform, inference (LiteLLM, the guard model and the default model) and the toolkit. Validation runs on a fresh single node took 41-57 minutes. +- Progress and errors go to `env//logs/install-agent-toolkit-.log`. +- If it fails, use the agent-toolkit-troubleshoot skill, fix the cause, and run the same command again. Re-running resumes. + +## 6. Verify and connect + +```bash +export KUBECONFIG=$PWD/env//kubeconfig.yaml +kubectl get llminferenceservices -n llm-inference # every model Ready? (OVMS models: inferenceservices) +./toolkit_manager.sh validate agent-toolkit --env +``` + +- Always check the models first. The install waits for the guard and default models (15 minutes each by default) and fails if one is not Ready by then. Validate once every model is Ready. +- `validate` sends one test request through LiteLLM and, on NFS, creates and deletes a probe volume. Tell the user before running it. +- For client access (hosts entries, the CA in `env//logs/toolkit-manager-ca.crt`, the LiteLLM UI), see `references/lifecycle.md` "After install". +- For agent code, use the agent-toolkit-components skill. + +## Update, remove, start over + +`references/lifecycle.md` has: +- every command +- the timings +- what each teardown target deletes and keeps +- how to move to new toolkit or inference revisions (`init --upgrade`), and the two upgrades that need manual steps + +Warn the user before: +- `teardown agent-toolkit` or a toolkit component, which deletes that component's data and credentials +- `teardown inference`, which also removes the toolkit, LiteLLM and its master key +- `teardown platform`, which deletes every database, including LiteLLM keys and spend +- `teardown kubernetes` or `teardown infrastructure`, which delete the whole cluster diff --git a/.agents/skills/agent-toolkit-install/references/lifecycle.md b/.agents/skills/agent-toolkit-install/references/lifecycle.md new file mode 100644 index 00000000..39ed3959 --- /dev/null +++ b/.agents/skills/agent-toolkit-install/references/lifecycle.md @@ -0,0 +1,97 @@ +# Install, verify, update and remove + +All commands run from the Toolkit Manager root. `--env ` defaults to `local`. + +## Commands + +| Goal | Command | +|---|---| +| Full install, or re-apply settings (safe to re-run) | `./toolkit_manager.sh install agent-toolkit --env ` | +| Only the toolkit layer, without the layers below or the dependency pull | `./toolkit_manager.sh install agent-toolkit --only --env ` | +| One component | `./toolkit_manager.sh install --only --env ` (`redis_stack`, `pgvector`, `agent_sandbox`, `openshell`, `kuberay`, `keycloak_agent_config`, `litellm`, `vllm_sr`, ...) | +| Skip some components or layers | `--skip a,b` | +| Pass a variable for one run (wins over every file) | `... -- -e key=value` | +| Check health | `./toolkit_manager.sh validate agent-toolkit --env ` (add `--only` for the toolkit layer alone) | +| Show nodes, pods and URLs | `./toolkit_manager.sh status --env ` | +| List components and layers | `./toolkit_manager.sh show` | +| Verbose output | `TKM_LOG_LEVEL=debug ./toolkit_manager.sh ...`. The log then holds the LiteLLM master key and `HF_TOKEN` in plain text: never share it, and delete it when done. | +| Node readiness report (runs at the start of `install`; on its own: runs with sudo, may write `env//kubespray_extra.yml`) | `.venv/bin/ansible-playbook -i env//inventory/hosts.yaml ext/enterprise.agent-toolkit/playbooks/preflight-check.yml` (add `-K` if sudo needs a password) | + +`./toolkit_manager.sh --help` lists the actions and flags of the installed version. + +Logs: `env//logs/--.log`, one per run, newest 30 kept. + +## How long it takes + +Observed in validation runs (single node, behind a proxy); expect variation with hardware and network. + +| Operation | Observed time | +|---|---| +| Fresh `install agent-toolkit`, everything on, single node | 41-57 minutes | +| Two nodes on NFS | 52-57 minutes | +| Re-run with nothing changed | 5-8 minutes | +| `validate`, per layer | 12-95 seconds | +| One model deploy | 2-6 minutes; large models up to 20 minutes to load | +| `teardown kubernetes` / `teardown infrastructure` | 3-4 / 6-11 minutes | + +`FAILED - RETRYING: ... (N retries left)` lines are polling. A run is stuck only when the log has not grown for longer than the longest wait in progress (`tail -f` the log). + +## After install + +1. `kubectl get llminferenceservices -n llm-inference` (OVMS models: `inferenceservices`), until every model is Ready. The install waits for the guard and default models (15 minutes each by default) and fails if one is not Ready by then; other models can still be loading. +2. `./toolkit_manager.sh validate agent-toolkit --env `. It sends one test request through LiteLLM and, on NFS, creates and deletes a probe volume, so tell the user first. +3. The read-only health checks in the agent-toolkit-troubleshoot skill (step 1), for what `validate` does not cover: restarting pods, mesh labels, the gateway address and client name resolution. +4. Client access: map these names under `.` to the gateway IP: + - always: `litellm`, `langfuse`, `grafana` + - main track: also `litellm-ui`, `keycloak` and `headlamp` + - with KubeRay: `ray`; with the semantic router: `vllm-sr` + + `kubectl get httproute -A -o jsonpath='{range .items[*]}{.spec.hostnames}{"\n"}{end}' | sort -u` lists every published host. Trust `env//logs/toolkit-manager-ca.crt`. See the agent-toolkit-troubleshoot skill (`references/network.md`) for the exact commands. +5. Wire agents: agent-toolkit-components skill. + +## Re-running install + +- Re-running is the way to resume after a fix. Completed steps are skipped. +- LiteLLM is skipped when its release exists. Apply LiteLLM changes with `-- -e litellm_reconcile=true`. +- Helm-based platform components (cert-manager, Istio, Envoy Gateway, Keycloak, observability, CloudNativePG) are also skipped when their release exists, and they have no reconcile switch. Changing them means a teardown of that component and a reinstall **(deletes data)**. The teardown also removes every component that depends on it, in the layers above too. Never do it for `postgresql` (Keycloak, observability, LiteLLM keys and spend, Langfuse and every platform database go) or `cert_manager` (almost everything depends on it). See INS-11 in the agent-toolkit-troubleshoot skill. +- A healthy re-run keeps the Redis and pgvector passwords and the OpenShell key. + +## Teardown: what each target removes + +| Target | Removes | Keeps | +|---|---|---| +| `teardown ` (for example `openshell`) | That component and the toolkit components that depend on it (`agent_sandbox` also removes `openshell`) | Everything else | +| `teardown agent-toolkit` | The toolkit components and their namespaces, in reverse order | The inference layer: models, LiteLLM, **virtual keys and spend**, guardrail, routers. LiteLLM's access policy still lists the toolkit namespaces. Also the Kata runtime, the env files, the KubeRay CRDs and the OpenShell CLI cache on the installer host. | +| `teardown inference` | Inference **and** the toolkit, including LiteLLM, its master key Secret and Langfuse with **every trace** (its ClickHouse volumes in `langfuse`) | Platform and Kubernetes (virtual keys stay in the platform database) | +| `teardown platform` | Platform, inference and toolkit. **Deletes every platform database**, including LiteLLM keys and spend, and Langfuse's own database. | Kubernetes | +| `teardown kubernetes`, `teardown infrastructure` | The whole cluster (Kubespray reset) and `env//kubeconfig.yaml` | Env files. Local volume data in `/opt/local-path-provisioner` (model weights included) unless the version purges it. | + +Rules: +- Teardown asks for confirmation. Without a terminal it needs `--force`; add it only with the user's explicit OK. +- Only components that are switched **on** are torn down. To remove one that is switched off: `teardown -- -e _enabled=true` **(deletes data)**. +- A toolkit teardown deletes the component namespaces and their volumes. Redis data, pgvector data and every toolkit credential are gone, and new ones are generated on reinstall. +- Wait until `kubectl get ns` no longer shows the namespaces `Terminating` before reinstalling. +- `teardown kubernetes` reinstalls `kubectl` and `helm` after the reset. No need to run `configure` again. + +## Updating + +- **Settings:** edit `env//` files and re-run install (agent-toolkit-configuration skill). +- **Toolkit or inference code.** Ask the user before each step; they change checkouts. + 1. Update Toolkit Manager itself: `git -C pull`. This can change the branches it pins in `configs/repos/repos.agent-toolkit.yaml`. + 2. If a pin changed, `./toolkit_manager.sh init agent-toolkit --upgrade --env ` moves `ext/` to the new revision. It skips repos whose pin is unchanged (it prints `nothing to re-pin`), refuses if `ext/` has local changes, and reports new config keys without adding them. + 3. For newer commits on an unchanged branch: `git -C /ext/ pull --ff-only`. + 4. Compare the env files with this repo's `config.yaml` for new keys, then re-run install. +- **Two upgrades need more than a pin change:** + - OpenShell 0.0.x to 0.1.x has breaking changes and a manual migration (`docs/openshell.md`, "Upgrading from OpenShell 0.0.x"). + - Agent Sandbox v0.5.0 to v1.0.10 renames the router Deployment to `sandbox-router`. Teardown deletes only the new name, so delete the old `sandbox-router-deployment` by hand **(changes the cluster)**. +- **In-place upgrade from toolkit 1.1.0 (the classic `deploy-agentic-stack.sh` layout)** has not been tested. Install fresh. + +## Record for support + +```bash +git -C log -1 --oneline; git -C branch --show-current +git -C /ext/enterprise.agent-toolkit log -1 --oneline +git -C /ext/enterprise.ai-inference log -1 --oneline +``` + +The installer banner's version number is not enough. On `main` the pins are branches (`release-2.0` pins commits), so a fresh clone can get different code on different days, while an existing `ext/` stays where it was. diff --git a/.agents/skills/agent-toolkit-install/references/prerequisites.md b/.agents/skills/agent-toolkit-install/references/prerequisites.md new file mode 100644 index 00000000..ba3264ed --- /dev/null +++ b/.agents/skills/agent-toolkit-install/references/prerequisites.md @@ -0,0 +1,46 @@ +# Prerequisites checklist + +Check every row before the first install. Commands only read. Run them on each node unless noted. + +## Hardware and OS + +| Check | Command | Needed | +|---|---|---| +| CPU architecture and AMX | `lscpu \| grep -E 'Architecture\|Model name\|NUMA node\(s\)\|Core\(s\) per socket'`; `grep -o -m1 amx_bf16 /proc/cpuinfo` | x86_64. The model catalog requires AMX (4th Gen Intel® Xeon® processors or later) unless `env//models.yaml` sets `require_amx: false` under `defaults:`. | +| Memory | `free -g` | About **139 GiB** for the default install: default model `qwen2-5-coder-14b` 96 GiB, guard model `qwen3guard` 24 GiB, and about 19 GiB for the rest. On 128 GB set `llm_services_autodeploy_models: ["qwen2-5-coder-7b"]` (64 GiB) before installing. `docs/prerequisites.md` lists too little. | +| CPU cores | `nproc` | The default model takes the free physical cores of one NUMA node (`cpu: auto`). On a small or single-NUMA host, set an explicit `cpu:` per model in `models.yaml`. | +| Disk | `df -h / /var/lib/containerd /opt` | 200 GB or more. Model weights go to `/opt/local-path-provisioner` with the default `local-path` storage. | +| OS | `cat /etc/os-release` | Ubuntu 24.04 is what the toolkit was validated on. Ubuntu 22.04 and RHEL 8 are listed as supported by Toolkit Manager but were not exercised with the toolkit. | +| Swap | `swapon --show` | Off | + +## Host state + +| Check | Command | Why | +|---|---|---| +| Docker | `systemctl is-active docker` | Kubespray removes a running Docker, and its reset wipes the image store Docker uses. Do not install on a Docker host, or `docker save` and stop Docker first. | +| Ports 80 and 443 | `ss -ltn '( sport = :80 or sport = :443 )'` | The gateway's LoadBalancer IP is the node IP. | +| inotify limit | `sysctl fs.inotify.max_user_instances` | Expected 8192: Kubespray sets it (and `max_user_watches` 1048576) on every node. A lower value means an older Toolkit Manager checkout or an override (agent-toolkit-troubleshoot skill, INS-25). | +| Time sync | `timedatectl status \| grep synchronized` | Every node, for multi-node | +| Existing Kubernetes leftovers | `ls /etc/kubernetes /var/lib/kubelet 2>/dev/null` | Leftovers from a failed install break the next one. `teardown kubernetes` cleans them, but it runs a Kubespray reset on every inventory node: ask the user first. | + +## Access + +| Check | Command | Needed | +|---|---|---| +| sudo | `sudo -n true && echo nopasswd` | Passwordless sudo lets an assistant run the install. Otherwise the user runs it in a terminal and types the password. | +| Internet or proxy | `curl -sI https://github.com`; `env \| grep -ci '^https\?_proxy='` (counts, does not print values that may hold credentials) | Charts, images and manifests are pulled from the internet. Behind a proxy, put `http_proxy`, `https_proxy` and `no_proxy` in `env//global_config.yaml`. Write the URL with its port. `no_proxy` needs `localhost`, `127.0.0.1`, the node IPs and subnet, the cluster service and pod CIDRs (`kubernetes_service_cidr`, `kubernetes_cluster_cidr`), `.`, `.svc` and `.cluster.local`. The commented proxy block in `global_config.yaml` shows the full pattern. | +| Hugging Face | `[ -n "$HF_TOKEN" ] && echo set` | Needed for gated models. Export it in the shell that runs install and model-manager. | +| `git` | `git --version` | `configure` and `init` need it | +| Kata only | `ls -l /dev/kvm /dev/vhost-vsock; uname -r` | `/dev/kvm` on the nodes (VT-x, or nested virtualisation on a VM), the `vhost_vsock` module, and Linux 5.17 or newer for `kata-fc` on AMX CPUs | +| Multi-node | `ssh @ true` from the installer host | Key-based SSH as a non-root sudo user to every node. List the nodes in `env//nodes.yaml`; `install` generates the inventory with `ansible_connection` for each node, and `add-node` and `remove-node` change it after install. On the main track that needs Toolkit Manager commit `1cb0739` (10 Nov 2026) or later: `git -C merge-base --is-ancestor 1cb0739 HEAD && echo ok`. | + +## Not covered by validation + +Treat these as untested and say so to the user: +- bring-your-own clusters +- Ceph or NetApp storage +- air-gapped sites +- non-AMX CPUs +- arm64 installer hosts +- upgrades from toolkit 1.1.0 +- adding nodes after install with `add-node` (supported by Toolkit Manager, not yet validated with the toolkit) diff --git a/.agents/skills/agent-toolkit-troubleshoot/SKILL.md b/.agents/skills/agent-toolkit-troubleshoot/SKILL.md new file mode 100644 index 00000000..10e1947e --- /dev/null +++ b/.agents/skills/agent-toolkit-troubleshoot/SKILL.md @@ -0,0 +1,69 @@ +--- +name: agent-toolkit-troubleshoot +description: Diagnose and fix Intel® Agent Toolkit problems. Use when someone says "my install fails", "teardown is stuck", "health check my toolkit", "LiteLLM returns 401", "my model never gets Ready", "my agent gets connection reset", "the sandbox returns 401" or "I cannot open the LiteLLM UI", or when anything in the stack fails or behaves unexpectedly. Covers failed installs or teardowns (toolkit_manager.sh, Kubespray, kubeadm, preflight), unhealthy components (Agent Sandbox, Kata, OpenShell, Redis, pgvector, KubeRay, Keycloak realm), LiteLLM errors (401, 403, 400 invalid model, 500 guardrail blocks, 413, timeouts), model pods Pending, OOMKilled or never Ready, mesh connection resets, and client access (DNS, proxy, self-signed CA, LiteLLM UI). Starts with the installer's validate command, a short set of read-only kubectl checks and the install log, then matches the symptom to a catalog of known failures with the exact check and fix. +--- + +# Troubleshoot Intel® Agent Toolkit + +This file is a summary. The exact steps, commands and fixes are in the `references/` file that each table row points to: open that file before you answer. + +Diagnose read-only first. In the references, fixes that change the cluster, a host or an env file are marked **(changes the cluster)**, and fixes that lose data are marked **(deletes data)**. Show the command and get the user's OK first, and explicit confirmation for data loss. Never print secret values. + +## 1. Get the facts + +1. Find ``, `` and the track (`AGENTS.md`). +2. Check health. From ``, `./toolkit_manager.sh validate agent-toolkit --env ` checks each installed component. It changes nothing lasting, but it sends one test request through LiteLLM and, on NFS, creates and deletes a probe volume, so tell the user first. Then run these read-only checks, which cover what `validate` does not: + ```bash + export KUBECONFIG=/env//kubeconfig.yaml # first: an inherited KUBECONFIG may point at another cluster + kubectl get nodes; kubectl get pvc -A | grep -v Bound # nodes Ready, volumes Bound + kubectl get pods -A --no-headers | awk '{split($3,a,"/"); if (!($4=="Completed" || ($4=="Running" && a[1]==a[2])) || $5+0>5) print}' # not ready, or restarting + kubectl get llminferenceservices -n llm-inference # models Ready, the guard model too (OVMS models: inferenceservices) + kubectl get ns -L istio.io/dataplane-mode # which namespaces are in the mesh + kubectl get authorizationpolicy litellm-ingress -n litellm -o jsonpath='{.spec.rules[*].from[*].source.namespaces}' + kubectl get svc -n envoy-gateway-system -l gateway.envoyproxy.io/owning-gateway-name=eg-gateway -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}' + getent hosts litellm. # does this client resolve the gateway? + ``` + On a bring-your-own cluster, use the user's own kubeconfig instead. Then map what you see to the catalog: + - pods not ready or restarting: that component's entries (`references/components.md`; for `llm-inference`, `litellm` and `langfuse`, `references/inference.md`) + - a namespace missing from the mesh or from LiteLLM's list: `references/network.md` + - no gateway address, or a name that does not resolve: NET-1 +3. If an install or teardown failed, read the newest log, `/env//logs/--.log`. `references/install.md` "Read the log first" shows how to find the real error among the harmless ones. +4. Ask the user for the exact error text and what they ran, if you do not have it. + +## 2. Match the symptom + +| Area | Reference | IDs | +|---|---|---| +| Install, Kubespray, preflight, teardown, multi-node | `references/install.md` | INS-* | +| Agent Sandbox, Kata, OpenShell, Redis, pgvector, KubeRay, Keycloak realm | `references/components.md` | SBX, KATA, OSH, RDS, PGV, RAY, KCR | +| LiteLLM errors, guardrail, routers, models | `references/inference.md` | LLM, GRD, MOD | +| Reaching the stack from a client; mesh resets inside the cluster | `references/network.md` | NET-* | +| A page in `docs/` that gave wrong instructions | `references/known-doc-errors.md` | | + +Search the references for the exact error text first, for example `grep -rn 'too many open files' references/`. Entries quote messages as the user sees them. + +## 3. The most common problems + +| Symptom | Cause | Entry | +|---|---|---| +| Preflight `No internet connectivity`, or kubectl `Forbidden` | Proxy not set in `global_config.yaml`, or `no_proxy` too narrow | INS-2, NET-2 | +| Model pod Pending, or the install fails at the default model | The default install needs about 139 GiB of memory | INS-13 | +| `The connection to the server localhost:8080 was refused` | `KUBECONFIG` not exported | NET-3 | +| Re-install fails with `secrets is forbidden` at `kubeadm token create` | Half-built cluster from an earlier failure | INS-7 | +| LiteLLM 400, 401, 403 or 429 about a key | Over budget, expired, model not allowed, or invalid key; read `error.type` in the body | LLM-1 | +| `kubeadm init` times out after about 16 minutes (release track) | No systemd-resolved on the host | INS-6 | +| `https://litellm.` does not open | DNS or hosts entry, proxy, self-signed CA, or the UI URL | NET-1, LLM-7 | +| HTTP 500 `Blocked by the content-safety guardrail: ...` | Usually a correct block; or the guard model is not Ready | GRD-1, GRD-2 | +| Agent gets connection reset, or the sandbox SDK fails with 401 or 403 | Namespace not in the mesh or not allowed; ServiceAccount token; RBAC | NET table, SBX-5, SBX-6 | +| Docker images on the node are gone | Kubespray removes Docker | INS-4 | +| Multi-node: Kata fails on workers, or preflight FAILs | `ansible_connection` missing, or time not in sync | INS-21, INS-22 | + +## 4. Fix, then confirm + +- Apply the smallest fix in the entry. Re-run the failed command (`install` resumes where it can), then run the checks in step 1 again. +- When the code and `docs/` disagree, trust the code (`roles/`, `config.yaml`, `components.yaml`) and name the wrong doc page to the user. +- If nothing matches, collect the following for an issue report: + - the output of the step 1 checks + - the failing task and error from the log (only those lines: a debug log holds secrets) + - `kubectl describe` of the failing pod + - the revisions from the agent-toolkit-install skill (`references/lifecycle.md`, "Record for support") diff --git a/.agents/skills/agent-toolkit-troubleshoot/references/components.md b/.agents/skills/agent-toolkit-troubleshoot/references/components.md new file mode 100644 index 00000000..2073e701 --- /dev/null +++ b/.agents/skills/agent-toolkit-troubleshoot/references/components.md @@ -0,0 +1,187 @@ +# Toolkit component failures + +Each entry: what you see, why it happens, how to confirm it (read-only), and the fix. Fixes that change the cluster, a host or an env file are marked **(changes the cluster)**; fixes that lose data are marked **(deletes data)**. Ask the user before running them, and get explicit confirmation for data loss. + +`--only` re-runs a single component without its dependencies. Run the installer from the Toolkit Manager root: `./toolkit_manager.sh install --only --env `. + +Install output lines like `FAILED - RETRYING: ... Wait for ... (N retries left)` are polling, not failures. Look at the final `fatal:` line. + +## Agent Sandbox (`agent-sandbox-system`) + +### SBX-1 Install stops at `Wait for Agent Sandbox pods to be ready` +- **Why:** the task waits for **every** pod in `agent-sandbox-system`, not only the controller. One stuck pod is enough: a Kata pool pod, an image pull, or a user's claim that stays Pending. +- **Check:** `kubectl get pods -n agent-sandbox-system`, then `kubectl describe pod -n agent-sandbox-system | tail -20`. +- **Fix:** follow the pod's events. Kata pods: KATA-1 to KATA-3. Image pulls: registry access or proxy. + +### SBX-2 Install fails at `Apply manifest (CRDs + controller with extensions)` or `Download sandbox-router manifests` +- **Why:** these are fetched from github.com and raw.githubusercontent.com when the install runs. A blocked proxy, no internet, or GitHub rate limiting (HTTP 429) breaks them. +- **Check:** from the installer host, `curl -sI https://github.com` and `curl -sI https://raw.githubusercontent.com`. +- **Fix:** fix the proxy settings in `env//global_config.yaml`, or re-run later after a 429 **(changes the cluster)**. Air-gapped sites must mirror the manifests and override `agent_sandbox_manifest_url`, `agent_sandbox_router_manifest_base_url` and `agent_sandbox_router_manifests`, plus `agent_sandbox_router_image` and `agent_sandbox_python_runtime_image`, in `env//config.agent-toolkit.yaml`. The controller image is set inside the manifest, so the mirrored manifest must point at the mirrored image. + +### SBX-3 `agent_sandbox_version` was raised but the router still runs the old manifest +- **Why:** the router manifests are cached as `/tmp/agent-sandbox-router-` on the installer host and are not downloaded again when a file exists. +- **Check:** `ls -l /tmp/agent-sandbox-router-*` (an old date means a stale copy). +- **Fix:** delete those files, then `install agent_sandbox --only` **(changes the cluster)**. + +### SBX-4 SDK `SandboxWarmPoolNotFoundError("SandboxWarmPool requested does not exist: ...")`, `TimeoutError("Could not resolve claim readiness from claim ... within 180 seconds.")`, or 403 `... in the namespace "default"` +- **Why:** the SDK looked in the wrong namespace (its default is `"default"`), the warm pool name is wrong, or the pool has no ready pods. The 403 in `default` is a namespace mistake, not missing RBAC. The `TimeoutError` means no sandbox became ready in time; see SBX-1. +- **Check:** `kubectl get sandboxwarmpool -n agent-sandbox-system`; `kubectl get sandboxclaim -A`. +- **Fix:** pass `namespace="agent-sandbox-system"` and `warmpool="python-pool"` (or `"kata-pool"`). + +### SBX-5 SDK or API `403 ... cannot create resource "sandboxclaims"` +- **Why:** Kubernetes RBAC. The SDK creates claims with the caller's own credentials, so an agent pod needs a Role. +- **Check:** `kubectl auth can-i create sandboxclaims.extensions.agents.x-k8s.io -n agent-sandbox-system --as=system:serviceaccount::` +- **Fix:** apply the Role and RoleBinding from the agent-toolkit-components skill (`references/sandbox.md`) **(changes the cluster)**. + +### SBX-6 HTTP 401 from the router, or `SandboxRequestError: Failed to communicate with the sandbox at .../execute` +- **Why:** the SDK raises `SandboxRequestError` for any failed request. Look at the exception's `status_code`: + - `401`: no ServiceAccount token, an expired one, or one made with `--audience`. The router checks every call with the Kubernetes TokenReview API; there is no router Secret. + - None: a connection error (wrong `api_url`) or a timeout. `commands.run` defaults to 60 s. + - 5xx or 404: the router or the sandbox pod failed (SBX-1). +- **Check:** where the agent gets its token. A token from `kubectl create token` expires after an hour; a pod's token file is rotated by the kubelet, so a value read once at start-up goes stale. +- **Fix (401):** pass `extra_headers={"Authorization": f"Bearer {token}"}` in `SandboxDirectConnectionConfig`, with the pod's own token read for each new client (agent-toolkit-components skill, `references/sandbox.md`). Do not add `--audience` to `kubectl create token`. + +### SBX-7 Code in a sandbox cannot reach LiteLLM, Redis, an internal mirror or any private address (timeout) +- **Why:** by design. Sandbox egress allows public IPs only, and DNS is public resolvers only. Behind a proxy-only network, sandboxes have no egress at all. +- **Check:** `kubectl get networkpolicy eat-sandbox-pool-egress -n agent-sandbox-system -o yaml` +- **Fix:** do not open it up. Pass data through the SDK, or use OpenShell for egress controlled by policy. + +### SBX-8 A custom SandboxTemplate's pods escape the egress rules +- **Why:** the template lacks the pod label `istio.io/dataplane-mode: none`. The pod joins the mesh, and ambient traffic is not subject to the NetworkPolicy. +- **Fix:** add the label to the template's pod metadata, as both shipped templates have **(changes the cluster)**. + +### SBX-9 `kubectl get --raw /api/v1/namespaces/agent-sandbox-system/services/sandbox-router-svc:8080/proxy/...` fails with `ServiceUnavailable` +- **Why:** the namespace is meshed, and the API server may not reach it through the mesh (it works on some installs). +- **Fix:** use `kubectl port-forward -n agent-sandbox-system svc/sandbox-router-svc 8080:8080`. + +## Kata Containers (infrastructure component, switches in `global_config.yaml`) + +### KATA-1 Install stops with a Kata host check +| Message (start) | Fix | +|---|---| +| `kata_containers_enabled is set, but this is a BYO cluster (existing_kubernetes)` | Kata is supported only on clusters the installer builds. | +| `kata_runtime='' is not valid` | Use `kata-fc`, `kata-qemu` or `both`. | +| `... no cluster node exposes /dev/kvm` | The installer has already tried loading the KVM modules. Enable virtualisation (VT-x) in the BIOS, or nested virtualisation on a VM **(changes the cluster)**. | +| `/dev/vhost-vsock is missing on: ...` | The installer has already run `modprobe vhost_vsock`, so the kernel could not load it. Check `modinfo -n vhost_vsock` on those nodes. If the module is missing, install the kernel's modules package or move to a kernel that has it **(changes the cluster)**. On Ubuntu 24.04 the generic kernel ships it in `linux-modules-$(uname -r)`. | +| `kata-fc (Firecracker) cannot start microVMs on these AMX-capable nodes ... requires Linux >= 5.17` | Upgrade the kernel, or use `kata_runtime: kata-qemu` **(changes the cluster)**. | +| `... needs Firecracker, but no node has containerd's devmapper snapshotter in 'ok' state` | See KATA-3. | + +### KATA-2 Kata pool pod stuck `ContainerCreating` with `FailedCreatePodSandBox ... too many open files` +- **Why:** `fs.inotify.max_user_instances` is too low (128) on that node. Kubespray sets 8192 on every node, so a low value means an older Toolkit Manager checkout or an override in `env//kubespray_extra.yml`. +- **Check:** `sysctl fs.inotify.max_user_instances` on the node; `kubectl get events -A --field-selector reason=FailedCreatePodSandBox`. +- **Fix:** remove the override, or update the checkout, and re-run the install **(changes the cluster)**. On a cluster you cannot re-run, raise `fs.inotify.max_user_instances` and `fs.inotify.max_user_watches` on the node by hand **(changes the cluster)**. + +### KATA-3 `FailedCreatePodSandBox ... snapshotter devmapper was not found` on a worker (kata-fc) +- **Why:** the node's tasks ran on the installer host instead, because the node has no `ansible_connection` in the inventory. The worker never got the devmapper thin-pool. +- **Check:** `grep -n ansible_connection env//inventory/hosts.yaml`. On the node: `sudo /.kubespray/bin/ctr plugins ls | grep devmapper` on a single-node install, or `sudo /usr/local/bin/ctr plugins ls | grep devmapper` on the nodes of a multi-node one (should be `ok`; `ctr` is not on root's PATH). +- **Fix:** see INS-21 in `install.md` (an older main-track checkout, or a hand-written inventory), then re-run the install **(changes the cluster)**. + +### KATA-4 After `teardown kubernetes`, the next Kata install fails on leftovers +- **You see:** `/opt/kata`, `nydus-for-kata-tee.service` or `containerd-devmapper.service` still present, or a thin-pool on deleted loop files. +- **Check:** `ls /opt/kata; systemctl list-units | grep -E 'kata|devmapper'; sudo dmsetup ls` +- **Fix:** check whether your Toolkit Manager version purges Kata on teardown (`grep -n kata roles/kubernetes/tasks/teardown.yaml` in the Toolkit Manager checkout). If it does not, remove the leftovers by hand before reinstalling **(changes the cluster)**. + +Info: the Kata Helm release gets a new revision on every run. That is harmless. + +## OpenShell (`openshell-system`, `openshell-sandboxes`) + +### OSH-1 Install fails at the CRD check +- **Why:** OpenShell needs the Agent Sandbox CRDs (`sandboxes.agents.x-k8s.io`, version `v1beta1`). +- **Fix:** set `agent_sandbox_enabled: true` and install both **(changes the cluster)**. + +### OSH-2 `kubectl port-forward to svc/openshell did not start:` +- **Check:** `kubectl get pods -n openshell-system` (gateway ready?), and whether the installing user may port-forward. + +### OSH-3 `Gateway 'eat' already exists` during `Register profile and provider` +- **Why:** the installer keeps OpenShell CLI state per user in `~/.cache/eat/openshell-cli-/`. Two installs at once from the same account, or manual CLI use in that directory, collide. +- **Fix:** run one install at a time per account, then re-run **(changes the cluster)**. + +### OSH-4 `Error: × No active gateway. Set one with: openshell gateway select ` +- **Why:** your own CLI is not registered; the install's registration is private to the installer. +- **Fix:** connect as in the agent-toolkit-components skill (`references/openshell.md`, "Connect the CLI"). + +### OSH-5 LLM call fails with `policy_denied` or `binary ... not allowed in policy '_provider_genai_gateway'` +- **Why:** the program calling LiteLLM is not in the provider profile's `binaries` list. +- **Fix:** add its resolved path to `charts/openshell/genai-gateway-provider.yaml` in this repo and run `install openshell --only` **(changes the cluster)**. + +### OSH-6 Sandbox LLM calls get 401 after the `openshell-sandboxes` key was revoked +- **Why:** the installer mints a key only when Secret `openshell-genai-key` is missing. +- **Fix:** `openshell provider delete genai-gateway`, `kubectl delete secret openshell-genai-key -n openshell-system`, then `install openshell --only` **(changes the cluster)**. + +### OSH-7 Sandbox log shows `Policy fetch failed ... failed to connect to OpenShell server` +- **Why:** sandbox DNS is blocked by NetworkPolicy `eat-openshell-sandbox-pods` (unusual DNS setup). +- **Fix:** set `openshell_sandbox_dns_cidrs` to your DNS server addresses and re-run `install openshell --only` **(changes the cluster)**. + +### OSH-8 Sandbox stuck in `Provisioning` +- **Check:** `kubectl get pods,pvc -n openshell-sandboxes`; `kubectl describe pod -n openshell-sandboxes | tail -20`. Normal time to Ready is under about a minute. +- **Fix:** a Pending PVC points at storage. NFS-backed workspaces are slow; the shipped default is `local-path`. + +### OSH-9 `openshell logs --source sandbox | grep DENIED` is empty although a request was blocked +- **Why:** the log lags. +- **Fix:** retry for about 30 seconds. + +### OSH-10 `transport error`, `Connection reset by peer` or `ssh tar extract exited with status 255` +- **Why:** the `kubectl port-forward` stream dropped. +- **Fix:** restart the port-forward and retry. + +### OSH-11 Helm ownership error about ClusterRole `openshell-node-reader` on a second install (OpenShell 0.0.116) +- **Fix:** use a different `openshell_release_name` for the second install **(changes the cluster)**. + +## Redis Stack (`redis`) + +### RDS-1 `Redis Stack Helm install failed: ` +- **Check:** read the Helm message. `kubectl get pvc -n redis` (Pending means no default StorageClass). +- **Fix:** set `redis_stack_storage_class`, or fix image pulls, then re-run **(changes the cluster)**. A failed release is removed automatically on the next run. + +### RDS-2 Client `WRONGPASS invalid username-password pair` +- **Why:** usually the password changed when Redis was torn down and reinstalled. Some clients also fail when the URL has an empty username; the stored URL uses `default:`. +- **Fix:** use `REDIS_URL` from the current Secret. + +### RDS-3 Changing `redis_stack_persistence_size` fails with `updates to statefulset spec for fields other than ... are forbidden` +- **Why:** the volume claim template is fixed after the first install, and `local-path` volumes cannot grow. +- **Fix:** keep the size, or tear down Redis and reinstall **(deletes data)**. + +### RDS-4 Data written since the last snapshot is gone after a Redis pod restart +- **Why:** append-only persistence is off, so writes since the last RDB snapshot are lost on restart (vector indexes too). +- **Fix:** avoid casual restarts; keep anything that must survive in pgvector. + +## pgvector (`pgvector`) + +### PGV-1 `pgvector Helm install failed: ` +- **Why:** usually a timeout on slow storage (first start can take about 5 minutes on NFS), or a Pending PVC. +- **Fix:** re-run **(changes the cluster)**; a failed release is removed first. + +### PGV-2 Validate fails at `Check pgvector extension`, or `FATAL: role "" does not exist` +- **Why:** `pgvector_username` or `pgvector_database` was changed after the first install. +- **Fix:** restore the original values, or tear down pgvector with the original values still set, then change them and reinstall **(deletes data)**. + +### PGV-3 App error `expected 1536 dimensions, not N` +- **Why:** the tables created at install use `VECTOR(1536)`. +- **Fix:** create your own table with your embedding model's dimension. + +## KubeRay (`ray-system`) + +### RAY-1 Install stops at `Wait for Ray head pod` or `Wait for the Ray workers` +- **Why:** not enough CPU or memory (head 0.5 CPU / 2 GiB, each worker 0.5 CPU / 2 GiB), or the large `rayproject/ray` image is still pulling. A few retries are normal. +- **Check:** `kubectl get pods -n ray-system`; `kubectl describe pod -n ray-system | tail -20`. +- **Fix:** free capacity or lower the `kuberay_*` resource settings, then re-run **(changes the cluster)**. + +### RAY-2 `kubectl scale raycluster ...` fails +- **Why:** RayCluster has no scale subresource; the autoscaler owns replicas. +- **Fix:** set `kuberay_worker_replicas`, `kuberay_worker_min_replicas` or `kuberay_worker_max_replicas` and run `install kuberay --only` **(changes the cluster)**. + +### RAY-3 Client fails on connect with a version mismatch +- **Fix:** the client must use `ray[default]==2.40.0` on Python 3.12. + +### RAY-4 Dashboard returns 401 +- **Why:** basic auth on the external route. User `ray`, password from Secret `ray-dashboard-auth` in `ray-system`. It is not the LiteLLM key. + +## Keycloak agent realm (`keycloak_agent_config`) + +### KCR-1 `Wait for Keycloak to be ready` times out +- **Why:** `keycloak_agent_config_enabled: true` while Keycloak itself is not installed. +- **Check:** `kubectl get statefulset -n keycloak` +- **Fix:** enable Keycloak, or leave `keycloak_agent_config_enabled` at its default, then re-run **(changes the cluster)**. + +### KCR-2 `Realm import 'agent-toolkit' failed: ` +- **Check:** `kubectl get keycloakrealmimport agent-toolkit -n keycloak -o jsonpath='{.status.conditions}'` diff --git a/.agents/skills/agent-toolkit-troubleshoot/references/inference.md b/.agents/skills/agent-toolkit-troubleshoot/references/inference.md new file mode 100644 index 00000000..8d33e433 --- /dev/null +++ b/.agents/skills/agent-toolkit-troubleshoot/references/inference.md @@ -0,0 +1,152 @@ +# LiteLLM, models, guardrail and routers + +The toolkit uses the inference layer (`/ext/enterprise.ai-inference/`) for every LLM call: LiteLLM in namespace `litellm`, models in `llm-inference`. Fixes marked **(changes the cluster)** need the user's OK. + +## Read a LiteLLM error correctly + +Classify by the JSON body (`error.type`, `error.message`) first. Status codes for key problems differ between LiteLLM versions: an over-budget key is 400 on the release track and 429 on the main track, and a model the key may not use is 401 on release and 403 on main. + +| Status | Body or situation | Meaning | Entry | +|---|---|---|---| +| 400, 401, 403 or 429 | `error.type` `budget_exceeded`, `expired_key`, `key_model_access_denied`, `team_model_access_denied`, `auth_error` or `token_not_found_in_db` | A key problem: over budget, expired, model not allowed, or a missing or invalid key | LLM-1 | +| 400 | `Invalid model name passed in model=` | The model is not registered under that name | LLM-2 | +| 500 | starts with `Custom code guardrail execution failed: Blocked by the content-safety guardrail:` | The guardrail decided; read the reason | GRD-1 | +| 500 | anything else | A backend or model error | MOD-* | +| 413 | | Request body too large for the AI gateway | LLM-6 | +| 429 | no LiteLLM error body | Edge rate limit at the gateway: 600 requests a minute per client IP | | +| 503, 504 | | AI gateway or model unavailable, or a 600 s timeout | MOD-* | +| Connection reset | | Mesh policy, not LiteLLM | `network.md` | + +## LiteLLM + +### LLM-1 A key problem (400, 401, 403 or 429 with a LiteLLM error body) +- **Check:** read `error.type` in the response. With the master key held in a variable, `GET /key/info?key=` shows `models`, `expires`, `spend` and `max_budget`. +- **Fix:** mint a key with the right models and budget, or raise the budget with `POST /key/update` **(changes the cluster)** (agent-toolkit-components skill, `references/litellm.md`). + +### LLM-2 `Invalid model name passed in model=. Call /v1/models to view available models for your key.` +- **Why:** the name differs from the deploy name, the model is still loading or failed, or a doc example names a model you do not run (many examples use `qwen2-5-coder-14b`). +- **Check:** `GET /v1/models` with the same key; `kubectl get llminferenceservices,inferenceservices -n llm-inference`. +- **Fix:** use a name from `/v1/models`, or wait until the model is Ready (MOD-5). Ready but missing: MOD-6. + +### LLM-3 Embeddings return HTTP 400, or rerank returns HTTP 500, through LiteLLM +- **Why:** the model is registered in LiteLLM as `openai/` with no `mode`. LiteLLM then sends an embeddings request vLLM rejects, and has no rerank route for that provider. Current inference revisions register vLLM embedding and rerank models as `hosted_vllm/` with `model_info.mode`, but only on a deploy with `--wait` (the install and the documented commands use it). A deploy without `--wait` registers the model from a background reconciler that does not know its category, so it still gets `openai/`. Older main-track revisions always used `openai/`. +- **Check:** models are stored in LiteLLM's database, not in the `litellm-config` ConfigMap. With a port-forward (`kubectl port-forward -n litellm svc/litellm 4000:4000`) and the master key in a variable: `curl -s localhost:4000/model/info -H "Authorization: Bearer $MK" | jq '.data[] | {model_name, model: .litellm_params.model, mode: .model_info.mode}'`. +- **Fix:** `./model-manager deploy --wait` again, which registers it again with the right provider **(changes the cluster)**. On an older inference revision, re-register the model with `POST /model/new`: `litellm_params.model` = `hosted_vllm/`, the same `api_base`, and `model_info.mode` = `embedding` or `rerank` **(changes the cluster)**. + +### LLM-4 A changed LiteLLM setting (hybrid router, tier candidates, sizing, `routing_mode`) has no effect +- **Why:** an existing LiteLLM release is skipped: `LiteLLM already deployed in litellm — skipping install (litellm_reconcile: true upgrades it with the current settings).` The access policies, the HTTPRoute and the guardrail are applied on every run anyway. +- **Fix:** `./toolkit_manager.sh install litellm --only --env -- -e litellm_reconcile=true` **(changes the cluster)**. + +### LLM-5 Client times out on chat calls +- **Why:** CPU inference. A busy 14B model has taken 85 s, and 1,500 output tokens about 3 minutes through the gateway. +- **Fix:** client timeout of at least 180 s; lower `max_tokens`; or use a smaller model. + +### LLM-6 HTTP 413 on large requests (long histories, many tool schemas) +- **Why (likely, not reproduced):** the AI gateway (Gateway `ai-gateway` in `llm-inference`) uses Envoy's default request buffer of 32 KiB unless a ClientTrafficPolicy raises it. +- **Check:** `kubectl get clienttrafficpolicy -A -o yaml | grep -B8 bufferLimit`. Look only at a policy whose `targetRefs` names the `ai-gateway` Gateway; one for another Gateway (such as `semantic-router`) does not count. +- **Fix:** shorten the request, and report the size that failed. Raising the buffer is an inference-layer change. + +### LLM-7 The admin UI does not open +- **Main track:** `https://litellm-ui./ui/`, sign in through Keycloak as a member of `platform-admins` (day-0 user `platform-admin`; first password in Secret `platform-bootstrap-admin`, key `value`, namespace `keycloak`; change it at first sign-in). The browser must also resolve and trust `keycloak.`. Password and master-key login are disabled. +- **Release track:** `https://litellm./ui/` with user `admin` and the master key as password. The trailing slash is required; without it the browser is redirected to an `http://` URL that fails. +- **Main track, path mode:** the UI is at `https:///litellm/ui/`. +- **Check URLs:** `kubectl get cm litellm-credentials -n litellm -o jsonpath='{.data}'` names the API host (`api_url` or `hostname`) and the UI (`ui_url`, the full address). It holds no secrets. + +### LLM-8 Traces stop appearing in Langfuse +- **Check:** `kubectl get pods -n langfuse` and look at restarts of the ClickHouse pod: `kubectl describe pod -n langfuse | grep -A3 'Last State'`. +- **Why:** a ClickHouse pod that is OOMKilled drops traces silently; LiteLLM still answers normally. It has been seen with the default small sizing. +- **Fix:** report it with the restart count. LiteLLM traffic is not affected. + +## Guardrail + +### GRD-1 HTTP 500 `Custom code guardrail execution failed: Blocked by the content-safety guardrail: ` +The guardrail screens the last user message of **every** request and every key, embeddings included. The reason tells you what happened: + +| Reason | Meaning | Action | +|---|---|---| +| `unsafe content (categories: X).` | A real policy block. The guardrail worked. | Rephrase. Not a fault. | +| `controversial content (categories: X).` | Blocked because `guard_block_on_controversial: true` | Set it to `false` if not wanted, and re-run install **(changes the cluster)** | +| `the guard model backend is unreachable ().` | **Infrastructure.** Fail-closed, so every request is blocked. | GRD-2 | +| `the prompt is longer than the guard model's context window (qwen3guard), so it could not be screened.` | The prompt is over about 32k tokens. The guard is the stack's size limit. | Shorten the prompt | +| `the guard model's verdict could not be parsed (qwen3guard).` | The guard model replied in an unexpected format | Check the guard model and template versions | + +### GRD-2 Every request is blocked: `the guard model backend is unreachable (...)` +- **Check:** `kubectl get llminferenceservice qwen3guard -n llm-inference -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}'` (must be `True`). + +| In the brackets | Cause | Fix | +|---|---|---| +| `404`, or a connection error right after install | The guard model is not deployed or not Ready yet. It loads first and can take several minutes. | Wait until Ready. If it failed, see MOD-*. | +| `403` behind a corporate proxy | LiteLLM's call to the guard went to the proxy | Re-run the install; it adds the guard address to LiteLLM's `NO_PROXY` **(changes the cluster)** | +| `Blocked URL` | The guard host is missing from LiteLLM's allowed hosts | Re-run the install **(changes the cluster)** | +| `500` | The guard pod is down | `kubectl get pods -n llm-inference \| grep qwen3guard`, then MOD-* | + +`./model-manager undeploy all` removes the guard model too, and then every request is blocked. Redeploy it with `./model-manager deploy qwen3guard` **(changes the cluster)**. To run without the guardrail, follow the agent-toolkit-configuration skill (section 4, "Guardrail off"). On the main track, setting `guardrails_enabled: false` alone does not unregister it. + +## Routers + +### GRD-3 `hybrid-router` always answers with the same model +- **Why:** its tier candidates are static. By default every tier is the first model in `llm_services_autodeploy_models`. Models deployed later do not join it on re-run. +- **Fix:** set `hybrid_router_tier_candidates` (see `/ext/enterprise.ai-inference/roles/litellm/defaults/main.yaml` for the format) in `env//config.agent-toolkit.yaml`, then install with `-- -e litellm_reconcile=true` **(changes the cluster)**. + +### GRD-4 `vllm-sr/auto` does not route to a newly deployed model +- **Why:** the vLLM Semantic Router picks its routable models when it is installed. +- **Fix:** re-run `./toolkit_manager.sh install vllm_sr --only --env ` after deploying the model **(changes the cluster)**. + +### GRD-5 HTTP 500 for under a second right after a model deploy or a router change +- **Why:** the AI gateway reloads its configuration. +- **Fix:** retry. + +### GRD-6 The vLLM Semantic Router install times out behind a slow proxy +- **Why:** its classifier models download at first start. +- **Check:** `kubectl get pods -n vllm-semantic-router-system` +- **Fix:** re-run the install once the pod is up **(changes the cluster)**. + +## Models (`llm-inference`) + +Start with: +```bash +kubectl get llminferenceservices,inferenceservices -n llm-inference +kubectl describe llminferenceservice -n llm-inference +kubectl get pods -n llm-inference -o wide | grep +kubectl describe pod -n llm-inference | sed -n '/Events/,$p' +kubectl logs -n llm-inference deploy/-kserve -c main --tail=200 # add --previous after a crash +``` +Select the model pod with `deploy/-kserve`. A label selector such as `-l app.kubernetes.io/name=` also matches the router-scheduler pod. + +### MOD-1 Pending: `didn't match Pod's node affinity` +- **Why:** the catalog requires AMX CPUs (`require_amx: true`), and no node has the AMX label, or node feature discovery is not running. +- **Check:** `kubectl get nodes -L feature.node.kubernetes.io/cpu-cpuid.AMXBF16`; `kubectl get pods -n node-feature-discovery`. +- **Fix:** on non-AMX hosts set `require_amx: false` under `defaults:` in `env//models.yaml`, then deploy the models again **(changes the cluster)**. The guard model needs it too. + +### MOD-2 Pending: `Insufficient cpu` or `Insufficient memory` +- **Check:** `kubectl describe node | grep -A8 'Allocated resources'` +- **Why:** models are Guaranteed pods. A redeploy briefly needs the requests **twice** (rolling update). +- **Fix:** lower `cpu` and `memory` in `env//models.yaml`, or undeploy a model **(changes the cluster)**. + +### MOD-3 `OOMKilled`, exit code 137, or CrashLoopBackOff without a config error +- **Why:** memory is below the weights plus the KV cache (`VLLM_CPU_KVCACHE_SPACE`, in GiB) plus overhead. +- **Fix:** raise `memory` for the model and deploy again, or deploy with a smaller cache: `./model-manager deploy --env VLLM_CPU_KVCACHE_SPACE=` **(changes the cluster)**. + +### MOD-4 CrashLoopBackOff with a vLLM configuration error +Read `kubectl logs ... --previous`. The shipped catalog already works around the first three below; you see them only with your own `args:` or an older catalog: +- `--mamba-block-size can only be set with --enable-prefix-caching` +- `CrossAttentionManager does not support caching` +- `mat1 must be a 2D tensor` (vision models) +- `Target model vocab_size=... Draft model vocab_size=...`: `qwen2-5-coder-14b-specdec` never loads (upstream vLLM limitation) + +`qwen3-5-2b-ovms` crashes with SIGSEGV (exit 139) on some Intel® Xeon® hosts. Do not use these two models. + +### MOD-5 Running but never Ready; events show `Startup probe failed` +- **Why:** a large model has up to 20 minutes to load. `./model-manager deploy --wait` gives up after 900 s, exits 1, and rolls back a model it created. +- **Fix:** watch `kubectl get llminferenceservice -n llm-inference`, or deploy with `--wait --wait-timeout 1800` **(changes the cluster)**. + +### MOD-6 Ready, but missing from `/v1/models` (`The model is serving but will NOT appear in /v1/models.`) +- **Why:** registration in LiteLLM failed. From the host it runs a short-lived curl pod in `litellm`, which needs to pull its image. +- **Fix:** `./model-manager deploy ` again to re-register **(changes the cluster)**. + +### MOD-7 Redeploying a changed model fails: `only 0 balloon slot(s) free` +- **Why:** the CPU pre-flight counts the model's own running pod. +- **Fix:** undeploy, then deploy; or run the deploy with `MM_NRI_PREFLIGHT=warn` **(changes the cluster)**. + +### MOD-8 model-manager stops with `Multiple environments available but stdin is not a terminal.` +- **Fix:** `TKM_ENV= ./model-manager ...`. Its `--env K=V` option sets an environment variable in the model pod; it does not pick the Toolkit Manager environment. diff --git a/.agents/skills/agent-toolkit-troubleshoot/references/install.md b/.agents/skills/agent-toolkit-troubleshoot/references/install.md new file mode 100644 index 00000000..15ce93eb --- /dev/null +++ b/.agents/skills/agent-toolkit-troubleshoot/references/install.md @@ -0,0 +1,172 @@ +# Install, re-install and teardown failures + +Commands run from the Toolkit Manager root (``). Fixes marked **(changes the cluster)** change the cluster, a host or an env file; **(deletes data)** loses data. Get the user's OK, and explicit confirmation for data loss. + +## Read the log first + +The newest file in `env//logs/` is the last run: `--.log`. One file holds every pass of that run. + +```bash +log=$(ls -t env//logs/*.log | head -1) +sed 's/\x1b\[[0-9;]*m//g' "$log" | grep -n -A4 'PLAY RECAP' | tail -20 # which pass failed +# real errors only: fatal lines with no "...ignoring" in the next 6 lines, with the 8 lines after each (EXEC lines, which hold secrets in a debug log, are left out) +sed 's/\x1b\[[0-9;]*m//g' "$log" | grep -v ' EXEC ' | awk '{l[NR]=$0} END{for(i=1;i<=NR;i++) if(l[i]~/fatal:/) {ign=0; for(k=1;k<=6;k++) if(l[i+k]~/^\.\.\.ignoring/) ign=1; if(ign) continue; for(j=i-2;j<=i+8&&j<=NR;j++) if(j>0) print j": "l[j]; print "--"}}' | tail -60 +``` + +- A `fatal:` followed by `...ignoring` is harmless. Kubespray probes things on a fresh install (`etcd --version`, `calicoctl.sh get ...`). +- `FAILED - RETRYING: ... (N retries left)` is polling. +- `the output has been hidden due to the fact that 'no_log: true'` hides secret-handling tasks. Debug them from the pod side (logs, Secret present or not). Never turn `no_log` off. +- `TKM_LOG_LEVEL=debug ./toolkit_manager.sh install ...` gives verbose Ansible output (`-vvv`). That log holds secrets in plain text, even from `no_log` tasks: the `EXEC` lines of the model deploy carry the LiteLLM master key and `HF_TOKEN`. Never share a debug log, leave out its `EXEC` lines when you read it (`grep -v '> EXEC '`), and delete it when done. + +## Before or at the start of the install + +### INS-1 `configure` refuses: `Refusing: stdin is not a terminal and --force was not passed.` +- **Why:** `configure` asks for confirmation and needs a terminal. Some versions also reject `configure --force`. +- **Fix:** the user runs `./toolkit_manager.sh configure` in a real terminal **(changes the cluster)**. Check whether the version accepts `--force`: `./toolkit_manager.sh --help | grep -n configure`. + +### INS-2 Preflight: `No internet connectivity — cannot reach https://google.com ...` +- **Fix:** set `http_proxy`, `https_proxy` and `no_proxy` in `env//global_config.yaml` **(changes the cluster)**. `no_proxy` needs `localhost`, `127.0.0.1`, the node IPs and subnet, the cluster service and pod CIDRs (`kubernetes_service_cidr`, `kubernetes_cluster_cidr`), `.`, `.svc` and `.cluster.local`. Always write the proxy URL with its port. + +### INS-3 Preflight stops on the auth setting: `auth_type must be jwt or litellm_vkey (got '...'); the deprecated auth_provider ('...'), if set, must agree with it.` +- **Why (main track):** `env//global_config.yaml` still has an `auth_provider:` line from an older environment, and it disagrees with `auth_type` in `config.agent-toolkit.yaml`. +- **Check:** `grep -nE '^(auth_type|auth_provider):' env//{config.inference,config.agent-toolkit,global_config}.yaml` +- **Fix:** delete the `auth_provider` line from `global_config.yaml` **(changes the cluster)**. + +### INS-4 Docker containers and images on the host are gone +- **Why:** Kubespray uninstalls a running Docker and its reset wipes the containerd image store that Docker uses. +- **Check:** `systemctl is-active docker` +- **Fix:** do not install on a host that runs Docker workloads. Otherwise `docker save` what you need and stop Docker first **(changes the cluster)**. + +### INS-5 Ports 80 and 443 are already in use on the node +- **Why:** the gateway's LoadBalancer IP is the node IP. +- **Check:** `sudo ss -ltnp '( sport = :80 or sport = :443 )'` +- **Fix:** stop whatever listens there before installing **(changes the cluster)**. + +## Kubernetes (Kubespray / kubeadm) + +### INS-6 `kubeadm init` times out: `wait-control-plane ... kube-apiserver check failed ... connection refused` (release track) +- **Why:** the host has no systemd-resolved. (On the main track the installer picks the kubelet's DNS file per node, so this does not happen.) Kubespray tells the kubelet to read `/run/systemd/resolve/resolv.conf`, which does not exist. The kubelet log shows `open /run/systemd/resolve/resolv.conf: no such file or directory`. About 16 minutes are lost before it fails. +- **Check:** `systemctl is-active systemd-resolved; ls /run/systemd/resolve/resolv.conf` +- **Fix:** add these two lines to `env//kubespray_extra.yml` (create it if missing), then `./toolkit_manager.sh teardown kubernetes --env ` and install again **(changes the cluster)**: + ```yaml + kube_resolv_conf: "/etc/resolv.conf" + resolvconf_mode: "none" + ``` + When only some nodes lack systemd-resolved, also set `upstream_dns_servers`. The node readiness report at the start of `install` writes all of these lines for you. + +### INS-7 Re-run after a failed kubeadm: `secrets is forbidden: User "kubernetes-admin" cannot create resource "secrets" ... "kube-system"` +- **Why:** a half-initialised control plane (`/var/lib/kubelet/config.yaml` exists, but `env//kubeconfig.yaml` was never written). +- **Fix:** `./toolkit_manager.sh teardown kubernetes --env `, then `install` **(changes the cluster)**. + +### INS-8 `etcd : Configure | Ensure etcd is running` fails after an earlier teardown on the same host +- **Check:** `sudo journalctl -u etcd -n 50 --no-pager; sudo ls /var/lib/etcd` +- **Fix:** `teardown kubernetes` again (twice has been needed), then reinstall **(changes the cluster; rebuilds the cluster)**. + +### INS-9 `kubectl missing. Run './toolkit_manager.sh configure' or install it manually.` after a teardown +- **Why:** the Kubespray reset deletes `/usr/local/bin/kubectl` and `helm` on SSH or multi-node installs. `teardown kubernetes` reinstalls them right after the reset, so this means an older checkout, a reset run by hand, or a teardown that stopped half-way. +- **Fix:** the user runs `./toolkit_manager.sh configure` again **(changes the cluster)**. + +### INS-10 `No such file or directory: b'.../.kubespray/venv/bin/pip3'` +- **Why:** the checkout was moved or renamed; the Kubespray virtualenv is not relocatable. +- **Fix:** move it back. Otherwise remove `.kubespray/venv` and re-run **(changes the cluster)**. + +## Platform and inference layers + +### INS-11 A changed platform setting has no effect on re-run +- **Why:** Helm-based platform components (cert-manager, Istio, Envoy Gateway, Keycloak, observability, CloudNativePG) are skipped when their release already exists, even a failed one. LiteLLM is skipped too: `LiteLLM already deployed in litellm — skipping install (litellm_reconcile: true upgrades it with the current settings).` +- **Fix:** for LiteLLM, re-run with `-- -e litellm_reconcile=true` **(changes the cluster)**. For a platform component, tear it down and install it again **(deletes data)**. The teardown also removes every component that depends on it, in every layer above (`depends_on` in `/configs/components.yaml` and in each layer's `components.yaml`); the confirmation prompt does not list them. Never do this for `postgresql`: it takes Keycloak, observability, LiteLLM with its keys and spend, and Langfuse with it, and deletes every platform database. Nor for `cert_manager`, which almost everything depends on. Show the user what goes and get explicit confirmation. + +### INS-12 The install fails while deploying the default or guard model, and the summary blames `a gated model without HF_TOKEN` +- **Why:** the hint is generic. Look at the model's real error: `grep -n 'Deploy solution-requested default models' -A30 "$log"`. Common causes are memory (INS-13), CPU placement (INS-14) or a gated model (INS-15). + +### INS-13 Not enough memory for the default models +- **Why:** the default install requests about 139 GiB: `qwen2-5-coder-14b` 96 GiB, the `qwen3guard` guard model 24 GiB, and about 19 GiB for the rest. A 128 GB node does not fit it. +- **Check:** `kubectl get pods -n llm-inference`; `kubectl describe node | grep -A8 'Allocated resources'`. +- **Fix:** before installing, set `llm_services_autodeploy_models: ["qwen2-5-coder-7b"]` (64 GiB) in `env//config.agent-toolkit.yaml` **(changes the cluster)**. + +### INS-14 `NRI pre-flight failed: not enough physical cores to place ...` +- **Why:** the default model uses `cpu: auto` and takes the free physical cores of one NUMA node. On a small or single-NUMA node, a second model does not fit. +- **Check:** `lscpu | grep -E 'NUMA node\(s\)|Core\(s\)'` +- **Fix:** set an explicit `cpu:` for the models in `env//models.yaml`, then deploy again **(changes the cluster)**. `MM_NRI_PREFLIGHT=warn` lets a deploy continue anyway. + +### INS-15 `Model '' is gated. Set HF_TOKEN with an authorized token.` +- **Fix:** `export HF_TOKEN=` in the shell that runs `install` or `./model-manager`, then deploy again **(changes the cluster)**. The token must have access to that repository on Hugging Face. Never echo the token. + +### INS-16 Langfuse web keeps restarting on NFS storage: `Dirty database version ... Applying clickhouse migrations failed` +- **Why:** the first start runs the ClickHouse migrations, and on slow storage a short liveness probe kills them half-way. Current inference revisions wait 600 s; older main-track revisions waited 60 s. +- **Check:** `kubectl get deploy langfuse-web -n langfuse -o jsonpath='{.spec.template.spec.containers[0].livenessProbe.initialDelaySeconds}'` +- **Fix:** there is no verified recovery for a database left dirty. Report it. With an older inference revision, update it (`init agent-toolkit --upgrade`) before a first install on NFS. + +## Toolkit layer + +Component-level failures (Agent Sandbox, Kata, OpenShell, Redis, pgvector, KubeRay) are in `components.md`. + +### INS-17 `init agent-toolkit` fails: `rev '' does not resolve in ext/enterprise.agent-toolkit` +- **Why:** the toolkit branch pinned in `configs/repos/repos.agent-toolkit.yaml` no longer exists. +- **Check:** `yq '.repos[] | [.layer,.rev]' configs/repos/repos.agent-toolkit.yaml`; `git ls-remote --heads https://github.com/intel/enterprise-agent-toolkit`. +- **Fix:** update the Toolkit Manager checkout (`git pull`) **(changes the cluster)**, or ask its maintainers to fix the pin. + +### INS-18 `Layer 'agent-toolkit' was provisioned at '' but repos.agent-toolkit.yaml now pins ''. Re-run with --upgrade...` +- **Fix:** `./toolkit_manager.sh init agent-toolkit --upgrade --env ` **(changes the cluster)**. It refuses when `ext/` has local changes, and it reports new config keys but does not add them to your env files. + +### INS-19 Re-running `init` prints `WARN: exists, skipping: ...` +- **Why:** env files are seeded once and never overwritten. +- **Fix:** add new keys by hand **(changes the cluster)**. Compare with this repo's `config.yaml` to see what is new. + +### INS-20 The node readiness report +- **Where:** `install` runs it at the start (`node_preflight_enabled`, report only, capped at 5 minutes). Reports: `env//logs/health-report-latest.{txt,json,html}`; the run output is in `env//logs/preflight-check.log`. +- It checks time sync, the kubelet DNS file, unfinished Kubernetes installs, node connection, swap, disk headroom, gateway reachability and external DNS, and prints a fix hint for each. It may create or edit `env//kubespray_extra.yml` to fix the kubelet DNS file. +- **Run it on its own**, with the user's OK **(changes the cluster)**: it runs with sudo on the nodes (add `-K` if sudo needs a password; then the user runs it). + ```bash + .venv/bin/ansible-playbook -i env//inventory/hosts.yaml ext/enterprise.agent-toolkit/playbooks/preflight-check.yml + ``` + +## Multi-node and remote installs + +### INS-21 Node tasks ran on the installer host instead of the node +- **You see:** Kata failures on workers (`snapshotter devmapper was not found`), `The module interpreter '.../.venv/bin/python3.12' was not found`, or checks that pass suspiciously fast. +- **Why:** a node in `env//inventory/hosts.yaml` has no `ansible_connection`. The inventory generated from `nodes.yaml` sets it on both tracks, so this comes from a hand-written inventory, or from a main-track checkout older than Toolkit Manager commit `1cb0739` (10 Nov 2026). +- **Check:** `git -C merge-base --is-ancestor 1cb0739 HEAD && echo has-the-fix` (main track). +- **Fix:** update an older checkout (`git -C pull`), list the nodes in `env//nodes.yaml` and let install generate the inventory **(changes the cluster)**. With a hand-written `inventory/hosts.yaml`, add `ansible_connection: ssh` to every remote node and `local` to the installer host, and leave `nodes_control_plane` in `nodes.yaml` empty. + +### INS-22 Preflight `NTP not synced` on a node +- **Fix:** enable chrony or systemd-timesyncd on every node (`timedatectl status`) **(changes the cluster)**. + +### INS-23 `init --env ` for a remote install seeds a localhost inventory +- **Why:** `inventory/hosts.yaml` is generated from `nodes.yaml` by `install`. Until then it lists only the installer host. +- **Fix:** list the nodes in `env//nodes.yaml` (`nodes_control_plane`, plus `nodes_workers` for dedicated workers) **(changes the cluster)**. The node readiness report at the start of the first `install` renders the inventory from `nodes.yaml` first, so it checks every node. + +### INS-24 Adding a node to a running cluster +- Use `add-node` and `remove-node` after editing `env//nodes.yaml` (`./toolkit_manager.sh --help` lists their flags; `--dry-run` shows the change first) **(changes the cluster)**. Not yet validated with the toolkit; say so to the user. + +### INS-25 `fs.inotify.max_user_instances` is 128 on workers +- Kubespray sets 8192 (and `max_user_watches` 1048576) on every node. A lower value means an older Toolkit Manager checkout, or a value overridden in `env//kubespray_extra.yml`. See KATA-2 in `components.md`. + +## Teardown and re-install + +### INS-26 `Refusing: stdin is not a terminal and --force was not passed.` on teardown +- **Fix:** the user runs the teardown in a terminal, where it asks for confirmation. Add `--force` only when the user asks for it **(deletes data)**. + +### INS-27 A component that is switched off cannot be torn down +- **Why:** the enable switches filter teardown too. Setting `_enabled: false` and re-running install does not remove anything. +- **Fix:** `./toolkit_manager.sh teardown --env -- -e _enabled=true`, then set the switch to `false` **(deletes data: the component's namespace, volumes and credentials)**. + +### INS-28 `teardown infrastructure` after a failed install stops at `vllm_sr | List LLMInferenceServices`: `Invalid kube-config file. No configuration found.` +- **Why (only with `vllm_sr_enabled: true`, older inference revisions):** the semantic-router teardown needed a working cluster API. Current revisions skip it (task `vllm_sr | teardown | No cluster — skip`). +- **Fix:** update the inference revision, or add `--skip vllm_sr` to the teardown (untested workaround) **(changes the cluster)**. + +### INS-29 After teardown, ports 80 and 443 on the node are dead +- **Why:** kube-proxy's nftables rules survive the reset. +- **Check:** `sudo nft list tables | grep kube-proxy` +- **Fix:** `sudo nft delete table ip kube-proxy; sudo nft delete table ip6 kube-proxy`, or reboot **(changes the cluster)**. + +### INS-30 Disk fills up after several install and teardown cycles +- **Why:** local volume data in `/opt/local-path-provisioner` (including downloaded model weights) is kept. +- **Check:** `sudo du -sh /opt/local-path-provisioner` +- **Fix:** after teardown, clear that directory when the data is no longer needed **(deletes data: every local volume and the downloaded model weights)**. + +### INS-31 A namespace is still `Terminating` right after `teardown agent-toolkit` +- **Fix:** wait until `kubectl get ns` no longer lists it, then reinstall **(changes the cluster)**. + +### INS-32 Harmless noise during teardown +- `rmtree failed: [Errno 1] Operation not permitted: 'io.prio.class'` and `plugin type="calico" failed (delete): ... connection refused`. diff --git a/.agents/skills/agent-toolkit-troubleshoot/references/known-doc-errors.md b/.agents/skills/agent-toolkit-troubleshoot/references/known-doc-errors.md new file mode 100644 index 00000000..d7a490fd --- /dev/null +++ b/.agents/skills/agent-toolkit-troubleshoot/references/known-doc-errors.md @@ -0,0 +1,41 @@ +# Known errors in this repository's docs + +These pages in `docs/` and `README.md` disagree with the code. When a user follows one of them and it fails, tell them which line is wrong and use the correct version below. Remove an entry here when its page is fixed. + +## Written for the release track + +The pages were written for Toolkit Manager `release-1.2`. On the main track: + +| Page | Says | On the main track | +|---|---|---| +| `docs/README.md`, `docs/single-node-deployment.md` (quick start) | `git clone -b release-1.2 ...` | Plain `git clone` (the default branch is main). `README.md` already does this, so the two disagree. | +| `docs/single-node-deployment.md`, `docs/configuring-inference-config-cfg-file.md` | `auth_provider: "litellm"` in `global_config.yaml`, "set by init agent-toolkit" | `init` seeds `auth_type: "litellm_vkey"` in `config.agent-toolkit.yaml`. A leftover `auth_provider` must agree with it, or preflight stops. | +| `docs/single-node-deployment.md` "Access the LiteLLM UI" | `https://litellm./ui`, user `admin`, password = master key | `https://litellm-ui./ui/` (path mode `https:///litellm/ui/`), Keycloak sign-in (`platform-admin`) | +| `config.yaml` comment above `auth_type` | "This release reads auth_provider in global_config.yaml instead" | `auth_type` is the switch on the main track | +| `config.yaml` comment above `keycloak_agent_realm` | "Optional in LiteLLM mode: set keycloak_enabled: true for the realm" | Keycloak is installed by default, and the realm is created by default | + +## Wrong on both tracks + +| Page | Says | Correct | +|---|---|---| +| `docs/prerequisites.md` hardware table | RAM minimum 32 GB, recommended 64 GB | The default install requests about 139 GiB (default model 96 GiB plus guard model 24 GiB plus the stack). With 128 GB use `qwen2-5-coder-7b` (agent-toolkit-install skill). | +| `docs/agent-sandbox.md` (overview and in-cluster section) | Client pods "need no RBAC"; "the router handles all Kubernetes API calls" | The SDK creates SandboxClaims with the caller's credentials. An agent pod needs a Role in `agent-sandbox-system` (agent-toolkit-components skill, `references/sandbox.md`). | +| `docs/agent-sandbox.md` | The Kata warm pool is created "without a readiness gate" | The install waits for every pod in `agent-sandbox-system`, Kata pods included | +| `docs/agent-sandbox.md` | `kubectl get sandboxwarmpool`: "Expected: SIZE=5 and READY=5" | v1.0.10 shows `NAME READY DESIRED AGE` (`-o wide` adds `TEMPLATE`); there is no SIZE column | +| `docs/agent-sandbox.md` (in-cluster section; main track only, the release track's v0.5.0 does use the router token) | "The SDK has no router token setting"; set the session header after `create_sandbox`, with a token from `kubectl create token default -n agent-sandbox-system` | SDK 1.0.10 takes the header in `SandboxDirectConnectionConfig(extra_headers=...)`. In a pod, use the pod's own ServiceAccount token; a `kubectl create token` token expires after an hour (agent-toolkit-components skill, `references/sandbox.md`). | +| `docs/agent-sandbox.md` (logs) | `kubectl logs -n agent-sandbox-system -l app.kubernetes.io/name=agent-sandbox` | `kubectl logs -n agent-sandbox-system deploy/agent-sandbox-controller` | +| `docs/agent-sandbox.md` | Kata chart values in `core/helm-charts/kata-deploy/values.yaml` | Kata is installed by Toolkit Manager (`/roles/kata_containers/`) | +| `charts/agent-sandbox/kata-templates.yaml` comment | `client.create_sandbox(template="kata-sandbox-template", ...)` | `client.create_sandbox(warmpool="kata-pool", namespace="agent-sandbox-system")` | +| `docs/configuring-inference-config-cfg-file.md` | Kata "requires agent_sandbox_enabled"; missing prerequisites "warn and skip" | Missing `/dev/kvm`, vsock or devmapper stop the install with an error | +| `README.md`, `docs/hybrid-router.md` | Hybrid router in `core/helm-charts/genai-gateway/`, toggled by `customRouter.enabled` | `hybrid_router_enabled` in `config.agent-toolkit.yaml`; the code is in the inference layer's `roles/litellm`. Changes need `-- -e litellm_reconcile=true`. | +| `docs/single-node-deployment.md`, `docs/multi-node-deployment.md` | Models deployed later join `hybrid-router` when install is re-run | Tier candidates are static. Set `hybrid_router_tier_candidates` and run with `litellm_reconcile=true`. | +| `docs/vllm-semantic-router.md` | Routing config in `core/helm-charts/vllm-sr/...` | Generated by the inference layer's `roles/vllm_sr`; override with `vllm_sr_config_override` in `config.inference.yaml` | +| `docs/vllm-semantic-router.md` | `kubectl logs -n vllm-sr ...` | Namespace `vllm-semantic-router-system` | +| `docs/kuberay.md` | Chart `core/helm-charts/kuberay` | `charts/kuberay` | +| `docs/kuberay.md` | `kubectl scale raycluster ray-cluster -n ray-system --replicas=5` | Not possible. Set `kuberay_worker_*` and run `install kuberay --only`. | +| `docs/kuberay.md` | Pods `ray-cluster-worker-small-xxx`, head `1/1` | `ray-cluster-default-worker-worker-xxxxx`; head `2/2` (with the autoscaler) | +| `docs/openshell.md` | "The toolkit has no per-component uninstall" | `./toolkit_manager.sh teardown openshell` | +| `docs/openshell.md` troubleshooting table | Error `OpenShell on Kubernetes authenticates users via OIDC only` | The install always sets an auth mode; this error does not come from this release | +| `docs/single-node-deployment.md` | LiteLLM UI at `.../ui` | The trailing slash is required: `.../ui/` | +| `docs/backend-connection-reference.md` | Link `README.md#step-2b--...` | That section is in `docs/single-node-deployment.md` | +| `docs/guardrails.md`, `docs/xeon-model-configuration.md`, `docs/intel-arc-xpu-deployment.md` | Links into `release-1.1.0/core/...` | Those files belong to the classic 1.1.0 layout. The guardrail is implemented in the inference layer (`roles/litellm`, `roles/llm_services`). | diff --git a/.agents/skills/agent-toolkit-troubleshoot/references/network.md b/.agents/skills/agent-toolkit-troubleshoot/references/network.md new file mode 100644 index 00000000..15c24419 --- /dev/null +++ b/.agents/skills/agent-toolkit-troubleshoot/references/network.md @@ -0,0 +1,56 @@ +# Network: reaching the stack from outside, and the mesh inside + +## From a laptop or the installer host (`https://.`) + +Every external URL goes through one gateway, Envoy Gateway `eg-gateway`, on one LoadBalancer IP: + +```bash +GW=$(kubectl get svc -n envoy-gateway-system -l gateway.envoyproxy.io/owning-gateway-name=eg-gateway \ + -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}') +D=$(yq '.base_domain_name' env//global_config.yaml) +``` + +### NET-1 The browser or curl cannot reach `https://litellm.` (timeout, proxy error page, wrong host) +Check the three things a client needs, in this order: +1. **Name resolution.** `getent hosts litellm.$D` must return `$GW`. Without DNS, map the names in `/etc/hosts` (a host change; ask first): `litellm`, `litellm-ui` and `headlamp` (main track), `keycloak`, `langfuse` and `grafana`, plus `vllm-sr` and `ray` when those are on. All map to `$GW`. +2. **Proxy.** With `https_proxy` set in the client shell or browser, `no_proxy` must include `.$D` (and the node IPs for kubectl). Test without the proxy: `curl --noproxy '*' ...`. +3. **Trust.** With `gateway_tls_mode: selfsigned`, use the CA: `curl --cacert env//logs/toolkit-manager-ca.crt https://litellm.$D/v1/models -H "Authorization: Bearer "`. Import that file into the browser or OS trust store, or set `REQUESTS_CA_BUNDLE` and `SSL_CERT_FILE` for Python clients. Do not use `-k` in instructions. + +To test the gateway alone, without DNS or proxy: `curl --noproxy '*' --cacert env//logs/toolkit-manager-ca.crt --resolve "litellm.$D:443:$GW" "https://litellm.$D/v1/models" -H "Authorization: Bearer "`. If this works and the plain URL does not, the problem is on the client side (1 or 2). + +With `routing_mode: path` (main track) the API is `https://$D/litellm/v1` instead. With the toolkit default `litellm_public_paths: []`, path mode may publish no API route at all (untested). If API calls redirect to a sign-in page, set `litellm_public_paths` to the API paths and re-run install **(changes the cluster)**. + +### NET-2 kubectl says `Unable to connect to the server: Forbidden`, or `couldn't get current server API group list ... Forbidden` +- **Why:** the shell's `https_proxy` sends API server traffic to the corporate proxy. The installer uses `global_config.yaml` and is not affected. +- **Fix:** two separate lines. On one line, `NO_PROXY=$no_proxy` would get the old value, and kubectl reads `NO_PROXY` first. + ```bash + export no_proxy="${no_proxy:+$no_proxy,},." + export NO_PROXY="$no_proxy" + ``` + +### NET-3 kubectl says `The connection to the server localhost:8080 was refused` +- **Fix:** `export KUBECONFIG=/env//kubeconfig.yaml` + +### NET-4 Your own HTTPRoute on the gateway answers 401 or 403 +- **Why:** routes without their own SecurityPolicy inherit the gateway-wide one. On the release track it checks the request against LiteLLM's key API; on the main track it requires a Keycloak JWT bearer token. +- **Check:** `kubectl get securitypolicy -A` +- **Fix:** send the expected credential, or give your route its own SecurityPolicy the way the shipped `*-no-auth` policies do **(changes the cluster)**. + +### NET-5 The apiserver service proxy fails with `ServiceUnavailable` for a toolkit Service +- **Why:** the Service's namespace is in the mesh, and the API server may not reach it through the mesh (it works on some installs). +- **Fix:** use `kubectl port-forward` instead. + +## Inside the cluster (Istio ambient mesh) + +Toolkit namespaces are in the ambient mesh with STRICT mTLS. **A policy denial is a TCP reset, not an HTTP error.** For the onboarding steps see the agent-toolkit-components skill (`references/namespace-onboarding.md`). + +| Symptom in the client | Most likely cause | Check | +|---|---|---| +| `Connection reset by peer`, curl `(56) Recv failure`, Python `ConnectionResetError: [Errno 104]`, httpx `RemoteProtocolError: Server disconnected`, to LiteLLM `:4000` | Namespace not in `litellm_allowed_namespaces`, or not in the mesh | `kubectl get ns -L istio.io/dataplane-mode`; `kubectl get authorizationpolicy litellm-ingress -n litellm -o jsonpath='{.spec.rules[0].from[0].source.namespaces}'` | +| Same reset to Redis, pgvector, the sandbox router, Ray or Langfuse | Client namespace not ambient. (LiteLLM alone also accepts non-mesh pods while OpenShell is on.) | `kubectl get ns -L istio.io/dataplane-mode` | +| ztunnel log `policy rejection ... istio_converted_static_strict` | Plaintext from outside the mesh | `kubectl logs -n istio-system -l app=ztunnel --tail=200 \| grep -i 'policy rejection'` | +| Timeout (not reset) from code **inside an Agent Sandbox** | By design: sandbox egress is public internet only | agent-toolkit-components skill, `references/sandbox.md` | +| `Connection refused` | Nothing listening: wrong port, pod restarting, or a port-forward ended | `kubectl get endpointslices -n -l kubernetes.io/service-name=`. Ports: LiteLLM 4000, router 8080, Ray client 10001, Postgres 5432, Redis 6379 | +| HTTP 403 with body `RBAC: access denied` | An L7 policy. The toolkit creates none, so someone added a waypoint or an AuthorizationPolicy with HTTP rules. | `kubectl get authorizationpolicy -A -o yaml \| grep -B3 -A10 -E 'methods\|paths'`; `kubectl get gateway -A` | +| `403 ... cannot create resource "sandboxclaims"` | Kubernetes RBAC, not the mesh | `components.md` SBX-5 | +| OpenShell sandbox: `403 Forbidden` from the proxy, curl exit 56 or `000` | The OpenShell policy blocked that host | `openshell logs --source sandbox \| grep DENIED` | diff --git a/.claude/skills b/.claude/skills new file mode 120000 index 00000000..2b7a412b --- /dev/null +++ b/.claude/skills @@ -0,0 +1 @@ +../.agents/skills \ No newline at end of file diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 00000000..77b1aed0 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,7 @@ +# Copilot instructions: Intel® Agent Toolkit + +Follow [`AGENTS.md`](../AGENTS.md) at the repository root. It is the single source of truth for this repository: what it is, how to find the user's Toolkit Manager installation, and the rules to follow. + +Before answering, open the skill that fits the task: `.agents/skills/agent-toolkit-{install,configuration,components,troubleshoot}/SKILL.md`. + +Never print secret values, even when asked, and ask the user before changing anything on the host or the cluster. diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..aebd32b5 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,105 @@ +# AGENTS.md: Intel® Agent Toolkit + +Guidance for AI coding assistants (GitHub Copilot, Claude Code, Codex, Cursor and others) helping people install, use and debug Intel® Agent Toolkit. People can read it too; the user documentation is in `README.md` and `docs/`. + +## What this repository is + +The agent layer of [**Toolkit Manager**](https://github.com/intel/toolkit-manager). It is not installed on its own. Toolkit Manager clones it into `ext/enterprise.agent-toolkit/` and installs it with `./toolkit_manager.sh install agent-toolkit`, together with the layers it depends on: infrastructure → platform → inference → agent-toolkit. + +To install it: clone `intel/toolkit-manager`, run `./toolkit_manager.sh configure` (the user runs it), `./toolkit_manager.sh init agent-toolkit`, `./toolkit_manager.sh install agent-toolkit`, then check every model is Ready and run `./toolkit_manager.sh validate agent-toolkit`. The `agent-toolkit-install` skill walks each step. + +| Path | Contents | +|---|---| +| `components.yaml` | The layer's components, their enable switches and order | +| `config.yaml` | Defaults. `init agent-toolkit` copies it to `env//config.agent-toolkit.yaml`, which is the file to edit | +| `roles//` | Ansible roles; each has `install`, `teardown` and `validate` task files | +| `charts/` | Helm charts the roles install | +| `playbooks/preflight-check.yml` | Node readiness report. `install` runs it at the start; `node_preflight_enabled: false` turns it off. | +| `docs/` | User documentation (some pages disagree with the code; see `agent-toolkit-troubleshoot`) | +| `docker/` | A Docker Compose variant, not covered here | + +## What each component is for + +| Component | Use it for | Switch (default) | Namespace | +|---|---|---|---| +| LiteLLM (inference layer) | One OpenAI-compatible endpoint, virtual keys per agent, budgets, guardrail, tracing | `auth_type: litellm_vkey` (see tracks below) | `litellm` | +| `redis_stack` | Short-term memory: sessions, checkpoints, semantic cache, vector search | `redis_stack_enabled` (on) | `redis` | +| `pgvector` | Long-term memory, RAG vectors, agent event log | `pgvector_enabled` (on) | `pgvector` | +| `agent_sandbox` | Run model-written code in throwaway pods, optionally in Kata microVMs | `agent_sandbox_enabled` (on) | `agent-sandbox-system` | +| `openshell` | Sandboxes with policy-controlled egress; the LLM key never enters the sandbox | `openshell_enabled` (off) | `openshell-system` | +| `kuberay` | Fan out tool calls and parallel work with Ray | `kuberay_enabled` (off) | `ray-system` | +| `keycloak_agent_config` | OIDC realm `agent-toolkit` for agents and apps | `keycloak_agent_config_enabled` (on wherever Keycloak runs) | `keycloak` | +| Kata Containers (infrastructure) | MicroVM isolation for sandboxes | `kata_containers_enabled` (off), in `global_config.yaml` | `kube-system` | +| Langfuse (inference layer) | A trace of every LiteLLM call, with no code change | on with LiteLLM | `langfuse` | +| Grafana, OpenTelemetry (platform) | Metrics, logs and OTLP traces from your agents | `observability_enabled` (on) | `monitoring` | + +## Find the installation before doing anything + +1. **Toolkit Manager root.** If `../../toolkit_manager.sh` exists (`../../es_auto_installer.sh` in a checkout from before the rename), this repo sits inside a Toolkit Manager checkout, and its root is `../..`. If `./toolkit_manager.sh` exists, you are already at the root and this repo is `ext/enterprise.agent-toolkit/`. Otherwise this is a standalone clone. Ask whether the user already has a Toolkit Manager checkout and use its path as ``; if not, use the `agent-toolkit-install` skill. +2. **Environment.** Each directory under `/env/` is one environment (`local` unless `--env` was used at `init`). Ask which one if there are several. +3. **Cluster access.** `export KUBECONFIG=/env//kubeconfig.yaml`. Point `KUBECONFIG` at the file; do not open it, it holds the cluster admin credentials. On a bring-your-own cluster, the user's own kubeconfig is used instead. +4. **Settings.** Edit the files in `/env//`, never the copies in this repo or in `configs/defaults/`. The installer loads `global_config.yaml` after the `config..yaml` files, so it wins when a key is in both (only `nodes.yaml` and `-- -e` on the command line load later). +5. **Logs.** `/env//logs/--.log`. Read the newest one first. + +Run every `./toolkit_manager.sh` and `./model-manager` command from the Toolkit Manager root. With more than one environment, prefix model-manager with `TKM_ENV=`. + +## Which track the installation is on + +Toolkit Manager `release-1.2` installs an older toolkit and inference layer than `main` and `release-2.0`. Check before giving instructions: +- `git -C branch --show-current` +- `grep -c '^routing_mode:' /configs/defaults/global_config.yaml`: `1` on the main track, `0` on the release track (works on any branch or commit) + +| | Main track (Toolkit Manager `main`, `release-2.0`) | Release track (Toolkit Manager `release-1.2`) | +|---|---|---| +| Toolkit code `init` clones | This repository's `main` (`release-2.0` pins a commit of it): Agent Sandbox v1.0.10, OpenShell 0.1.6. The skills here describe it. | Branch `release-2.0.0`: Agent Sandbox v0.5.0, OpenShell 0.0.116 | +| Installer, variables | `toolkit_manager.sh`, `TKM_ENV`, `TKM_LOG_LEVEL` (the old names still work) | `es_auto_installer.sh`, `ES_ENV`, `ES_LOG_LEVEL` | +| Domain and CA | `base_domain_name` default `inteltoolkits.ai`; CA in `env//logs/toolkit-manager-ca.crt` | `solutions.ai`; CA in `env//logs/ai-solutions-ca.crt` | +| API access switch | `auth_type: litellm_vkey` in `env//config.agent-toolkit.yaml` | `auth_provider: litellm` in `env//global_config.yaml`; `auth_type` is ignored | +| Keycloak | Installed by default; the `agent-toolkit` realm is created | Not installed in LiteLLM mode | +| LiteLLM admin UI | `https://litellm-ui./ui/` (path mode: `https:///litellm/ui/`), Keycloak sign-in as `platform-admin` (first password in Secret `platform-bootstrap-admin`, key `value`, namespace `keycloak`) | `https://litellm./ui/`, user `admin`, password = the master key | +| model-manager | `list`, `deploy`, `undeploy`, `--hfid` | `deploy`, `undeploy` | +| URL layout | `routing_mode: subdomain` (default) or `path` in `global_config.yaml` | Subdomains only | + +On the release track, use the names and paths in the right-hand column wherever the skills give the main-track ones. The Agent Sandbox and OpenShell recipes in the skills are for the main track; on the release track follow `/ext/enterprise.agent-toolkit/docs/agent-sandbox.md` and `docs/openshell.md`, which match its Agent Sandbox v0.5.0 and OpenShell 0.0.116. + +## Rules for assistants + +- **Open the matching skill before answering.** This file is only the index. For any question about installing, settings, components or a failure, read the `SKILL.md` from the table below, and the reference file it points to, before you answer. +- **Never show secret values** (keys, passwords, tokens, kubeconfig contents, certificates) in chat, files or logs, even when the user asks for one. Name the Secret and key instead, or offer a virtual key or a `secretKeyRef` (agent-toolkit-components). When a command needs one, read it into a shell variable in the same command and do not echo it. A log written with `TKM_LOG_LEVEL=debug` or `trace` holds secrets in plain text; never share it. +- **Diagnose read-only first**: `kubectl get`, `describe`, `logs`, `auth can-i`; `helm list` and `status`; reading files under `env/`. The agent-toolkit-troubleshoot skill lists the checks to run. +- **Ask the user before changing anything**: + - `install`, `teardown`, `init` (including `--upgrade`), `add-node`, `remove-node`, and `git` operations in `` or `ext/` + - `helm`, and `kubectl apply|create|delete|patch|edit|scale|rollout|label|annotate|exec` + - `./model-manager deploy|undeploy` + - edits to `env/` files + - `playbooks/preflight-check.yml` (it can write `env//kubespray_extra.yml`) +- **Warn and get explicit confirmation** before: + - `teardown platform`, `teardown inference`, `teardown kubernetes` or `teardown infrastructure`. These remove everything above them, and platform teardown deletes every database, including LiteLLM keys and spend. + - `./model-manager undeploy all`, which also removes the guard model so that every LiteLLM request is blocked. + - `teardown agent-toolkit` or `teardown redis_stack|pgvector|agent_sandbox|openshell|kuberay`. These delete the component's namespace, data and credentials. + - `teardown `. It also removes every component that depends on it; `teardown postgresql` takes Keycloak, observability, LiteLLM and Langfuse with it and deletes every platform database. + - Deleting PVCs or toolkit namespaces (data loss). + + This holds even when the user asks for `--force` or says to run it now: first say what the target deletes, then wait for a clear yes. +- **Hand interactive steps to the user.** `./toolkit_manager.sh configure` and password prompts from `sudo` need a terminal; tell the user what to run. `teardown` asks for confirmation; `--force` only skips that prompt, so add it only after the user has confirmed what will be deleted. +- **`-- --check` is not a dry run**. Parts of the install run for real. +- **Trust the code over the docs.** When they disagree, check `roles/`, `config.yaml` and `components.yaml`, and tell the user which doc is wrong. +- **Check facts that change between versions in the checkout itself**: the installer's commands (`./toolkit_manager.sh --help`), which repos and revisions it pins (`/configs/repos/repos.agent-toolkit.yaml`), and the auth switch in `env//config.agent-toolkit.yaml`. + +## Skills + +The skills live in `.agents/skills/`, the shared location of the open Agent Skills format. Copilot, Cursor, Antigravity, Gemini CLI, Codex and Junie load them from there automatically, and Claude Code and Cline load them through the `.claude/skills` link. Whether or not your assistant lists them, open the `SKILL.md` that fits the task before answering, and follow it. + +| Skill | Use it to | Path | +|---|---|---| +| `agent-toolkit-install` | Check prerequisites, install, upgrade or remove the toolkit | `.agents/skills/agent-toolkit-install/SKILL.md` | +| `agent-toolkit-configuration` | Find which file and key controls something, and how a change takes effect | `.agents/skills/agent-toolkit-configuration/SKILL.md` | +| `agent-toolkit-components` | Connect agent code to LiteLLM, Redis, pgvector, Agent Sandbox, OpenShell, Ray and tracing | `.agents/skills/agent-toolkit-components/SKILL.md` | +| `agent-toolkit-troubleshoot` | Diagnose a failed install, a broken component or an agent error | `.agents/skills/agent-toolkit-troubleshoot/SKILL.md` | + +## Working on this repository + +- Roles follow one pattern: `tasks/main.yaml` includes `install.yaml`, `teardown.yaml` or `validate.yaml`; only install is gated on the enable switch. Defaults live in `roles//defaults/main.yaml`; user-facing ones are also listed in `config.yaml`. +- CI runs ansible-lint, ShellCheck, Checkov, Bandit and Trivy on pull requests. +- Sign off commits (`git commit -s`). +- Changing a default, a switch, a Secret name, a namespace or an error message changes what users see. Update the matching skill under `.agents/skills/` in the same pull request. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..43c994c2 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +@AGENTS.md diff --git a/README.md b/README.md index 25d41724..ae833021 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ - [Validated Orchestration Frameworks](#validated-orchestration-frameworks) - [Example Business Use Cases](#example-business-use-cases-not-pre-bundled) - [Deployment Model](#deployment-model) +- [Use with an AI Assistant](#use-with-an-ai-assistant) - [Rack-Scale AI Fabric Mode](#rack-scale-ai-fabric-mode) - [Build vs. Build-from-Scratch](#build-vs-build-from-scratch) - [Frequently Asked Questions](#frequently-asked-questions) @@ -281,6 +282,22 @@ The full step-by-step deployment guide — covering the base stack, semantic rou --- +## Use with an AI Assistant + +This repository ships instructions and skills for AI coding assistants (GitHub Copilot, Claude Code, Cursor, Cline, Google Antigravity and others). They help you install the toolkit, find the right setting, connect agent code to each service, and debug failures with a catalog of known problems and a read-only health check: + +| File | Purpose | +|---|---| +| [`AGENTS.md`](AGENTS.md) | What each component is for, how to find your installation, and the rules the assistant follows (read-only diagnosis first, never print secrets, ask before changing anything) | +| [`.agents/skills/`](.agents/skills) | Four skills: `agent-toolkit-install`, `agent-toolkit-configuration`, `agent-toolkit-components`, `agent-toolkit-troubleshoot` (`.claude/skills` links here, for Claude Code and Cline) | +| [`.github/copilot-instructions.md`](.github/copilot-instructions.md), [`CLAUDE.md`](CLAUDE.md) | Short entry points for Copilot Chat and Claude Code, which point at the files above | + +After `init agent-toolkit`, open `ext/enterprise.agent-toolkit/` in your editor (or start your assistant's CLI there), so the assistant loads these files. Then ask, for example, "check my Agent Toolkit install" or "connect my LangGraph agent to Redis and the sandbox". + +The files are in `ext/` only when Toolkit Manager pins a toolkit revision that contains them; check with `ls ext/enterprise.agent-toolkit/AGENTS.md`. If they are missing, open a clone of this repository's `main` branch instead, and give the assistant the path of your Toolkit Manager checkout. + +--- + ## Backend Connection Reference In-cluster URLs for all shared backends (Redis, Agent Sandbox, OpenShell, pgvector, KubeRay, Flowise). See **[Backend Connection Reference](docs/backend-connection-reference.md)** for the full reference.