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, 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.
  • 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 tests/fixtures/contract_projects/ops-desk-lab
pdm run docs-check
pdm run validate

The examples/incident-command project is the public walkthrough fixture for check, compile, and visualization. The eval command currently uses the richer tests/fixtures/contract_projects/ops-desk-lab fixture because the reusable fixture runner expects a fixture.json project.

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.1.0.tar.gz (42.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.1.0-py3-none-any.whl (56.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: contract4agents-0.1.0.tar.gz
  • Upload date:
  • Size: 42.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.1.0.tar.gz
Algorithm Hash digest
SHA256 254dcf6e0145f4041366556f0a0441c1da8c66139201b6c1bd70c135000c4bb1
MD5 c9f52279d926aa1944a2017dbdeff671
BLAKE2b-256 62545f0b337c3d04ab891ad6299dff72130d1336fe49a1cd84509fcf072cc538

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for contract4agents-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44fa690c2468d81b364dde408a5ccf8a666ce39295ccbe1731c0276df84abaa8
MD5 84fb083bb78697ad4c6670984d9ddf50
BLAKE2b-256 3013e9b17672cfc29658efd6b3546e3b715b55d5bffd37874e1ce3ae6c0fce4d

See more details on using hashes here.

Provenance

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