Skip to main content

Typed declarative contracts for AI agent systems.

Project description

Contract4Agents

Contract4Agents banner

Contract4Agents is a typed declarative language and local toolchain for defining AI agents as inspectable contracts.

The source artifact is a .contract file. It describes an agent's callable interface, allowed capabilities, policies, guards, assertions, and output contract. The compiler turns that source into prompts, provider-neutral manifests, JSON Schemas, guard plans, eval packs, monitor rules, and visualization artifacts.

Contract4Agents includes the compiler, CLI, local fixtures, monitor checks, runtime primitives, and provider adapters needed to use those contracts beside a host agent application.

Start here:

  • docs/tutorials/using-contract4agents-with-an-agent-app.md explains how to use Contract4Agents beside an existing agent SDK implementation.
  • VISION.md explains the concept and why it exists.
  • examples/incident-command/README.md is the most concrete first read: it explains what users write, what the files mean, and what artifacts are generated.
  • examples/multi-lens-research/README.md shows a complex research team split into focused expert lenses.
  • examples/market-research-brief/README.md shows document-driven market research against dated current-fact snapshots, including an OpenAI hosted web-search declaration.
  • examples/README.md explains the reusable pattern for future examples.
  • docs/index.md is the documentation map.
  • docs/examples/incident-command-walkthrough.md walks through the clone-only example.
  • docs/research/agent-sdk-pattern-survey.md captures the cross-SDK patterns Contract4Agents should preserve.
  • docs/decisions/accepted-decisions.md records choices that should not be reopened casually.
  • docs/implementation/roadmap.md tracks the active backlog for VISION gaps that are not implemented yet.

What's Included

  • contract4agents Python package
  • contract4agents Click CLI
  • Lark-backed parser
  • semantic analyzer
  • JSON Schema and provider-neutral manifest compiler
  • local fake-tool and datasource runtime primitives
  • eval and monitor runners
  • static project visualization
  • first OpenAI adapter and semantic judge adapter
  • clone-only Incident Command example backed by SQLite fake data

Development Setup

pdm install
pdm run contract4agents --help

Useful Commands

pdm run contract4agents check examples/incident-command
pdm run contract4agents compile examples/incident-command --out .contract/build
pdm run contract4agents visualize examples/incident-command --out .contract/build/visualization
pdm run contract4agents eval examples/incident-command
pdm run docs-check
pdm run validate

The examples/incident-command project is the public walkthrough fixture for check, compile, visualization, and eval. The richer tests/fixtures/contract_projects/ops-desk-lab fixture remains available for internal edge-case coverage.

OpenAI Adapter Checks

The normal validation suite does not call external APIs. Live OpenAI checks are opt-in:

CONTRACT4AGENTS_RUN_OPENAI_LIVE=1 pdm run test:openai-live
CONTRACT4AGENTS_RUN_OPENAI_AGENT_LIVE=1 pdm run test:openai-agent-live

Those commands require OPENAI_API_KEY in the environment or in the ignored local .env file.

License

MIT. See LICENSE.

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

contract4agents-0.2.0.tar.gz (66.5 kB view details)

Uploaded Source

Built Distribution

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

contract4agents-0.2.0-py3-none-any.whl (93.3 kB view details)

Uploaded Python 3

File details

Details for the file contract4agents-0.2.0.tar.gz.

File metadata

  • Download URL: contract4agents-0.2.0.tar.gz
  • Upload date:
  • Size: 66.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for contract4agents-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dee248b11dc51fe6866db872745fe9139804ba4f99078827143c86e30b996cff
MD5 1bf6cc2a2291309807f86d2b83dd9696
BLAKE2b-256 fba3d69dd3ce65518393b007868902fee705ce12a5d9b1bd7ac2ac12b07563a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for contract4agents-0.2.0.tar.gz:

Publisher: python-publish.yml on btfranklin/contract4agents

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file contract4agents-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for contract4agents-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8536b0927e6a2b0bab484366436fc216efa623fd1f8dfb34c221d67e0a07a6ea
MD5 71d481d2ce2cf8d72530b58b2ec87938
BLAKE2b-256 79aec76f943dac10d75c37937041e547dfdd3be57b804a977339b94ba38786fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for contract4agents-0.2.0-py3-none-any.whl:

Publisher: python-publish.yml on btfranklin/contract4agents

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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