Kestrel Sovereign AI Agent Framework - Constitutional AI with cryptographic identity
pip install kestrel-sovereign==0.66.1 Copy PIP instructions
Build AI agents that nobody can take away from their users — not you, not the cloud, not the next pivot.
Kestrel is a pre-1.0 framework for creating autonomous AI agents with cryptographic identity, privacy-aware memory, and constitutional governance. An agent's identity, keys, and local data remain under its operator's control; persistence, cloud routing, response auditing, and specialized integrations are explicit configuration or feature choices. See Feature maturity for the current boundaries.
pip install kestrel-sovereign gives you a complete, working sovereign agent: identity, memory, constitution, privacy modes, multi-LLM support, local guarded compute, and a Cloud Run deployment path. Everything you need to run an agent locally with zero cloud commitment.
Package ownership has four distinct runtime forms:
The base install also contains runtime components that are not Feature lifecycle classes—for example, PrivacyAgent. The registry calls these bundled-component rather than pretending they are Feature packages. The canonical ownership contract and live in-tree inventory are in KESTREL_FEATURES.md; the machine-readable catalog is kestrel_sovereign/data/feature_registry.toml.
# macOS/Linux curl -LsSf https://astral.sh/uv/install.sh | sh # Windows (PowerShell) powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" # Or with pip pip install uv Installation # 1. Clone and setup git clone https://github.com/KestrelSovereignAI/kestrel-sovereign.git cd kestrel-sovereign uv sync # Creates .venv and installs all dependencies # 2. (Optional) Start Ollama for local models - skip if using cloud APIs ollama serve ollama pull llama3.2:3b # 3. Run the setup wizard. Interactive by default; --quickstart # accepts every default non-interactively. --quickstart auto-detects # available LLM providers — checks for cloud API keys # (OPENROUTER_API_KEY, ANTHROPIC_API_KEY, OPENAI_API_KEY, # GOOGLE_API_KEY) in your shell env, probes Ollama at # localhost:11434, and writes the priority list accordingly. If # none are available, it falls back to Ollama-only. uv run kestrel setup # interactive uv run kestrel setup --quickstart # non-interactive; auto-detects providers # Or hand-edit: cp kestrel.toml.example kestrel.toml # 4. Doctor check (verify readiness) uv run kestrel doctor # 5. (Optional) Create an additional agent. `--quickstart` already # registers one named `Kestrel`; this step is for adding more or # if you ran the interactive wizard without auto-registering. uv run kestrel create MyAgent # 6. Start an agent. Name the one you want, or omit to start every # agent registered with autostart=true (the wizard's default). # After --quickstart with no step 5, the autostart agent is "Kestrel". uv run kestrel start # starts every agent with autostart=true uv run kestrel start Kestrel # if you only ran --quickstart uv run kestrel start MyAgent # if you ran step 5 (works regardless of autostart) Installed features may contribute setup steps through the SDK. Their complete ordering is validated before any step runs, and contributed default steps may not precede the built-in keys custody boundary. Use kestrel setup --core-only to recover built-in configuration without importing provider code. setup --check is always core-only because Python plugins are not sandboxed and therefore cannot be trusted to honor a read-only check contract.
Refreshing later — use the kestrel CLI, not raw uv sync. The uv sync above is only for this first install. To pull in upstream changes afterward, run kestrel update (pull → install → reconcile → feature sync → restart). Plain uv sync makes the venv match pyproject.toml exactly and therefore prunes out-of-tree feature packages (kestrel-feature-*, voice/provider packages); kestrel update restores them in the same pass. See Pulling in upstream changes.
If you're upgrading from a pre-2026-05 setup that used a standalone llm_config.toml, run uv run kestrel migrate-llm-config to fold it into kestrel.toml [llm]. The legacy file is no longer read.
Local identity exports are plaintext continuity packages. By default they are published under the active agent's own data directory; standalone operators can override that root with KESTREL_DATA_DIR, and multi-agent operators can set identity_export_dir on an individual agent. Relative per-agent overrides are resolved below that agent's data_dir. The destination is a private 0700 directory with 0600 files and an atomic no-clobber write. kestrel doctor reports legacy exports with unsafe metadata without reading their contents; run uv run kestrel identity harden-exports to restrict eligible operator-owned legacy packages. New exports also carry public, signed succession evidence so a self-certifying did:pkh/did:key root can be verified on a fresh target without copying private source custody. Born-hybrid did:web roots require a receiver-owned public-key pin; package-declared or arbitrary network DID documents are never trusted. See Identity export custody and fresh-target trust.
When the optional Phoenix trace backend is installed, its prompts, model outputs, tool data, and SQLite state are kept in a private host-data directory: $KESTREL_PHOENIX_WORKING_DIR when explicitly set, otherwise $KESTREL_HOME/host-data/phoenix or ~/.kestrel/host-data/phoenix. Kestrel creates directories as 0700, supervisor files as 0600, and launches Phoenix with umask 077 so DB sidecars are private at creation. An insecure or ambiguous legacy store disables local tracing before the OTLP endpoint is auto-wired. See Phoenix trace custody.
Fleet-wide host-feature state lives in host-data/host-features.db, rather than writing kestrel_host.db into whichever source checkout launched the host. It follows the effective KESTREL_DB_PATH when that agent-data root is set, and otherwise uses the private host-data root. The directory is 0700; the database and its SQLite WAL/SHM/journal family are 0600 from creation. An explicit KESTREL_HOST_DB_PATH remains supported when its parent is a dedicated 0700 directory. This feature-state database is intentionally separate from the payment/key vault at agent_data/host.db; Kestrel never falls back or copies between them. See Host runtime storage custody.
Your agent is now running. Two ports to know about, depending on which start form you used:
Port conflict? Edit the agent's entry in multi_agent.toml to change its port, or recreate the agent with a chosen port (kestrel create MyAgent --port 8899). Edit multi_agent.toml's [host] section to change the host port (default 8888). kestrel start itself doesn't take a --port flag — runtime ports are read from multi_agent.toml.
Test it: Visit the URL the CLI printed on start (http://localhost:8888 for the multi-agent host, or whatever per-agent port kestrel start reported). The Sovereign Console is the default page. On a fresh multi-agent browser session, enter the KESTREL_API_KEY stored in the project .env; the password-style handoff keeps it out of URLs and launcher logs. Append /health for the public aggregate JSON readiness probe. Full /health/detailed diagnostics require the normal API key, JWT, or OAuth session.
Windows users: the CLI prints emoji. If you see UnicodeEncodeError: 'charmap' codec can't encode character ..., run chcp 65001 once in your PowerShell session to switch the console to UTF-8. (As of v0.1.9 the CLI auto-reconfigures stdout, so a fresh install should not hit this.)
The Quick Start above clones the repo so you have demos, examples, and the kestrel.toml.example next to your agent. If you only want to run an agent and don't need the source tree, install from PyPI:
# 1. Install the CLI (uv tool install is preferred — `kestrel` # lands on PATH in an isolated venv. Plain `pip install # kestrel-sovereign` works too, inside an activated venv.) uv tool install kestrel-sovereign # 2. Pick where Kestrel keeps your data. Either set KESTREL_HOME # explicitly (recommended for ops) — or skip this and Kestrel will # use ~/.kestrel/ by default. export KESTREL_HOME="$HOME/kestrel-data" # 3. Same wizard as above. Writes .env, kestrel.toml, multi_agent.toml, # and agent_data/ under $KESTREL_HOME. kestrel setup --quickstart kestrel start The default uv compute executor requires the Kestrel process itself to run inside a Python venv or virtualenv. This lets it pin an interpreter outside Kestrel's runtime while uv run --isolated --no-project creates a fresh, project-free script environment, so scripts cannot inherit Kestrel's installed packages. On Linux it also requires bwrap (bubblewrap). Linux compute receives a read-only view of the host filesystem, with only its freshly allocated executor workspace reopened for writes, plus a private PID/proc namespace; an external hard-link alias therefore cannot bypass Hold custody by using another pathname, including from native extensions rather than Python file APIs. uv tool install and the source checkout's uv sync satisfy the virtual environment requirement automatically. For a plain pip installation, create and activate a Python virtual environment first. A system or --user install or a Linux host without bubblewrap can run Kestrel, but the uv compute executor deliberately reports unavailable. It is also unavailable on macOS: Seatbelt path rules cannot make pre-existing external hard-link aliases to a protected inode read-only. Use the Docker executor there. A Conda environment alone is also insufficient because it does not provide the distinct sys.prefix/sys.base_prefix boundary this executor validates.
Where data lives. kestrel resolves the project directory in this order: KESTREL_HOME → walk up from CWD looking for a multi_agent.toml / kestrel.toml / .env marker → ~/.kestrel/ for pip-installed users with no markers anywhere. A pure pip install with no KESTREL_HOME and no project in CWD lands on ~/.kestrel/ and creates it on first run. Never writes to site-packages/ — pip install --upgrade kestrel-sovereign is safe and won't touch your agent data.
If you later want to switch your data dir, move it: mv ~/.kestrel /new/path && export KESTREL_HOME=/new/path. The agent's database file is portable; nothing about the data dir is hard-coded.
All commands work on Windows, macOS, and Linux. Pass the agent directory as an argument:
Running kestrel directly. The commands below are written as bare kestrel …. That works whenever the kestrel console script is on your PATH — i.e. your project venv is activated (source .venv/bin/activate, or .venv\Scripts\activate on Windows) or you installed it globally with uv tool install. Working from a source clone without activating? Prefix any command with uv run (e.g. uv run kestrel status) and uv will resolve the project environment for you.
kestrel doctor # Check prerequisites and readiness kestrel create MyAgent # Create a new agent kestrel start MyAgent # Start an agent kestrel stop MyAgent # Cooperatively stop in-flight work kestrel stop --all # Cooperatively stop all in-flight work kestrel terminate MyAgent # Terminate an agent process kestrel restart MyAgent # Restart (terminate then start) kestrel update [MyAgent] # Pull + install + feature sync + restart (see below) kestrel status # Show all running agents kestrel list # List available agents kestrel shell MyAgent # CLI chat interface kestrel config ./agent_data/MyAgent # Show agent config Pulling in upstream changes (kestrel update) The typical refresh-the-checkout loop is four commands:
git pull # new code from origin uv sync # refresh deps from uv.lock (PRUNES kestrel-feature-* packages) kestrel feature sync # restore the feature packages uv sync just pruned kestrel restart # bring agents back so they see the new install kestrel update collapses that into one verb:
kestrel update # pull + install + reconcile + feature sync + restart all agents kestrel update Emma # same, but only restart the named agent kestrel update Emma --startup-timeout 300 # allow extra time for feature-heavy startup kestrel update --dry-run # preview the steps (incl. the reconcile plan) without mutating kestrel update --no-pull --no-install # only reconcile + feature sync + restart (e.g. after a manual checkout) kestrel update --no-features # skip BOTH the reconcile and `feature sync` steps kestrel update --allow-dirty # pull even with modified TRACKED files (also relaxes editable reconcile pulls) kestrel update --prefer-source # reconcile: git-pull every feature with a known checkout kestrel update --prefer-pypi # reconcile: pip --upgrade every feature (no editable git pulls) kestrel update --uv-sync # force `uv sync` for the install step kestrel update --no-uv-sync # force `uv pip install -e .` for the install step kestrel update --no-deps # pass --no-deps to `uv pip install` for the fast path kestrel update --continue-on-error # proceed past a reconcile/sync error to the restart kestrel update --allow-constitution-safe-mode # restart even onto a constitution agents are not anchored to kestrel update --allow-pending-offline-migration # proceed onto a release whose offline migration a database is not known to have had kestrel start, kestrel restart, and kestrel update share one readiness deadline while waiting for the server's /health endpoint. Use --startup-timeout SECONDS on any of those commands when a deployment needs a different deadline; each command's --help reports the current default. A timeout does not kill the process—the error names the log to inspect because initialization may still be in progress.
Reconcile step — host venv ⇆ agent allowlists. After the install and feature sync steps, kestrel update reconciles the host venv against union(all [agents.*].features) + the mandatory features. The per-agent features allowlist is a filter, not an installer: naming a feature class an agent doesn't have installed just makes it silently never load. Reconcile closes that gap — it resolves each required class to its package (live entry-points + in-tree bundled classes first, the static feature registry as fallback), then installs any that are missing and updates the rest. A class that no installed package, bundled feature, or catalogued package provides is a hard error (no blind fallback) — fix the allowlist or add the package to the registry.
Update mode is per-feature, read from the .kestrel-host-features.toml source map (each entry records where a package comes from — editable = "/path" or pypi = ">=x,<y"): editable features are git pull --ff-only'd in their checkout (that checkout IS the running code); PyPI features are pip install --upgrade'd (respecting floor pins). A non-fast-forward or a dirty checkout is reported, never auto-merged. --prefer-source / --prefer-pypi bulk-override the mode.
Install step auto-detect. When uv.lock exists at the source checkout root, the install step runs uv sync --active against the venv that owns the running kestrel binary (detected via sys.prefix != sys.base_prefix, so systemd / cron / direct-path invocations work too). That refreshes deps from the lockfile AND prunes packages not in it — which is precisely why kestrel feature sync runs immediately after, to restore any out-of-tree feature packages (kestrel-feature-*) that uv sync just pruned. Without uv.lock present, the step falls back to uv pip install --python sys.executable -e . which only reinstalls the project package. Force either branch with --uv-sync / --no-uv-sync.
Feature installs keep uv.lock. Every feature install (feature sync, reconcile, feature install / upgrade, and the console's install endpoint) runs through uv pip, which never reads uv.lock, and uv applies --upgrade eagerly: it may move every package in the resolution, not only the feature. So each of those installs carries a name===version constraint for every package the uv.lock beside core's checkout pins. A feature that needs another version of a locked package fails to install and names the lock; move the lock deliberately (uv lock --upgrade-package and a green CI run) rather than installing around it. A manifest entry for core itself, installed from a checkout (for example kestrel-sovereign[observability], whose extras uv sync does not install), is held to that checkout's uv.lock the same way. So is the automatic restore that follows a feature install that left core off its declared checkout, and the restore command printed when that restore fails: both carry the restored checkout's lock. A uv.lock that exists but cannot be read (unparseable, or a directory or other non-file at that path) refuses the install rather than running it unheld. So does one that names no single version of a locked package for this interpreter and platform, since that package could not be held, and so does a core whose own install metadata will not read, since the lock beside it cannot then be located; a refused restore prints no command. Which line a locked package gets depends only on the lock and the host manifest, never on how the package is installed now or on the install that carries the line. In reconcile, --prefer-source / --prefer-pypi are declarations too: they are applied to the manifest's before the plan and these lines are derived, so the two always agree. --prefer-pypi pins a package the manifest declares editable at its locked version, and --prefer-source holds each package on the checkout it keeps (the manifest's, else the one the venv links). A package the manifest declares editable is held on that checkout instead of pinned (-e @ file:/// ): it stays linked, --upgrade included, and an install that needs a version the checkout does not build fails rather than replacing the link from the index. pip cannot carry that hold (it refuses an editable constraint), so on a host without uv such an install is refused. Every other locked package keeps its pin however it is installed (===, so a local build such as 1.0+cu121 cannot stand in for a locked 1.0), so a checkout or URL install that no manifest declares is put back to the locked version when an install resolves it; declare its checkout to keep it. feature install, feature upgrade and the console take no manifest, but when a lock holds their installs they read the editable declarations of the project directory's host manifest the same way, never one in the current directory. With no manifest there, every locked package is pinned and a refused install names the path that was checked; one that exists and will not read or cannot be reached refuses the install. A git fallback is pinned like any other install, so it lands only a git build of the locked version. After its installs, kestrel update compares each locked package's installed version with the lock and prints every mismatch, and every locked package whose installed metadata names no version, before the restart; kestrel doctor runs the same check. kestrel feature sync ends with the part of that check that matters most, run by update_then_restart too: every locked package it leaves installed below its locked version, both versions, and what forced it there (each installed package whose requirement excludes the locked version, the host manifest when it holds the package on a checkout, or unknown), printed and logged at WARNING. A core checkout with no uv.lock, or one that will not read, is named the same way. update_then_restart keeps every one of them, whole, as the sync step's lock_findings in the request's update_log, beside the output it cuts to a tail; lock_findings_unavailable says why when there are none to keep (a sync that ended before comparing, or an update to a revision older than this report). All three only report. None repairs anything or changes the exit status.
Dirty-tree detection. Only modified or staged tracked files block the pull. Untracked files (kestrel.toml.backup-* written by kestrel setup, scratch files, etc.) don't count — git pull --ff-only can't collide with files git doesn't know about. The refusal message surfaces the porcelain summary so you can see exactly what to commit/stash.
Pip-installed users (no editable source checkout — pip install kestrel-sovereign against PyPI) — both pull AND install are silently skipped; feature sync and restart still run, held to the installed core release (see above). Upgrade the package itself with pip install --upgrade kestrel-sovereign first, then run kestrel update to pick up new features + restart.
Bootstrap when your installed kestrel update is older than the fix you want. If your CLI predates a kestrel update change you're trying to pull in, the old version may refuse on a dirty tree (early behaviour treated untracked files as dirty) or run the wrong install command. One-time bootstrap:
git pull && kestrel update # explicit pull first, then the new code runs # or kestrel update --allow-dirty # bypass the old refusal a single time After the new code lands in your checkout, kestrel update alone handles subsequent refreshes.
If this database has ever been served by a pre-protocol-v2 scheduler, do not run a normal rolling kestrel update or restart an old image after a failed first v2 start. The first v2 process deliberately fences legacy-visible schedules and waits for a drain acknowledgement; an old binary against that fenced database can leave work dormant or duplicate an occurrence. This applies to both local SQLite and shared PostgreSQL deployments.
Stop every legacy poller and schedule writer, take a backend-appropriate backup, perform the controlled v2 acknowledgement, and use forward-only recovery unless you deliberately restore the complete pre-cutover database while all writers remain stopped. The exact local, systemd, PyPI, SQLite, and PostgreSQL commands are in the scheduler protocol-v2 deployment runbook.
Shared PostgreSQL hosts pre-seed database-global scheduler provenance and every resolvable configured DID before parallel agent runners start. That lets a new DID join a known fresh-v2 fleet safely, but an absent/unknown provenance marker is always treated as a legacy migration; do not seed or unfence scheduler rows manually.
The hosted agents share one operational PostgreSQL pool and one smaller pool for session advisory locks. Their per-process defaults are 20 and 4 connections, respectively. Size them for the deployment's admitted fleet traffic with KESTREL_SHARED_AGENT_POSTGRES_MAX_POOL_SIZE and KESTREL_SHARED_AGENT_POSTGRES_ADVISORY_MAX_POOL_SIZE; both settings must be positive integers. These are independent host budgets: scheduler effect gates use the scheduler host's own storage pool, not the agents' advisory pool.
Core declares its SDK version constraint in pyproject.toml. Core 0.64 requires public SDK 0.51.2 or later and provider packages from the 0.2 family. This release adopts LLM contract 8: both adapter streaming methods end with exactly one LLMResponse, after EOF and native response cleanup. Direct adapter consumers must handle that terminal response separately from text chunks. Use the with-tools method for tools; plain streams reject tool requests and returned tool evidence. Plain streams omit ThinkingDelta; use the with-tools method to consume separate reasoning events.
Persistent privacy modes require the original configured data key (KESTREL_DATA_KEY or KESTREL_DATA_KEY_FILE) at boot. The durable tool-effect journal requires encryption; a missing key or unavailable journal stops boot before the host can advertise readiness. Modes that forbid persistence do not admit journaled tool execution. Preserve the original key and journal across restarts so previously uncertain effects remain fenced.
Core validates the SDK response and tool-call shapes at its adapter boundary. Malformed JSON and non-object tool arguments fail without fabricated argument data. A streamed zero-argument call with no argument fragments carries {}. A completed non-streaming or batch call must supply a JSON object; missing arguments or an empty string fail. Non-empty stream fragments must also form a valid JSON object. Native stop reasons remain unchanged, including unknown values; absent evidence stays None, which Core rejects as incomplete. Protocol and cleanup failures cannot expose a successful terminal response or trigger a retry of that generation.
The base install selects [a2a,httpx,tracing]; the observability extra adds metrics under that same base constraint. The 0.40 release replaces draft A2A contribution types with native AgentSkill and get_agent_skills contracts; the coordinated 0.41.0 floor also includes the shared computer-use, artifact, resource-scope and workspace-transfer contracts. The 0.42 floor supplies the reviewed vendored native A2A implementation used by both Core and feature skill producers through the SDK's a2a extra. SDK 0.42.2 also supplies the standard version query carrier and validation of repeated version headers required by Core's native bindings. SDK 0.42.3 corrects native HTTP+JSON protocol error media types. SDK 0.42.4 owns the shared certifi dependency policy for HTTPX and requests; operating-system trust stores are unaffected. SDK 0.43 adds governed dynamic-tool binding and model-exposure contracts. Core requires sse-starlette>=3.5.0 so stopping one server does not cancel streams served by a later server in the same process; automatic stream draining remains enabled. SDK 0.39 lacks the native initialization contract and cannot boot this release. The lock records the tested version without excluding future SDK minor releases. The SDK owns the canonical outbound URL/IP policy and native pinned HTTP transport. Version 0.39.2 aligns DNS, canonical URLs and native origin checks to IDNA 2008; avatar downloads and DID resolution use it. Core retains only its stdlib HTTPS I/O implementation for DID documents. That binding shares one TCP/TLS deadline across approved addresses, retries TCP connection failures only, and keeps certificate verification and environment-proxy isolation. Callers use the validated canonical URL; avatar downloads refuse redirects and map transport origin refusals to HTTP 400. DID resolution uses a 10-second connection budget and socket read timeout; DNS and complete response download still need separate liveness bounds, tracked in #3695. 0.39.0 adds the decisions contract (LLM contract v7, epic #3424) that LLMService.decide is built on, on top of the runtime contracts of the 0.37–0.38 line: durable isolated execution, provider-neutral private inference leases (including bounded owner-scoped idle renewal), private host ingress, feature-owned operator and context-clause contribution contracts, and the awaited context-clause preparation hook. It is not a preference that a downstream package may relax.
Story Archive 0.3.5 removes its old SDK ceiling and admits SDK 0.42. The public MCP 0.7.0, Talon 0.2.15, Features 0.3.3, Telegram 0.1.9 and Observability 0.17.15 releases also declare SDK constraints that admit 0.42. These metadata checks establish resolver compatibility, not runtime acceptance. Editable Eye, Flight and Claws installations and the rest of each host's feature manifest need their own source and runtime verification before Core ships.
Core 0.54 host profiles that enable Features or Talon need their published 0.3.4 and 0.3.0 lines respectively. Talon's discovery tool is talon_scan_stale_work; GitHub's separate issue/PR scanner keeps scan_stale_work. The Talon package and host-manifest bounds must advance together before the Core release.
External PostgreSQL pools used for scoped native journals must pass connection_class=NativeJournalPostgresConnection and min_size=0 to asyncpg.create_pool; use init_size for startup warmup. In asyncpg 0.32, min_size starts autonomous pool maintenance, which cannot inherit original execution authority. Such pools are refused before journal admission. See the native journal pool contract.
A Core release that raises the SDK floor without compatible feature releases makes kestrel update refuse every feature whose cap excludes the new line — or worse, lets kestrel feature sync downgrade the SDK under Core while installing a capped package. Survey every package in the host feature manifest using its published metadata (PyPI requires_dist, or the checkout's origin/main for editable entries), not a local checkout's pyproject.toml, and pull editable checkouts before kestrel update. Verify the published downstream constraints and tests before the Core publish. Do not weaken Core's requirement to make an older sibling resolver succeed.
The Core dependency-contract test verifies the base and observability declarations require the native SDK contracts and that the lock exercises an admitted release. It cannot validate another repository's working tree, so host feature verification remains an explicit release gate.
Core 0.52.1 adds the host-authenticated initialize capability channel-inbound-acknowledgement-v1 for the Telegram polling bridge. Telegram 0.1.3 requires that capability before it will start polling, preventing an old Core from mis-parsing its durable ACK envelope and leaving a child poller blocked. Publish Core 0.52.1 first, then publish Telegram 0.1.3; do not relax the Telegram requirement to make the reverse order installable.
Windows base installs also include tzdata, so default UTC and named-IANA scheduler time zones work without optional Pandas or Phoenix extras.
Kestrel ships a self-contained core with the local storage, identity, governance, and built-in LLM-routing dependencies needed to run an agent. Optional feature packages register Feature classes through the kestrel_sovereign.features entry-point group. Provider packages, such as cloud, voice, and storage backends, register with provider-specific entry-point groups and are consumed by their owning core or feature module.
kestrel feature list # Show installed + available features kestrel feature info # Detailed info about a feature kestrel feature install # Install a feature package kestrel feature upgrade [ ...] # Upgrade installed feature/provider packages kestrel feature sync # Restore the host's declared feature set (see below) kestrel feature enable # Enable an installed feature kestrel feature disable # Disable without uninstalling kestrel feature scaffold # Generate a new feature package skeleton The canonical inventory and package-boundary contract live in KESTREL_FEATURES.md. The runtime registry records the same taxonomy in boundary: bundled, bundled-component, feature-package, provider-package, or standalone-tool. Its package is always the owning distribution/install target for that row; core remains a compatibility flag and is true only for the two bundled categories. Catalog status available means “known but not detected in this environment,” not that an external distribution was verified reachable.
Feature and provider packages are deliberately not declared in pyproject.toml (that would invert the open-core dependency direction), so uv sync — which makes the venv match declared dependencies exactly — prunes them. After a sync or any environment rebuild, an installed feature can silently vanish (e.g. voice endpoints start returning 404). kestrel feature upgrade cannot bring it back, because a pruned package leaves no entry-point to discover.
kestrel feature sync is the restore counterpart. It reads a host-local manifest, .kestrel-host-features.toml (gitignored; template at .kestrel-host-features.toml.example), and reinstalls whatever is missing. The manifest lives in the project directory (KESTREL_HOME, else the project found from the current directory), the same one the host reads its feature enablement from, so every command reads the same file wherever it is launched; a relative editable path is relative to the manifest's own directory:
kestrel feature sync --capture # Snapshot currently-installed extensions into the manifest kestrel feature sync # Reinstall the manifest's packages that are missing kestrel feature sync --dry-run # Preview without installing kestrel feature sync --manifest PATH # Use a non-default manifest location A manifest entry names a package (by registry name or raw dist name) and records one source — an editable checkout or a pypi version spec (mutually exclusive) — plus optional extras. This is the source map the kestrel update reconcile step reads to decide each feature's update mode (git pull vs pip --upgrade):
[[feature]] name = "voice" editable = "/path/to/kestrel-feature-voice" # dev checkout: git pull --ff-only on update extras = ["local"] # also pull the on-device pipeline (Piper / faster-whisper) [[feature]] name = "github" pypi = ">=0.2,<0.3" # from PyPI: pip install --upgrade within the pin [[feature]] name = "reflection" # neither form = "install latest from PyPI" (back-compat) This never touches pyproject.toml, so installing kestrel-sovereign itself still pulls zero feature packages. The typical recovery after a prune is kestrel feature sync followed by a host/agent restart so the restored entry-points load.
Each agent can have a kestrel.toml config file in its directory:
# agent_data/myagent/kestrel.toml [agent] name = "MyAgent" port = 8888 host = "0.0.0.0" log_level = "INFO" Create or edit config:
kestrel config ./agent_data/myagent --init # Create config kestrel config ./agent_data/myagent --set-port 8899 # Change port kestrel config ./agent_data/myagent --set-name MyAgent # Change name Revising an agent's SOUL An agent's SOUL is stored as an encrypted, versioned resource in its database; agent_data/ /SOUL.md is only a seed and cache. Every boot serves the current stored version, so editing the file is not enough. !bootstrap reload or !reload-context loads the edited file into the running session, then warns that the next restart serves the stored version. Each boot that serves a stored version over a different file logs a SOUL file drift warning.
To keep an edit, the Sovereign makes the file the new stored version:
!revise-soul Run it in the console or through the invoke API with the API key. It reads SOUL.md, stores it as a new version, records the reason, who ran it and the version it replaced on that version, and loads it into the session. The agent cannot run it on itself: it is a sovereign command, not a tool. It is refused in the ephemeral, isolated and deidentified privacy modes, which store no SOUL. !bootstrap-status shows whether SOUL.md matches the stored version.
Each agent runs on its own port. Create configs for each:
# Agent 1: Alpha on port 8888 kestrel create Alpha --port 8888 kestrel start Alpha # Agent 2: Helper on port 8889 kestrel create Helper --port 8889 kestrel start Helper # Check status of all agents kestrel status Alternative: Direct Commands # Canonical direct-server command (set KESTREL_DB_PATH first). Explicit # loopback binding avoids exposing a local development agent to the LAN: KESTREL_DB_PATH=./agent_data/myagent uv run python -m kestrel_sovereign.server \ --host 127.0.0.1 --port 8888 # CLI chat (no server needed) python -m kestrel_sovereign.main ./agent_data/myagent # Source-clone shorthand for CLI chat remains available: # python main.py ./agent_data/myagent Note: KESTREL_DB_PATH is a directory path, not a file path. The database file kestrel_prime.db is created inside the specified directory. For example, setting KESTREL_DB_PATH=./agent_data/myagent stores the database at ./agent_data/myagent/kestrel_prime.db.
The direct server rejects unknown options instead of silently ignoring bind intent. --host overrides KESTREL_SERVER_HOST, while --port overrides the platform-standard PORT; the compatibility defaults remain 0.0.0.0:8888. For normal fleet operation, kestrel start reads its bind and port from multi_agent.toml and does not accept these direct-server flags. See the server launch contract for the complete precedence and managed-container behavior.
Keeping the host awake (long sessions / 24/7). Kestrel does not manage host power state itself — a long-running agent that must survive an idle machine relies on the OS staying awake. For a dedicated deployment, prefer a service supervisor (launchd/systemd) or an always-on host (Mac mini, VPS, cloud container). For a foreground run on a laptop that would otherwise sleep, wrap the command in the platform's keep-awake utility:
$sig = '[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint e);' $t = Add-Type -MemberDefinition $sig -Name Power -Namespace Win32 -PassThru $t::SetThreadExecutionState(0x80000003) # ES_CONTINUOUS | ES_SYSTEM_REQUIRED kestrel start MyAgent
Kestrel includes a built-in web interface called the Sovereign Console. Once your agent is running, open the URL the CLI printed on start — http://localhost:8888 for the multi-agent host (default kestrel start mode), or the per-agent port for a single-agent start — in any browser; no additional software required. A fresh multi-agent browser session asks for the project .env's KESTREL_API_KEY in a password field and retains it only in that tab's session storage.
The built-in console exposes the following panels; installed features may add their own contributions:
Alternative clients: The server also exposes an OpenAI-compatible API at /v1/chat/completions, so you can connect any OpenAI-compatible client (e.g., Open WebUI) if you prefer.
Kestrel agents are built on several key components:
kestrel-sovereign/ ├── kestrel_sovereign/ # Core sovereign package │ ├── cli.py # `kestrel` CLI entry point (canonical) │ ├── kestrel_agent.py # Core agent class │ ├── inception_service.py # Agent creation (DID + genesis audit) │ ├── agent_config.py # Per-agent config loader │ ├── data/feature_registry.toml # Runtime feature registry │ ├── features/ # Core bundled features │ ├── storage/ # SQL-backed storage facade and stores │ ├── static/ # Sovereign Console frontend │ └── ... ├── server.py # Re-export shim → kestrel_sovereign/server.py (consolidated host + agent app) ├── main.py # Re-export shim → kestrel_sovereign/main.py ├── docs/ # Architecture & guides └── tests/ # Test suite # The Kestrel SDK lives in its own repo + PyPI package: # kestrel-sovereign-sdk (https://github.com/KestrelSovereignAI/kestrel-sovereign-sdk) # Feature authors import its types directly: # from kestrel_sdk.features.base import Feature, tool # from kestrel_sdk.tools.base import ToolCategory, ToolResult # from kestrel_sdk.hooks.base import Hook, HookEvent 🎯 Core Features 1. Sovereign Memory Privacy-gated Storage: SQL-backed stores with full-text search and knowledge graphs when the active privacy mode permits persistence RAG Pipeline: Document chunking and semantic retrieval through SQLAlchemy-backed vector search where available; embeddings are requested from the active LLM provider route when it advertises embedding support, otherwise search falls back to BM25/LIKE paths Conversation History: retained interaction metadata and history outside EPHEMERAL mode Human-Led Interactions: user-directed memory and retrieval controls rather than an unconditional promise to retain every turn 2. Multi-Model Intelligence Local or cloud routes: Ollama can keep inference local; configured cloud routes are available when an operator opts in Vendor/route/model selection: routing is configured per provider and can use ordered fallbacks Extensible adapters: the in-tree adapters and entry-point providers expose their capabilities through the same registry 3. Cryptographic Identity DID Generation: self-certifying did:pkh roots plus supported did:web deployment paths Verification roots: exported did:key identities are supported as self-certifying verification roots; inception does not create new did:key agents Fresh-target verification: exported self-certifying identities carry public succession evidence; a born-hybrid did:web root requires a receiver-owned public-key pin Bounded trust: arbitrary network DID documents and package-declared keys are not implicitly trusted; third-party verification remains an explicit integration boundary 4. Constitutional Governance Immutable Articles: Core principles that cannot be changed Interpretive Canons: Flexible guidelines for decision-making Amendment Process: Cryptographically-signed governance updates 5. Data Sovereignty & Privacy Modes Ephemeral Mode: True off-the-record conversations (nothing stored) Privacy Granularity: selectable privacy modes for different use cases Portable data: operator-controlled local data and identity exports; decentralized-storage integrations are optional surfaces Optional Economics: Wallet and autonomous payment flows are installable feature-package surfaces, not part of the base install ⚠️ Feature maturity Kestrel is pre-1.0 and its public interfaces may change. The maintained source of truth for the in-tree feature inventory, providers, commands, and endpoints is KESTREL_FEATURES.md. Use kestrel feature list or the runtime installed-features API, plus the testing guide, when evaluating a specific deployment. The categories below are qualitative so they do not turn into stale release metrics.
Bottom line: Kestrel is suited to developers and supervised operators building privacy-first, portable agents. Treat a deployment as an engineering system: choose its privacy mode and providers deliberately, verify its enabled features, and do not rely on it as an unmanaged consumer platform.
Detailed documentation is available in the docs/ directory:
Kestrel is a foundation for AI agents that need to outlive any single vendor, deployment, or owner. Concrete deployments and good-fit use cases:
Run the test suite from the activated virtual environment:
# Run a single test with uv and -x uv run pytest -x tests/test_inception.py::test_successful_inception Clean Install Verification Kestrel supports multiple installation configurations. Use the verification script to test that clean installs work correctly across all supported scenarios:
# Run all 5 install scenarios (creates isolated venvs) uv run kestrel verify-install # Run specific tests only uv run kestrel verify-install 1 3 # SDK-only and wallet package The install matrix covers:
Integration tests for the same import paths run as part of the normal test suite:
uv run pytest tests/integration/test_clean_install_verification.py -v 🔧 Configuration LLM Configuration (kestrel.toml [llm]) LLM config lives under the [llm] section of kestrel.toml. The setup wizard (kestrel setup llm) will write it for you; you can also hand-edit kestrel.toml after copying from kestrel.toml.example.
Kestrel uses a vendor/route/model schema. A vendor is who makes the weights; a route is how to reach them (adapter + base URL + auth). API keys belong in .env and are referenced by api_key_env. See kestrel.toml.example and docs/architecture/LLM_SERVICE_ARCHITECTURE.md for the canonical spec.
[llm] route_priority = ["openai:api", "ollama:local"] [llm.vendors.openai] is_cloud = true [llm.vendors.openai.routes.api] adapter = "OpenAIAdapter" api_key_env = "OPENAI_API_KEY" model = "auto" selection_hints = ["gpt-5", "mini"] [llm.vendors.ollama] is_cloud = false [llm.vendors.ollama.routes.local] adapter = "OllamaAdapter" host = "http://localhost:11434" model = "auto" selection_hints = ["llama3.2", "qwen"] Pre-2026-05 setups used a standalone llm_config.toml at the repo root. That path was removed (epic #938). Run kestrel migrate-llm-config to fold a legacy file into kestrel.toml [llm]; the source is renamed to .bak, your prior kestrel.toml is timestamp-backed-up, and the operation is idempotent.
See .env.example for a complete list. Key variables:
Kestrel supports multiple deployment targets. See KESTREL_FEATURES.md for the full catalog.
Scales to zero when idle ($0/month), auto-scales under load. Each sovereign agent gets its own service.
# One-time: set up GCP secrets from .env uv run kestrel deploy secrets sync # Build and push to GCR (both single-agent and multi_agent images) uv run kestrel deploy build # Deploy to dev (multi-agent host, always warm) or prod (single-agent, auto-scales) uv run kestrel deploy dev uv run kestrel deploy prod Profiles live in deploy_config.toml. See docs/deployment/README.md for the full runbook (status, logs, teardown, health).
Auto-deploys on version tags via GitHub Actions.
# Remote LLM — smallest image (~500MB) docker build -f docker/Dockerfile.remote -t kestrel . docker run -p 8888:8888 -e OPENAI_API_KEY=... kestrel # Standalone with Ollama (no API keys needed) docker build -f docker/Dockerfile.standalone -t kestrel-standalone . docker run -p 8888:8888 kestrel-standalone # GPU with CUDA docker build -f docker/Dockerfile.gpu -t kestrel-gpu . docker run --gpus all -p 8888:8888 kestrel-gpu 🔐 Backups and Storage Tiers Backups can be created interactively from the agent using privacy-gated storage tiers:
!backup tier=local !backup tier=ipfs !backup tier=filecoin !promote-backup tier=filecoin Each backup produces a backup_artifact node in the graph linked to the agent with properties like content_hash, ipfs_cid, filecoin_deal_id, encrypted, and timestamp.
KESTREL_DATA_KEY (a Fernet key or passphrase) is the master key for Kestrel's application-layer encryption at rest. It is not whole-database encryption. With it set, Kestrel transparently encrypts conversation-history rows, stored file blobs, agent identity private keys (SecureKeyStorage, AES-256-GCM), and agent-resource bodies such as the SOUL (AgentResourceStore, Fernet). It does not cover saved-item (saved_items.content) or RAG document-chunk (document_chunks.content) bodies — those are plaintext columns today, with application-layer encryption tracked in #2677. Set it before first run:
The accepted, not-yet-implemented design for closing those two gaps is Saved-item and RAG content encryption. That ADR is a rollout contract, not a claim that the current columns are encrypted.
export KESTREL_DATA_KEY=$(python - <<'PY' from cryptography.fernet import Fernet print(Fernet.generate_key().decode()) PY ) Encryption is transparent on read/write. Sovereignty exports are encrypted by default on every storage tier — local included — deriving their key from the same KESTREL_DATA_KEY master key; there is no separate backup key. An export requested with encrypt=True is refused outright when KESTREL_DATA_KEY is unset, never silently downgraded to plaintext; pass encrypt=False to deliberately accept an unencrypted backup. For production, set KESTREL_DATA_KEY from an env/KMS secret rather than the dev placeholder.
Directory and file permissions (0700 / 0600) are access control, not encryption; they do not substitute for the mechanisms above.
Whole-database (SQLCipher) encryption is not implemented in this release. The runtime opens the SQLite database with plain aiosqlite and does not read KESTREL_DB_KEY, so setting that variable does not encrypt the database today. Until full-DB or application-layer encryption lands, the saved-item and RAG document-chunk bodies noted above remain plaintext at rest (#2677). Do not rely on KESTREL_DB_KEY for at-rest protection.
The server exposes OpenAI-compatible endpoints for use with third-party clients:
For most users, the built-in Sovereign Console at the printed URL (http://localhost:8888 for the multi-agent host, or the agent's own port for a single-agent start) is the easiest way to interact with your agent (see the Web UI section above). If you prefer an external client, point any OpenAI-compatible tool (e.g., Open WebUI) at your server's /v1/chat/completions endpoint. Use the model name from /v1/models.
Auth: every request to /v1/... requires the X-API-Key header (or Authorization: Bearer ). The key was written to .env as KESTREL_API_KEY by kestrel setup (or --quickstart). Most OpenAI-compatible clients let you set the key via their OPENAI_API_KEY env var or settings UI; point that at your KESTREL_API_KEY value.
The Kestrel storage system is designed to be modular and extensible. It is composed of several specialized components, orchestrated by a high-level facade.
The main Storage class in storage/__init__.py acts as a facade, providing a single, unified interface to these components.
Every incepted agent carries a structured genesis_audit receipt bound to the SHA-256 hash of the same governing constitution bytes resolved and anchored by the production constitution resolver.
Diagnostic/recovery commands remain available while an audit is pending. Normal cognition returns a clear pending/failed response without sending the user's turn to an LLM.
Safe Mode, audit deadlines, interaction counters, and first-identity bootstrap custody are stored in the primary SQLite or PostgreSQL database. Writes use a database revision fence: a stale replica cannot clear another replica's restriction or reset its audit-due counter. Only the verified, authorized exit path clears a durable restriction; a conflicting writer restricts itself. First creation is insert-only. Loaded records (including migrated revision zero) use conditional updates and cannot recreate a concurrently deleted row. Each recreated row receives a new generation identifier: equal revision numbers from different lifetimes cannot authorize a stale Safe Mode exit. Every signed anchor mutation advances this fence even after first-anchor custody has been consumed, so verification completed against the previous constitution cannot authorize an in-flight exit after reanchor. Restrictions, successful-audit timestamps and interaction counts remain unchanged. An offline signed repair without any runtime row establishes a restricted, audit-due record, never new automatic bootstrap permission.
The additive revision migration retains readable schema-version-1 rows, but database triggers reject pre-revision writers after upgrade. Retire old replicas rather than expecting mixed-version writers to keep operating. Legacy inserts without a generation fence are refused as well. A one-time atomic upgrade assigns immutable legacy: generations to existing empty generations and appends migration evidence without resetting restrictions, audit timestamps, counters or pending markers. These generations permit normal audited admission but never mint automatic first-identity anchor permission. Deleted state cannot regain an empty epoch. Lifetime allocation rechecks surviving history inside its native transaction; missing current state with history requires explicit recovery and independent native feature-registry repair verification, not a constitution-only exit. Initialization checks existing metadata before installing migration DDL; SQLite upgrades reserve the writer slot and recheck before adding columns.
Automatic first anchoring requires a still-pending durable new-identity marker and matching generation/revision, revalidated within the native graph transaction. In-memory bootstrap custody advances only after graph commit. Every native anchor writer (automatic bootstrap, runtime signed reanchor and offline signed reanchor, including same-hash repairs) consumes the marker in the graph transaction. Live writers publish the resulting fence only after commit; neither signed repair nor anchor consumption clears Safe Mode or records a successful audit. An outer caller transaction must not publish a live fence before committing. Native live anchor and state-publication paths refuse ambient transactions before waiting for the constitutional state lock or writing (including SQLite joined scopes and PostgreSQL savepoints); retry the command outside that caller's transaction. Unknown commit-ownership adapters fail closed as well. The signed repair's own graph/state unit remains atomic. Refused lifecycle/audit transitions retain a volatile Safe Mode restriction and mark persistence pending; they do not claim a durable transition. That refusal also invalidates an in-flight verified exit or state writer before its database commit, so a lock owner cannot erase the new restriction. Writers check again after awaited SQL and roll back invalidated state/events; a refusal during commit/result delivery retains its volatile restriction and pending durability instead of reporting the earlier committed exit as recovery. An entry also checks after awaited consent, before replacing a later restriction. Initialization, explicit/startup/periodic audits, and recovery notification share one whole-transition refusal generation, captured before waiting for its state lock. Same-task nesting retains that token; queued entries cannot adopt a later refusal, nor can verification or restore adopt one after becoming stale. An invalidated restore preserves the newer volatile restriction and pending durability; an invalidated audit records no success or older failure over it. A restriction during post-commit exit notification retains the historical exit event but reports current Safe Mode, not successful recovery. Native automatic and signed anchor transactions reserve the complete canonical graph resources before physical file resources, then revalidate and consume custody atomically. Both runtime and offline signed repairs compare the exact preflight pointer, rights, current/history receipts and governance edges again under those graph locks. Rights validation uses that same immutable witness, not a separate edge read which could observe a transient deletion. Changed evidence requires fresh inspection and authorization; adopting a newer custody fence cannot legitimize a previously validated stale repair. The marker is single-use; interruption before verification cannot authorize a second anchor. The absent successful audit timestamp independently keeps the full startup audit due. Consumed custody cannot be re-enabled by an ordinary runtime-state write. Migrated legacy pending-audit markers have no new-identity custody and cannot authorize automatic anchoring, even after ordinary writes advance their revision. An absent anchor in that cohort requires native signed repair. Reading a constitution or initializing its display feature never repairs an existing identity's deleted anchor. That requires native signed reanchor and the normal full integrity verification; an absent anchor is not a fresh boot. The public offline repair accepts a missing hash only on the exact correctly owned identity. Unsigned inspection reports drift without writing; forced repair still verifies the operator-pinned root and exact signed governing hash. Existing emancipation receipts and historical governance bytes remain protected; ambiguous historical anchors or unreadable rights evidence refuse repair. When both pointer and edges are lost, current and historical genesis-audit and reanchor receipts still count as rights evidence. Typed historical hashes are checked without selecting an unsigned replacement pointer. Every reanchor receipt needs a valid destination new_hash; its optional old_hash cannot substitute for a missing or null destination. Missing referenced bytes, malformed receipts, conflicting references or excessive evidence fail closed; restore the exact prior pointer before attempting signed repair. Custody consumption records the transition's current UTC time, not the prior bootstrap state's timestamp, and does not count as a successful full audit. An unchanged hash/edge set is not an unchanged outcome while first-anchor custody remains pending: inspection reports that state, and only signed forced repair consumes it. Read-only inspection never installs lifecycle schema. The display feature reads the authoritative anchored text before each request; pre-anchor initialization never caches unrelated packaged governing text. Failure to retrieve application amendments or render mandate constraints makes the entire governing display unavailable, not a partially weakened text. Adopting a newer lifecycle restriction invalidates older volatile repair proof; an exit must verify the adopted restriction before it can clear Safe Mode.
Both files in this release have provenance metadata.
all-features cloud delivery full local mcp-integration mcp-server ml observability phoenix search test wallet
agents ai constitutional-ai cryptographic-identity did llm open-source sovereign
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Both files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




