Skip to main content

Contractual runtime for AI agents — pre/post contracts, policy enforcement, credits metering, checkpoint & replay

Reason this release was yanked:

rework

Project description

DEED

Contractual runtime for AI agents.

pip install deed-runtime

Zero dependencies. Python 3.10+.


The problem

Your AI agent ran. Something unexpected happened. No pre-conditions checked. No audit trail. No rollback.

The answer

Every action passes through a contract:

agent score_agent
  contract score_contract
    pre  company_name_present
    post score_generated

  policy
    cap  budget_tokens <= 5000
    deny score_company if input.region == "restricted"
    allow score_company if company_name_present
  • Pre-condition fails → action rejected, no side effects, no charge
  • Post-condition fails → DLQ entry written, credits refunded
  • Policy violation → blocked before execution

Five lines

from deed import DeedRuntime

runtime = DeedRuntime(".")
runtime.register("score_company", my_scorer, charge=1)
result = runtime.run("my_pipeline", "input/state.json")
print(result["score"])  # 0.82

What you get

  • Pre/post contracts on every agent action
  • Policy engine (cap / allow / deny) enforced before execution
  • Credits metering — charge per deed, refund on violation
  • Checkpoint & replay — resume from last known good state
  • DLQ — failed stages captured with full context

Three working examples

# Clone and run:
git clone https://github.com/syntriq/deed
cd deed/examples/mushroom_safety
python run.py           # happy path
python run.py --fail    # ContractViolation → DLQ

How register() works

runtime = DeedRuntime(
    project_root=".",           # must contain deeds/ folder with .dd files
    initial_credits=100,        # starting credit balance
    named_predicates_fn=my_fn,  # optional: callable(context) -> dict[str, bool]
)

# Chain register calls
(runtime
    .register("normalize",   normalize_fn,  charge=1)
    .register("score",       score_fn,      charge=1, retry=2)
    .register("send_alert",  alert_fn,      charge=1, idempotency_key="alert_id")
)

result = runtime.run("my_pipeline", "input/state.json")

Writing .dd files

agent my_agent
  description "Does something useful"
  capabilities ["action_a", "action_b"]

  contract my_contract
    pre  input_present
    post result_generated

  policy
    cap  budget_tokens <= 3000
    deny action_b if region == "restricted"
    allow action_a if input_present
    allow action_b if input_present and not region == "restricted"

pipeline my_pipeline
  input my_input

  stage step_one
    agent my_agent
    -> action_a()
    checkpoint after
    on_error retry(2)

  stage step_two
    agent my_agent
    -> action_b()
    on_error deadletter

Error types

from deed import ContractViolation, PolicyViolation, DeedError

try:
    result = runtime.run("my_pipeline", "input/state.json")
except ContractViolation as e:
    # pre or post condition failed
    # action was NOT executed (pre) or ran but outcome invalid (post)
    print(e)
except PolicyViolation as e:
    # cap / deny / allow rule blocked the action
    # action was NOT executed, no credits charged
    print(e)

Replay

# After a failure — resume from last checkpoint
runtime = DeedRuntime(".", replay=True, initial_credits=100, ...)
runtime.register(...)  # same registrations
result = runtime.run("my_pipeline", "input/state.json")
# Completed steps are skipped, credits not re-charged

Docs

docs.deed.dev

License

MIT — Syntriq

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

deed_runtime-0.1.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

deed_runtime-0.1.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: deed_runtime-0.1.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for deed_runtime-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cb234aaaf0705e37232d85e7bc27549a6f091fe489d745fe81e53b7e62ca3314
MD5 73ad4f33c0f90e4108438ac676d57173
BLAKE2b-256 3bcdd22a53266bddb2016e7c7c8f6a1cd4693d4b0a7756587d52b49ce48f87f8

See more details on using hashes here.

File details

Details for the file deed_runtime-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: deed_runtime-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for deed_runtime-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b68c695d26af962ae2bf2d149025d55405622585630e3430827f87096c0de600
MD5 60495419536cb1f09b2aa25ac1bf6185
BLAKE2b-256 2c112ec926b422190a70ba709575663da69914451e208cd5fce76dc367fbe50c

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