Typed declarative contracts for AI agent systems.
Project description
Contract4Agents
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.mdexplains how to use Contract4Agents beside an existing agent SDK implementation.VISION.mdexplains the concept and why it exists.examples/incident-command/README.mdis the most concrete first read: it explains what users write, what the files mean, and what artifacts are generated.examples/multi-lens-research/README.mdshows a complex research team split into focused expert lenses.examples/market-research-brief/README.mdshows document-driven market research against dated current-fact snapshots, including an OpenAI hosted web-search declaration.examples/README.mdexplains the reusable pattern for future examples.docs/index.mdis the documentation map.docs/examples/incident-command-walkthrough.mdwalks through the clone-only example.docs/research/agent-sdk-pattern-survey.mdcaptures the cross-SDK patterns Contract4Agents should preserve.docs/decisions/accepted-decisions.mdrecords choices that should not be reopened casually.
What's Included
contract4agentsPython packagecontract4agentsClick 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 Commandexample 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57fc2720f1b512d3ddfd8e36d7a95f34724d2972cbb89dfd2f56e00499c23542
|
|
| MD5 |
68eb5d1344e725c465b2dbe7c47924e8
|
|
| BLAKE2b-256 |
039221525f7114ef8f7219bab1759d52ea5f843390d8c6ab65601aaac80df404
|
Provenance
The following attestation bundles were made for contract4agents-0.3.0.tar.gz:
Publisher:
python-publish.yml on btfranklin/contract4agents
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
contract4agents-0.3.0.tar.gz -
Subject digest:
57fc2720f1b512d3ddfd8e36d7a95f34724d2972cbb89dfd2f56e00499c23542 - Sigstore transparency entry: 2066617768
- Sigstore integration time:
-
Permalink:
btfranklin/contract4agents@100bb959aacc2c1cb4482c73d528bed52742acdb -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/btfranklin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@100bb959aacc2c1cb4482c73d528bed52742acdb -
Trigger Event:
release
-
Statement type:
File details
Details for the file contract4agents-0.3.0-py3-none-any.whl.
File metadata
- Download URL: contract4agents-0.3.0-py3-none-any.whl
- Upload date:
- Size: 113.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b6adce48d6c8612e5f20b7db4f6f031a24abed43368edb2093e0f305b8371f3
|
|
| MD5 |
b0861a993ddf0a42713fb975fe696139
|
|
| BLAKE2b-256 |
be520b956f3f5f9a88fee37490b15d48e75b27623865ba07ba3f3c94948fdffc
|
Provenance
The following attestation bundles were made for contract4agents-0.3.0-py3-none-any.whl:
Publisher:
python-publish.yml on btfranklin/contract4agents
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
contract4agents-0.3.0-py3-none-any.whl -
Subject digest:
0b6adce48d6c8612e5f20b7db4f6f031a24abed43368edb2093e0f305b8371f3 - Sigstore transparency entry: 2066617790
- Sigstore integration time:
-
Permalink:
btfranklin/contract4agents@100bb959aacc2c1cb4482c73d528bed52742acdb -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/btfranklin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@100bb959aacc2c1cb4482c73d528bed52742acdb -
Trigger Event:
release
-
Statement type: