Skip to content

feat: v0.1.1 — adapters, preconditions, GitHub Action#1

Merged
pyyush merged 6 commits intomainfrom
feat/v0.1.1-adapters-preconditions
Mar 26, 2026
Merged

feat: v0.1.1 — adapters, preconditions, GitHub Action#1
pyyush merged 6 commits intomainfrom
feat/v0.1.1-adapters-preconditions

Conversation

@pyyush
Copy link
Copy Markdown
Owner

@pyyush pyyush commented Mar 26, 2026

Summary

  • Precondition evaluationinputs.preconditions[] evaluated on input BEFORE agent runs. Reuses CEL-like expression evaluator. PreconditionError blocks execution before tokens are spent. Wired into ContractEnforcer.check_preconditions() and @enforce_contract decorator.
  • OpenAI Agents SDK adapterContractRunHooks(RunHooks) for effect gating via on_tool_start, token tracking via on_llm_end, postcondition evaluation via on_agent_end. Pinned to openai-agents==0.8.4.
  • Claude Agent SDK adapterContractHooks with structured deny via PreToolUse (not exception). Cost/token extraction from ResultMessage. Pinned to claude-agent-sdk==0.1.50 (Python 3.10+).
  • GitHub Actionpyyush/agentcontracts@v0.1.1 composite action for CI contract validation.
  • README badges — PyPI version and CI status.
  • 35 new tests (188 total), lint clean.

Stats

15 files changed, 795 insertions, 3 deletions.

Test plan

  • 188 tests pass (pytest)
  • Ruff lint clean
  • Quality review fixes applied (narrow exception catch, asyncio.run, deduplicated action)

🤖 Generated with Claude Code

pyyush and others added 6 commits March 26, 2026 13:41
Reuses the same CEL-like expression evaluator as postconditions.
PreconditionError raised on failure blocks execution before tokens
are spent. Wired into ContractEnforcer.check_preconditions() and
the @enforce_contract decorator.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
RunHooks implementation for effect gating (on_tool_start), token
tracking (on_llm_end), and postcondition evaluation (on_agent_end).
Pinned to openai-agents==0.8.4.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PreToolUse hook returns structured deny for unauthorized tools (not
exception — matches Claude SDK convention). PostToolUse observes
completion. track_result() extracts cost/tokens from ResultMessage.
Pinned to claude-agent-sdk==0.1.50 (Python 3.10+).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 new tests covering precondition evaluation, enforcer integration,
OpenAI RunHooks lifecycle (tool blocking, token tracking, postconditions),
and Claude hooks (structured deny, budget tracking, result tracking).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add action.yml composite action for CI contract validation.
Add PyPI/CI badges to README. Add OpenAI/Claude adapter examples.
Pin openai-agents==0.8.4 and claude-agent-sdk==0.1.50 as optional
deps. Bump version to 0.1.1. Update CHANGELOG.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ate action

- on_agent_end: catch ContractViolation instead of broad Exception
- Tests: replace deprecated get_event_loop().run_until_complete with asyncio.run
- action.yml: capture validate output once instead of running command twice

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pyyush pyyush merged commit 3a9bcf4 into main Mar 26, 2026
5 checks passed
@pyyush pyyush deleted the feat/v0.1.1-adapters-preconditions branch March 26, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant