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, context requirements, 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.

What's Included

  • contract4agents Python package
  • contract4agents Click CLI
  • Lark-backed parser
  • semantic analyzer
  • static child-agent context dependency checks
  • source-owned capability registry and strict host-code drift checks
  • run specs for host-owned workflow trace and stage-output expectations
  • 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 check examples/incident-command --strict-drift
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.3.0.tar.gz (79.6 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.3.0-py3-none-any.whl (113.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for contract4agents-0.3.0.tar.gz
Algorithm Hash digest
SHA256 57fc2720f1b512d3ddfd8e36d7a95f34724d2972cbb89dfd2f56e00499c23542
MD5 68eb5d1344e725c465b2dbe7c47924e8
BLAKE2b-256 039221525f7114ef8f7219bab1759d52ea5f843390d8c6ab65601aaac80df404

See more details on using hashes here.

Provenance

The following attestation bundles were made for contract4agents-0.3.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.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for contract4agents-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b6adce48d6c8612e5f20b7db4f6f031a24abed43368edb2093e0f305b8371f3
MD5 b0861a993ddf0a42713fb975fe696139
BLAKE2b-256 be520b956f3f5f9a88fee37490b15d48e75b27623865ba07ba3f3c94948fdffc

See more details on using hashes here.

Provenance

The following attestation bundles were made for contract4agents-0.3.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