Skip to main content

In-process agent sessions: task contracts, transcript merge, compression, and YAML policy

Project description

Keel

Python library for long-running LLM agents: task contracts, transcript merge, tiered context compression, and YAML policy (tools and outbound text). Runs in-process beside your provider SDK.

PyPI distribution: keel-agent. Import name: keel (import keel).

Optional CloudClient syncs audit-style events when KEEL_API_KEY is set; the hosted dashboard is a separate product.

Install

pip install keel-agent
pip install 'keel-agent[cloud]'   # httpx for CloudClient

From a checkout:

pip install -e .
pip install -e ".[dev]"    # tests + ruff

Example

import asyncio
from keel import AgentSession, TaskContract

async def main():
    contract = TaskContract(
        objective="Ship the fix",
        hard_constraints="No secrets in logs.",
        done_criteria="Tests pass.",
        version=1,
        created_at="2026-01-01T00:00:00Z",
        updated_by="app",
    )
    session = AgentSession(contract=contract, transcript=[])
    prep = await session.prepare_turn([{"role": "user", "content": "Next step?"}])
    # prep.messages_for_model -> your LLM API
    # await session.check_tool_or_raise(name, args) before each tool call
    # session.finish_turn(prep.merged_transcript_base, assistant_dict)

asyncio.run(main())

Cloud sync

from keel import CloudClient

client = CloudClient()  # KEEL_API_KEY, KEEL_CLOUD_BASE_URL from env
info = client.verify_subscription()
if info.active:
    client.push_audit_batch([{"type": "compression", "tokens_saved": 42}])

See docs/CLOUD.md in the repository for behavior and endpoints. Base URL is env-driven.

Configuration

Environment variables use the KEEL_ prefix (e.g. KEEL_VERBATIM_USER_TURNS, KEEL_POLICY_FILE). Defaults and types are in keel/config.py.

Tests

pip install -e ".[dev]"
pytest -q tests/

Documentation

Guides and OpenAPI for the cloud API live under docs/ in the source tree. On PyPI, open the project’s repository and browse that folder (the published sdist is code-only).

Modules

Module Role
keel.runtime AgentSession, PreparedTurn
keel.context_assembly merge + assemble_messages
keel.compressor tiered compression
keel.policy_yaml YAML policy loading
keel.cloud optional authenticated sync
keel.grading deterministic rubrics for tests / evals

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keel_agent-0.3.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keel_agent-0.3.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file keel_agent-0.3.0.tar.gz.

File metadata

  • Download URL: keel_agent-0.3.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for keel_agent-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ca52608df4826e7c6f77aa8ef23a7860a8163b571f08d265dc8117237343cdb5
MD5 05bb41940a2b35009671002995a254f4
BLAKE2b-256 cac70523fec94b5382e2deccd5982603856df1136ec8bc9bb25652bc8cc44224

See more details on using hashes here.

File details

Details for the file keel_agent-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: keel_agent-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for keel_agent-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4f9a8eee4f30c5748ab5980022be22448bc3d6575a7baa79f2cc055ca6a1c4c
MD5 96b96655c2893982cb14ed0212307ca7
BLAKE2b-256 9997f9c7464b5c015c24be3980a1c8b87d89a03c8aac4a870a3d0ee57f60c6b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page