Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Kaiwen Agent Platform

Provider-neutral, reusable agent runtime and UI protocol. This repository contains the reusable platform only; product-specific prompts, tools, persistence models, routes, and visual themes belong in consuming applications.

The project is an alpha. Pin exact versions in consuming applications.

Packages

Package Registry Location Purpose
kaiwen-agent PyPI repository root (src/) Trusted server runtime (Python 3.11+)
@imthekaiwen/agent-protocol npm packages/protocol/ Versioned JSON Schema and TypeScript contracts
@imthekaiwen/agent-ui npm packages/ui-agent/ Headless browser runtime and optional React bindings

Package versions are independent. See CHANGELOG.md for the Python package history and docs/releasing.md for the release procedure.

Repository layout

src/kaiwen_agent/   Python package source
tests/              Python tests
pyproject.toml      Python package metadata and tool configuration
packages/protocol/  Schemas, fixtures, and TypeScript contracts
packages/ui-agent/  Browser runtime, transports, and React components
examples/           Runnable examples, several verified in CI
docs/               Architecture, subsystem documents, ADRs, roadmap
docs/archive/       Historical planning documents (not authoritative)

Install

pip install "kaiwen-agent[openai]"
npm install @imthekaiwen/agent-protocol @imthekaiwen/agent-ui

Optional Python extras: openai-live, gemini, ollama, postgres-memory, redis.

To try the coding-team preview (beta, deterministic, no credentials) from a source checkout, follow docs/quickstart-coding-team.md.

Python quickstart

import asyncio

from pydantic import BaseModel

from kaiwen_agent import Agent, AgentContext, tool
from kaiwen_agent.models.openai import OpenAIResponsesProvider
from kaiwen_agent.types import AgentInput


class ProjectQuery(BaseModel):
    category: str | None = None


@tool(
    name="projects.read",
    description="List projects visible to the current user",
    input_model=ProjectQuery,
    permissions={"projects.read"},
)
async def read_projects(
    context: AgentContext,
    query: ProjectQuery,
) -> list[dict[str, str]]:
    repository = context.services["projects"]
    return await repository.list(category=query.category)


async def main() -> None:
    agent = Agent(
        name="portfolio",
        model=OpenAIResponsesProvider(
            model="your-model-id",
            instructions="Help visitors discover relevant products.",
            store=False,
        ),
        tools=[read_projects],
        permissions={"projects.read"},
    )
    result = await agent.run(
        AgentInput(text="Show me the games"),
        context=AgentContext(
            session_id="session-id",
            permissions=frozenset({"projects.read"}),
            services={"projects": your_repository},
        ),
    )
    print(result.text)


asyncio.run(main())

For a single-agent composition that keeps normal chat tool-free and makes action tools explicit:

from kaiwen_agent import AgentRuntime, RuntimeIdentity

runtime = AgentRuntime(name="assistant", model=provider, tools=[read_projects])
reply = await runtime.chat(
    "Merhaba",
    identity=RuntimeIdentity(session_id="session-id"),
)

AgentRuntime.action() exposes only the tool names selected by trusted host code. AgentRuntime.run() keeps workflow mode fail-closed. Autonomous hosts explicitly compose WorkflowController with durable run state, the existing Task Runtime, and completion gates; it never falls back to an unsafe in-memory workflow.

Larger applications can register immutable AgentDefinition records and compose them through AgentFactory plus a strict WorkspaceProfile. The factory resolves exact prompt and capability versions, constructs a fresh provider instance, validates tool visibility against both capability and workspace allowlists, and records the selected versions in runtime context. Policy and execution-time permission checks remain authoritative; configuration never grants additional access.

Applications may inject ContextBuilder, ContextWindow, and ContextCompactionManager into the runtime. Context collection stays optional for simple chat, uses a provider-specific TokenCounter when available, and never treats lossy session summaries as policy or configuration. Use ArtifactToolResultProcessor when large tool output should be stored out-of-band and represented to the model by an owner-scoped artifact reference.

Runtime delivery requirements use immutable StandardsPack definitions and host-registered verifiers. CompletionGate accepts a mandatory requirement only when its artifact evidence is owned by the trusted user, belongs to the current run, and matches both the protected input fingerprint and declared evidence type. The package does not include product-specific test, legal, citation, or CI verifiers.

OPENAI_API_KEY is read by the OpenAI SDK from the server environment. The runtime never stores it and it must never be exposed to browser code.

Side effects

Tools marked reversible or destructive receive a runtime idempotency key. Set requires_approval=True and supply an application-owned ApprovalGate for publishing, deleting, deploying, calling, or sending messages. Applications must still perform authorization inside their own service boundary. Memory setup and its trust boundaries are documented in docs/long-term-memory.md.

Implemented capabilities

The checked-out code is authoritative; docs/roadmap.md tracks status per phase.

  • Async agent loop with a central tool pipeline: schema validation, policy, approval, idempotency, timeout and retry, audit, and events; session, run, event, and audit ports with a SQLite reference adapter, and SSE event fan-out.
  • AgentRuntime: single-agent-first facade with explicit chat and action modes, trusted identity, immutable definitions, optional context and compaction.
  • Durable action intents, one-time approvals, and restart recovery for workflows.
  • Task runtime, background jobs, bounded delegation, optional teams.
  • Lifecycle wakeups, triggers, objectives, watches, and attention evaluation.
  • Short-term summaries and policy-gated long-term memory (in-memory and optional PostgreSQL full-text and pgvector hybrid retrieval).
  • Optional Redis lease coordination with fencing tokens.
  • Root-bounded workspace filesystem tools and trusted MCP bindings that use the central tool safety pipeline.
  • Technical model capability records and data-locality-aware routing that prevents cloud fallback for local_only requests.
  • Model routing, budgets, prompt and skill registries, artifacts, evaluation, replay, dead letters, backpressure, health, and metrics ports.
  • Providers: OpenAI Responses, OpenAI Live (WebSocket, WebRTC bootstrap, and trusted sideband), optional Gemini and Ollama whose SDKs only return tool proposals, with deterministic fakes for tests.
  • Speech pipeline contracts and phone-channel contracts.
  • Opt-in Coding Kits and the Simple Coding API (kaiwen_agent.kits.coding).
  • Browser runtime with a semantic action registry, HTTP/SSE transport, and React Dynamic Island.

Known limitations

  • No first-party isolated command runner exists. Command, test, lint, and typecheck tools require a host-supplied SandboxRunner; only an unavailable-runner stub and a deterministic fake ship in the package.
  • SQLite and in-memory stores are local references, not a production deployment choice. Distributed rate admission, live Redis and load validation, and operational alerting remain open.
  • Gemini, Ollama, PostgreSQL, Redis, real media, and telephony providers are not exercised by continuous integration.
  • Provider failover occurs only for exceptions a host or adapter classifies as retryable.
  • Open audit risks and planned hardening are tracked in docs/roadmap.md.

Examples

Provider-free examples run without credentials: examples/basic-agent (minimal Agent with a tool), examples/simple-runtime (AgentRuntime chat quickstart), and examples/speech-pipeline (ephemeral STT/TTS composition). Further examples cover task graphs, autonomous and team workflows, Coding Kits, and the React UI under examples/. Give AGENTS.md and docs/consumer-agent-brief.md to a coding agent that integrates the package.

Local development

Python commands run from the repository root:

python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e ".[dev]"
.\.venv\Scripts\python.exe -m pytest
.\.venv\Scripts\python.exe -m ruff check src tests examples

Node packages are built and tested from the repository root with npm ci, npm run build, npm test, and npm run typecheck. The full verification list is in AGENTS.md.

No provider credentials are required for the core test suite or the provider-free examples. For the optional live OpenAI smoke test, copy .env.example to .env, add the key, then run:

.\.venv\Scripts\python.exe examples\openai-smoke\main.py

Documentation

Design constraints

  • Core code is async and independent of OpenAI, FastAPI, databases, and web frameworks.
  • API keys and provider SDK calls remain server-side.
  • Applications own domain tools and authorization context.
  • Every event uses a versioned envelope.
  • Tool access is deny-by-default and checked by the runtime.
  • Side-effecting tools use the central approval, idempotency, policy, and audit pipeline.
  • Browser actions are semantic; executable code and DOM selectors are never transmitted.

Metadata

Release files for kaiwen-agent 0.8.0b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kaiwen-agent 0.8.0b1
File Size Uploaded Provenance Actions
kaiwen_agent-0.8.0b1.tar.gz 602.9 kB With provenance Details for kaiwen_agent-0.8.0b1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kaiwen-agent 0.8.0b1
File Interpreter ABI Platform Actions
kaiwen_agent-0.8.0b1-py3-none-any.whl Python 3 none any Details for kaiwen_agent-0.8.0b1-py3-none-any.whl

Total release size: 1.0 MB

Release files / kaiwen_agent-0.8.0b1.tar.gz

Download URL kaiwen_agent-0.8.0b1.tar.gz
Size 602.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1d83404090f9aa5897732a145b65c3ac793a03b33423f8ce563542724d426679
BLAKE2b-256 checksum
How to use checksums
9df981637c2d2494a59dff2da1daf87a92e9b42491eb8fd05435444274f4ef88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / kaiwen_agent-0.8.0b1-py3-none-any.whl

Download URL kaiwen_agent-0.8.0b1-py3-none-any.whl
Size 423.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3bd59e28a653416dc4bc55b5892cf41e56bf809bebc9112abe43b896883d063a
BLAKE2b-256 checksum
How to use checksums
d343133f5bc44e590165a173429f86065b4bb60f37e8e239648d67afa780142e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for kaiwen-agent 0.8.0b1

Provenance

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kaiwen_agent-0.8.0b1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page