cayu README

The project's README from github.com/cayu-dev/cayu. As one markdown file: README.md.

Cayu

Find public concepts · Run the example

Cayu is a production agent runtime for building and operating AI agents in Python.

A harness turns a model into an agent by supplying its context, tools, permissions, and execution logic. Cayu gives applications control of the full agent execution lifecycle: how context is assembled, models and tools are invoked, where agent code runs, how state is persisted, authority is governed, failures are recovered, and behavior is observed and evaluated.

Cayu provides durable agent-runtime primitives including sessions, task dispatch, leased workers, resumable workflow steps, approvals, and recovery. Applications can use them directly without a separate workflow engine.

Applications retain control of their UI, authentication, domain logic, and business workflows.

Cayu is designed for agents that do consequential or long-horizon work. You compose its runtime primitives directly in your application.

Why we built Cayu

Cayu was extracted from the production runtime behind an agent-operated software factory that built and deployed thousands of business applications. Specialized agents worked together as the AI SRE, AI product manager, AI coder, and FDE assistant behind that delivery process.

We began by building agents with SDKs and frameworks including the Claude Agent SDK, Mastra, and LangGraph. They helped us implement the model-and-tool loop quickly. Production quality required deeper control of the loop itself: context assembly, model and tool invocation, output validation, and failure handling.

Production quality also depended on everything around that loop: scheduling, durable state, credentials, execution environments, human intervention, recovery, cost attribution, and evaluation. Cayu gives applications control of that entire agent execution lifecycle.

Why Cayu

Agent prototypes are easy to start. Production failures happen at the boundaries:

Cayu treats these as runtime contracts. Important actions become structured events; tool authority and recovery are explicit; configured durable stores let transcripts and checkpoints survive process boundaries; and the same public seams support local development, tests, control-plane inspection, and hosted deployments.

What Cayu provides

Need Cayu primitive
Long-horizon work Durable sessions, transcripts, events, resume, fork, interruption
Safe effects Typed tools, effect declarations, policies, approvals, idempotency keys
Human interaction User-input checkpoints, approval resolution, manual recovery
Context pressure Token counting, projection, compaction, overflow recovery
Cost control Usage events, run limits, budgets, pricing, causal-budget summaries
Execution boundaries Environments, workspaces, runners, artifacts, vaults, egress
Reviewed knowledge Durable entries, approval state, keyword/vector retrieval, recall tools
Long-term recall Bounded knowledge/transcript sources, deterministic fusion, exact locators and coverage
Provider flexibility OpenAI API, experimental OpenAI subscription login, Anthropic, Bedrock, Vertex, OpenAI-compatible APIs
Agent operations Tasks, dispatchers, event watchers, subagents, runtime hooks
Behavioral proof Runtime tests, production-session promotion, durable evals, comparison, and CI reports
Operations FastAPI control plane and a packaged dashboard for sessions, workflows, usage, and evals

Verify the runtime

Want executable evidence before adopting Cayu? The runtime qualification guide maps tool roundtrips, durable continuation, approval gating, and reviewed-proposal binding to existing tests. It provides a pinned installed-wheel setup, a small credential-free acceptance plan, the restartable support integration, and broader release qualification, with report interpretation and coverage limits.

Quickstart

Need a non-coding agent that survives restarts and waits for approval? Follow the restartable support-agent example. It investigates an order, asks for clarification, proposes a replacement, and waits for verified representative approval before executing it. The guide and executable ship with Cayu:

cayu guide order-support
python -m cayu.examples.order_support --help

For a model-only agent, start with the generated project below.

Start a project

The generated project is the recommended path for both humans and coding agents. Cayu requires Python 3.11 or newer.

You can give a coding agent one request: “Run pip install cayu and create a code review agent.”

pip install cayu pytest
cayu new myagent
cd myagent

cayu inspect --json
cayu check --fail-on warning --json
pytest
cayu eval run

# After configuring the provider through configuration/settings.py or CAYU_PROVIDER:
python run.py --message "Review this change."

For a portable operator snapshot that performs no agent, tool, recovery, repair, or live-provider work, run cayu doctor --bundle cayu-support.zip. The command reuses maintained-service diagnostics when selected and forces CayuApp and project control-plane stores backed by the built-in SQLite and PostgreSQL implementations into diagnostic read-only validation without creating or migrating them. Session history is excluded unless you explicitly repeat --session. See Diagnostic support bundles for the contents, redaction boundary, hard limits, and exit codes.

The scaffold is credential-free and includes:

Open the generated project, describe the requested job in the existing agent, and keep its public test/eval seam intact.

For an explicit, editable repository-coding starter with bounded file and Git tools, durable knowledge, background review delegation, and human input, opt in to the maintained composition:

cayu new mycoder --preset coding
cd mycoder
cayu check --fail-on warning --json
pytest -q tests/test_coding_composition.py
python run.py --agent mycoder --message "Implement the requested change."

Add --execution docker for the maintained GitHub-independent coding product. Its build_coding_product_application() front door produces durable patch_ready_for_delivery evidence after required checks, source copy-back, Git inspection, and configured review gates settle. It performs no commit, push, pull-request, CI, or merge effect. See the maintained coding product.

Add --with remote-git-delivery to generate the optional host-side broker seam. It prepares the exact patch-ready tree for application approval, then can create and push one exact commit to a new configured branch without exposing remote or credential authority to the coding agent. See approved remote Git delivery.

Add --with github-delivery to include the subsequent host-only PR, exact-head checks, review, and provenance-labelled follow-up seam. It implies remote Git delivery and does not authorize merge. See GitHub delivery.

The generated repository starts from a clean Git commit, and each new product run requires a clean committed Git source baseline. It also requires git, rg, and the POSIX descriptor-relative filesystem primitives used by secure LocalWorkspace path operations. Unsupported hosts fail during generation or application construction. Its local workspace and runner are trusted-host development adapters, not a hostile-code sandbox. The default scaffold is the complete Cayu application convention. Select --preset agent, --preset service, or --preset coding; optional capabilities share the same application layout.

Discover or review the Rails-style generation plan before writing:

cayu new --list-presets --json
cayu new --list-capabilities --json
cayu new myagent --preset agent --provider anthropic --dry-run --json
cayu guide applications#planning --json

Deploy with Cayu Cloud

Cloud commands ship in the same cayu package; no additional CLI package is required. Cayu Cloud is currently invite-only. Login-backed commands are pinned to the production service at https://cloud.cayu.dev; users never select an API URL.

cayu cloud --help
cayu cloud login
cayu cloud whoami
cayu cloud init
cayu cloud deploy

Login uses WorkOS device authorization. It opens the browser when possible and always prints a verification URL and one-time user code for SSH, containers, Cursor, Codex, and Claude Code. The resulting Organization-scoped session is stored privately and refreshed automatically; no WorkOS secret is embedded in Cayu. Use --no-browser when a human will open the displayed URL on another device. Login selects the WorkOS session over any previously persisted private context; a later cayu cloud context use PATH deliberately switches back to that internal automation context. Private contexts and explicit API credentials remain endpoint-bound operator mechanisms and do not change the default customer endpoint.

cayu cloud init generates the small deployment descriptor from standard pyproject.toml metadata and a configured Cayu server, worker, or console script. Review the generated process topology before deploying it. Existing descriptors are never replaced unless --force is explicit.

The default command packages the current local working directory and uploads it directly to the selected Cayu Cloud Organization as an immutable source bundle. It includes an applied patch and does not require GitHub, a clean worktree, a commit, or a push. Git-ignored files and common local credential/cache paths are omitted.

Deploy creates or updates the 8-63 character application slug declared in cayu-cloud.toml. Slugs use lowercase letters, numbers, and interior hyphens. --application SLUG overrides that create-or-update slug; check it carefully because a valid typo creates a separate application.

Deploy output and local evidence redact runtime environment values. Cayu verifies the evidence destination before Cloud mutation; if only the final evidence write fails after a successful rollout, deploy still exits successfully with evidence_id: null and an evidence.status: unavailable diagnostic.

To deploy an exact remote GitHub revision instead, pass its canonical URL and 40-character commit. For a private source, make authentication available to the process that runs Cayu:

gh auth status --hostname github.com
# For noninteractive CI or an isolated Codex/Claude Code home:
GH_TOKEN="$GITHUB_TOKEN" cayu cloud deploy \
  https://github.com/example/agent --revision COMMIT_SHA

GitHub CLI credentials stored in a desktop keychain may not be reachable after changing HOME, even when GH_CONFIG_DIR points at an authenticated GitHub CLI configuration. In that case, pass a short-lived GH_TOKEN explicitly. Cayu does not persist the token in its Cloud context or include GitHub CLI stderr in its JSON errors. Public GitHub repositories remain deployable without GitHub authentication.

For CI and other noninteractive automation, the existing CAYU_CLOUD_API_KEY, CAYU_CLOUD_API_KEY_FILE, and private Cloud-context options remain available. Explicit automation credentials take precedence over the saved interactive login.

Run an agent

This compact example shows the core API. Real projects should put the same registrations in the generated build_app() factory instead of constructing a module-global app.

import asyncio

from cayu import (
    AgentSpec,
    CayuApp,
    Message,
    OpenAIProvider,
    RunRequest,
    run_to_completion,
)


async def main() -> None:
    app = CayuApp()
    app.register_provider(OpenAIProvider(), default=True)  # reads OPENAI_API_KEY
    app.register_agent(AgentSpec(name="assistant", model="gpt-5.6"))

    outcome = await run_to_completion(
        app,
        RunRequest(
            agent_name="assistant",
            messages=[Message.text("user", "Explain durable agent sessions.")],
        ),
    )

    if outcome.ok:
        print(outcome.final_text)
    else:
        print(f"{outcome.status}: {outcome.error}")


asyncio.run(main())

CayuApp() uses in-memory stores by default, which is appropriate for this one-shot example and for tests. The generated project configures all local Cayu stores in data/cayu.db so sessions survive process restarts. Multi-process production deployments should select a conforming shared store such as PostgreSQL.

CayuApp.run(...) is the lower-level event-stream API. Runtime failures arrive as terminal session.failed events instead of exceptions raised from iteration. run_to_completion(...) consumes that same stream and returns a typed outcome when an application only needs the result. It retains the complete event stream in RunOutcome.events; use it for bounded runs. Consume CayuApp.run(...) incrementally for long-lived or high-volume runs.

For a credential-free domain-tool tracer bullet, run cayu guide references#domain-tool, then use cayu generate tool. To add workspace tools and command execution, see examples/local_environment_runtime.py. For a finite application-owned command surface, use NamedCheck and RunCheckTool instead of exposing model-authored shell or argv.

Build with a coding agent

The generated AGENTS.md is the project-local source of truth. Ask the coding agent to read it first, then use Cayu's package-shipped guides and structured inspection:

cayu guide anatomy
cayu guide authoring
cayu inspect --json
cayu check --fail-on warning --json

The package-shipped cayu guide authoring#cayu-map routes each optional capability to the smallest version-matched local reference. Its online source mirror is secondary. The examples index provides runnable references without making them required project structure.

The supported authoring loop is:

understand -> inspect -> plan -> change -> test -> eval -> exercise -> report evidence

Start by editing the existing model-only agent, test, and eval. Add a generated tool-backed slice only when the requested job needs a capability outside the model; generated slices remain unfinished until their placeholder behavior, test, and eval have been replaced.

Mental model

Cayu separates the agent's identity from the resources and durable state used for one execution:

AgentSpec
  identity, model, system prompt, defaults, runtime policies

Environment
  workspace, runner, artifacts, vault, proxy, knowledge, MCP

Session
  durable identity, transcript, events, status, checkpoints

ToolContext
  the active environment services and call identity for one tool execution

An environment is optional for a conversational agent. It becomes important when tools need files, commands, artifacts, secrets, network policy, or a sandbox. Static environments are useful for trusted local work; EnvironmentFactory creates or reattaches session-specific environments in production.

Choose the execution surface according to where code should run and which boundary should contain it:

Surface Execution location Boundary
Native Python Tool Cayu application process Trusted application code; policy controls invocation, not host-process access
Process-isolated host Tool Disposable POSIX child process session Hard wall-clock liveness and owned process-group cleanup for an explicitly reconstructable trusted adapter; not a security sandbox
Runner-backed operation (ctx.runner) Selected runner for that operation; the enclosing Tool.run() stays in the Cayu application process Isolation, environment, network, and filesystem guarantees for the operation come from the admitted runner and environment
MCP tool Configured MCP process or server Separate integration boundary whose process, transport, credentials, and isolation remain deployment choices
Virtual egress Selected runner plus a trusted broker outside it A conforming adapter can keep the real credential out of the workload; code isolation still depends on the runner

Use the smallest runtime shape

Do not add every Cayu primitive to every application.

Desired behavior Start with
One model-driven interaction CayuApp, AgentSpec, provider, RunRequest
Deterministic model-callable action Tool, ToolSpec, explicit ToolEffect
Authority over an effect ToolPolicy; approval only where a human gate is required
Mutable files or commands Explicit Environment, Workspace, and Runner
Durable uploaded or generated files ArtifactStore
Long-lived conversation or recovery Durable SessionStore and checkpoint APIs
Background durable work TaskStore plus an explicitly started worker
Delegated model work Subagent tools with bounded child-session policy
Behavioral regression proof EvalSuite and trajectory assertions

Start a conversation agent with the model and state it needs. Add workflows, task queues, environments, memory stores, servers, or multi-agent topology when the behavior requires them. Give coding agents narrow domain tools before granting broader shell access.

Artifact writes have a bounded cancellation-settlement contract. After a dispatched write is interrupted, stores distinguish an exact committed artifact, positively proved absence, and a typed reconciliation-required orphan candidate; the candidate is diagnostic evidence, never a readable artifact reference.

Application UI and control plane

Your application should own:

Cayu owns runtime execution and the operational state recorded by the application's configured stores. Its optional dashboard is a control plane for developers and operators: inspect sessions, events, transcripts, tasks, usage, artifacts, pending actions, and recovery state. Your application remains responsible for the product experience.

Start work through the API that matches the trigger:

See Triggering runs for the decision guide and lifecycle responsibilities.

Providers and environments

The base package includes the provider contracts and built-in OpenAI, Anthropic, OpenAI-compatible HTTP, and experimental OpenAI-subscription adapters. Optional extras add integrations without forcing their dependencies into every deployment:

Extra Adds
cayu[server] FastAPI control plane and packaged dashboard
cayu[server-settings] Server extra plus typed environment and .env loading
cayu[oidc] Server extra plus OIDC/JWT bearer-token verification (OidcBearerAuth)
cayu[postgres] PostgreSQL session, task, knowledge, and related stores
cayu[aws] Amazon Bedrock and Lambda MicroVM support
cayu[vertex] Anthropic models through Google Cloud Vertex AI
cayu[e2b] E2B runner and workspace
cayu[microsandbox] Local microVM-backed untrusted-code runner
cayu[egress] Virtual egress and credential-broker primitives
cayu[files] Image and PDF inspection
cayu[console] Interactive application console
cayu[otel] OpenTelemetry tracing and metrics support
cayu[all] Every runtime integration extra above

cayu[all] intentionally excludes cayu[browser], which is dashboard and browser verification tooling rather than a runtime integration.

Providers normalize text, thinking, tool calls, usage, completion reasons, and typed failures behind one runtime contract. Applications register providers explicitly and may add deterministic model-pattern routing; an arbitrary model name never selects a provider.

Cayu focuses on OpenAI, Anthropic, OpenRouter, Google, Bedrock, and Vertex. OpenRouter is a first-class cayu new --provider openrouter and CAYU_PROVIDER=openrouter choice backed by the generic Chat Completions adapter; it requires OPENROUTER_API_KEY and an explicit CAYU_MODEL slug. Compatible Chat Completions services such as Fireworks, Baseten Model APIs, and OpenCode Go use that generic adapter directly. Run cayu guide providers#openrouter or use the package guide for exact setup.

For native Choice, Score, and Noul decisions, explicitly register the experimental TypeSafeProvider. It uses TypeSafe's System One API through Cayu sessions and events; it does not support chat tools or multimodal inputs.

For local development without separate OpenAI API billing, users can sign in with their own ChatGPT subscription:

cayu auth openai login
# For SSH or a remote machine:
cayu auth openai login --headless
from cayu import OpenAISubscriptionProvider

app.register_provider(OpenAISubscriptionProvider(), default=True)

This experimental integration uses the Codex backend. It does not use the documented OpenAI Platform API. Cayu identifies itself with originator: cayu and preserves upstream rejections. OpenAI has not documented this raw backend as a general third-party provider API, so support may change or stop.

Intended-use boundary: Use this path only for a subscription holder's own local development and evaluation. For production, customer-facing or multi-user services, use the OpenAI Platform API or another officially supported provider. Do not share or resell credentials or bypass plan limits.

See OpenAI subscription authentication for the support boundary, credential storage, and fallback options.

The same agent can run in a local workspace, trusted Docker container, E2B, Microsandbox, Lambda MicroVM, or an application-owned runner without changing its identity or transcript contract.

Open and replaceable control plane

Cayu ships three equally supported control-plane choices: use the bundled compiled dashboard, eject the exact version-matched React/TypeScript source for application-owned customization, or provide a completely custom UI over the versioned control-plane API.

cayu dashboard eject ./control-plane
cd control-plane
npm ci
npm run dev
npm run build

Extraction uses package data only—no repository clone, GitHub access, or network request. Serve the resulting dist/ with DashboardConfig(directory=...), mount_cayu(..., dashboard_dir=...), or mount_dashboard(..., dashboard_dir=...). Cayu never rewrites the extracted application-owned source during upgrades. See Open and replaceable control plane for the complete workflow, compatibility gate, and redistribution obligations.

Production boundaries

Cayu makes safety boundaries explicit, but configuration still matters:

Read Runtime contracts before changing persistence, replay, approval, interruption, budget, provider, runner, or recovery behavior.

Documentation

Start with the documentation index for maintained guides, operational references, design records, research evidence, and explicitly archived material.

Start with the document that matches the job:

Goal Guide
Choose Cayu concepts and build an application, by hand or with an AI coding agent cayu guide authoring#cayu-map
Configure primary or compatible model services cayu guide providers (source)
Classify and verify tool mutation and replay behavior cayu guide tool-effects
Build a durable propose, authorize, act, verify, and recover lifecycle cayu guide durable-operations (source)
Complete a task only after an independent verifier accepts its evidence cayu guide verified-work (source, example)
Notify people about durable questions, approvals, and recovery gates cayu guide human-attention (source, example)
Reconstruct service-backed tools with stable identities and scoped knowledge cayu guide durable-service-tools (source, example)
Understand factories, process roles, and lifecycle cayu guide anatomy (source)
Build a browser UI that follows sessions without hot polling cayu guide app-ui (source)
Choose how work starts Triggering runs
Create per-session workspaces and runners Environment factories
Produce a durable checked patch without external delivery Maintained coding product
Deliver an approved exact patch to a new remote Git branch Approved remote Git delivery
Create a bound GitHub PR and observe exact-head checks/reviews GitHub delivery
Implement a runner for your platform Build a runner
Contain a non-cooperative trusted host dependency behind a hard deadline Process-isolated host tools
Configure network and credential boundaries Virtual egress
Let an agent search and read bounded public web evidence Web fetch and hosted search
Run GitHub CLI without giving the runner a real token GitHub CLI through virtual egress
Run a first Control Plane evaluation cayu guide evals-first (source)
Add rubric-based AI quality evaluation cayu guide evals-ai-quality (source)
Evaluate production sessions, scenarios, tools, and memory cayu guide evals-production (source)
Look up complete Evals contracts Evals reference
Understand knowledge authorization, retrieval fusion, and memory baselines Memory foundation contracts
Reproduce bounded stateful agent evaluations Portable agent snapshots
Estimate and govern cost Cost optimization
Use the application console Console
Start a configured server process Project server
Use, customize, or replace the operator control plane Open and replaceable control plane
Start a named worker process Project workers
Configure CLI session-store discovery Session-store targets
Inspect durable sessions safely Session inspection
Configure a control-plane server deployment Server configuration
Embed Cayu behind tenant-aware product APIs Server authentication and tenant isolation
Inspect supported model metadata Model catalog
Look up exact runtime behavior Runtime contracts
Track prerelease behavior and migrations Release notes

Maintainer-facing architecture is documented in Architecture, Project layout, and the Glossary.

Examples

Advanced examples are executable runtime specifications. Each example states its evidence boundary instead of presenting one strategy as suitable for every workload. Their measured results are described in Advanced runtime strategies.

Contributing and security

Cayu contributors should read CONTRIBUTING.md for placement policy, setup, validation commands, and pull-request requirements. New third-party integrations normally live in their own packages against Cayu's public extension contracts.

Report suspected vulnerabilities privately as described in SECURITY.md. Do not open a public issue or pull request for a suspected security vulnerability.

For questions and project discussion, join Discord. Use GitHub issues for actionable bugs and concrete feature proposals.

License

Cayu is licensed under the Apache License 2.0.

cayu (cayu-dev/cayu)

runtime
Searching Database…

904 ·GitHub
What is this?Cayu is an open-source Python framework for building and running domain-specific long-horizon AI agents, with a durable runtime built in that handles sessions, task dispatch, recovery, approvals, and observability.
Is this a framework I embed in my app, or a standalone service?It is a framework whose runtime primitives (sessions, workers, workflows, approvals) you compose directly inside your own Python application, though it also ships a FastAPI control plane and dashboard and can be deployed via Cayu Cloud.
How do I get a Cayu project running?Install it with 'pip install cayu' and scaffold a project; you can even ask a coding agent to 'Run pip install cayu and create a code review agent,' which generates an app.py with a buildapp() factory, tracked folders for tools/prompts/policies, and a hermetic test/eval.
What Python version and tools does it need?Cayu requires Python 3.11 or newer, and the repository-coding starter additionally needs git, rg (ripgrep), and POSIX filesystem primitives on the host.
Is Cayu Cloud available to everyone, and is code execution sandboxed?Cayu Cloud is currently invite-only, and the local workspace/runner used by the coding starter is a trusted-host development adapter, not a sandbox for hostile code.
Which LLM providers does Cayu support?Cayu supports the OpenAI API, an experimental OpenAI subscription login, Anthropic, AWS Bedrock, Google Vertex, and other OpenAI-compatible APIs.
What does Cayu mean by a durable runtime?It means runs can survive process restarts: sessions, transcripts, and checkpoints are persisted so agents can resume, fork, or recover after a crash instead of losing state mid-task.
What is the FastAPI dashboard for?It is a packaged control plane and dashboard for inspecting sessions, workflows, usage, and evaluation results across your running agents.
Why did the team build Cayu instead of using existing agent SDKs?They started with SDKs like the Claude Agent SDK, Mastra, and LangGraph but found production quality required deeper control over context assembly, tool invocation, scheduling, credentials, recovery, and cost attribution, so they extracted Cayu from their own production agent factory.
Creator
cayu-dev
Size
82.3 MB
Stars
904
Age
3mo
Commits · 90 Days