ai-agent-contracts 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. ai_agent_contracts-0.1.0/.github/dependabot.yml +15 -0
  2. ai_agent_contracts-0.1.0/.github/workflows/ci.yml +59 -0
  3. ai_agent_contracts-0.1.0/.gitignore +234 -0
  4. ai_agent_contracts-0.1.0/.pre-commit-config.yaml +115 -0
  5. ai_agent_contracts-0.1.0/.python-version +1 -0
  6. ai_agent_contracts-0.1.0/CHANGELOG.md +51 -0
  7. ai_agent_contracts-0.1.0/LICENSE +190 -0
  8. ai_agent_contracts-0.1.0/PKG-INFO +591 -0
  9. ai_agent_contracts-0.1.0/README.md +553 -0
  10. ai_agent_contracts-0.1.0/benchmarks/README.md +203 -0
  11. ai_agent_contracts-0.1.0/benchmarks/__init__.py +1 -0
  12. ai_agent_contracts-0.1.0/benchmarks/google_adk/README.md +129 -0
  13. ai_agent_contracts-0.1.0/benchmarks/google_adk/__init__.py +1 -0
  14. ai_agent_contracts-0.1.0/benchmarks/google_adk/demo_delegation.py +483 -0
  15. ai_agent_contracts-0.1.0/benchmarks/google_adk/demo_integration.py +489 -0
  16. ai_agent_contracts-0.1.0/benchmarks/governance/README.md +258 -0
  17. ai_agent_contracts-0.1.0/benchmarks/governance/VARIANCE_ANALYSIS.md +234 -0
  18. ai_agent_contracts-0.1.0/benchmarks/governance/__init__.py +11 -0
  19. ai_agent_contracts-0.1.0/benchmarks/governance/budget_violation_test.py +512 -0
  20. ai_agent_contracts-0.1.0/benchmarks/governance/cost_governance_test.py +453 -0
  21. ai_agent_contracts-0.1.0/benchmarks/governance/variance_reduction_test.py +453 -0
  22. ai_agent_contracts-0.1.0/benchmarks/langchain/README.md +77 -0
  23. ai_agent_contracts-0.1.0/benchmarks/langchain/demo_integration.py +276 -0
  24. ai_agent_contracts-0.1.0/benchmarks/langgraph/README.md +148 -0
  25. ai_agent_contracts-0.1.0/benchmarks/langgraph/demo_integration.py +397 -0
  26. ai_agent_contracts-0.1.0/benchmarks/research_agent/FUNDAMENTAL_ISSUES.md +230 -0
  27. ai_agent_contracts-0.1.0/benchmarks/research_agent/README.md +185 -0
  28. ai_agent_contracts-0.1.0/benchmarks/research_agent/__init__.py +20 -0
  29. ai_agent_contracts-0.1.0/benchmarks/research_agent/agent.py +319 -0
  30. ai_agent_contracts-0.1.0/benchmarks/research_agent/benchmark.py +409 -0
  31. ai_agent_contracts-0.1.0/benchmarks/research_agent/contracted_agent.py +112 -0
  32. ai_agent_contracts-0.1.0/benchmarks/research_agent/evaluator.py +304 -0
  33. ai_agent_contracts-0.1.0/benchmarks/research_agent/questions.py +89 -0
  34. ai_agent_contracts-0.1.0/benchmarks/research_agent/uncontracted_agent.py +46 -0
  35. ai_agent_contracts-0.1.0/benchmarks/strategic/__init__.py +0 -0
  36. ai_agent_contracts-0.1.0/benchmarks/strategic/pareto_visualization.py +252 -0
  37. ai_agent_contracts-0.1.0/benchmarks/strategic/strategic_optimization_test.py +403 -0
  38. ai_agent_contracts-0.1.0/claude.md +313 -0
  39. ai_agent_contracts-0.1.0/docs/README.md +138 -0
  40. ai_agent_contracts-0.1.0/docs/quality_measurement_research.md +324 -0
  41. ai_agent_contracts-0.1.0/docs/testing-strategy.md +1132 -0
  42. ai_agent_contracts-0.1.0/docs/whitepaper.md +2056 -0
  43. ai_agent_contracts-0.1.0/evaluation/README.md +884 -0
  44. ai_agent_contracts-0.1.0/evaluation/__init__.py +58 -0
  45. ai_agent_contracts-0.1.0/evaluation/code_review_pipeline/RESULTS.md +229 -0
  46. ai_agent_contracts-0.1.0/evaluation/code_review_pipeline/__init__.py +33 -0
  47. ai_agent_contracts-0.1.0/evaluation/code_review_pipeline/agents.py +292 -0
  48. ai_agent_contracts-0.1.0/evaluation/code_review_pipeline/analyze_results.py +882 -0
  49. ai_agent_contracts-0.1.0/evaluation/code_review_pipeline/execution.py +387 -0
  50. ai_agent_contracts-0.1.0/evaluation/code_review_pipeline/orchestrator.py +626 -0
  51. ai_agent_contracts-0.1.0/evaluation/code_review_pipeline/run_experiment.py +448 -0
  52. ai_agent_contracts-0.1.0/evaluation/code_review_pipeline/tasks.py +241 -0
  53. ai_agent_contracts-0.1.0/evaluation/code_review_pipeline/usage_tracker.py +226 -0
  54. ai_agent_contracts-0.1.0/evaluation/good_enough/DESIGN.md +260 -0
  55. ai_agent_contracts-0.1.0/evaluation/good_enough/RESULTS.md +260 -0
  56. ai_agent_contracts-0.1.0/evaluation/good_enough/__init__.py +14 -0
  57. ai_agent_contracts-0.1.0/evaluation/good_enough/adk_agents.py +495 -0
  58. ai_agent_contracts-0.1.0/evaluation/good_enough/adk_tools.py +172 -0
  59. ai_agent_contracts-0.1.0/evaluation/good_enough/agents.py +418 -0
  60. ai_agent_contracts-0.1.0/evaluation/good_enough/analyze_crisis_results.py +579 -0
  61. ai_agent_contracts-0.1.0/evaluation/good_enough/analyze_results.py +766 -0
  62. ai_agent_contracts-0.1.0/evaluation/good_enough/email_indeterminacy_evaluator.py +583 -0
  63. ai_agent_contracts-0.1.0/evaluation/good_enough/evaluator.py +364 -0
  64. ai_agent_contracts-0.1.0/evaluation/good_enough/figures/crisis_comparison.png +0 -0
  65. ai_agent_contracts-0.1.0/evaluation/good_enough/figures/crisis_paired_differences.png +0 -0
  66. ai_agent_contracts-0.1.0/evaluation/good_enough/figures/crisis_statistics.md +29 -0
  67. ai_agent_contracts-0.1.0/evaluation/good_enough/run_adk_experiment.py +340 -0
  68. ai_agent_contracts-0.1.0/evaluation/good_enough/run_crisis_experiment.py +348 -0
  69. ai_agent_contracts-0.1.0/evaluation/good_enough/run_experiment.py +353 -0
  70. ai_agent_contracts-0.1.0/evaluation/good_enough/scenarios.py +921 -0
  71. ai_agent_contracts-0.1.0/evaluation/indeterminacy_evaluator.py +708 -0
  72. ai_agent_contracts-0.1.0/evaluation/research_pipeline/RESULTS.md +529 -0
  73. ai_agent_contracts-0.1.0/evaluation/research_pipeline/__init__.py +37 -0
  74. ai_agent_contracts-0.1.0/evaluation/research_pipeline/agents.py +403 -0
  75. ai_agent_contracts-0.1.0/evaluation/research_pipeline/analyze_results.py +1428 -0
  76. ai_agent_contracts-0.1.0/evaluation/research_pipeline/evaluator.py +195 -0
  77. ai_agent_contracts-0.1.0/evaluation/research_pipeline/figures/fig_category_breakdown.png +0 -0
  78. ai_agent_contracts-0.1.0/evaluation/research_pipeline/figures/fig_combined.png +0 -0
  79. ai_agent_contracts-0.1.0/evaluation/research_pipeline/figures/fig_correlations.png +0 -0
  80. ai_agent_contracts-0.1.0/evaluation/research_pipeline/figures/fig_efficiency_frontier.png +0 -0
  81. ai_agent_contracts-0.1.0/evaluation/research_pipeline/figures/fig_llm_quality.png +0 -0
  82. ai_agent_contracts-0.1.0/evaluation/research_pipeline/figures/fig_quality_dimensions.png +0 -0
  83. ai_agent_contracts-0.1.0/evaluation/research_pipeline/figures/fig_quality_distribution.png +0 -0
  84. ai_agent_contracts-0.1.0/evaluation/research_pipeline/figures/fig_tail_risk.png +0 -0
  85. ai_agent_contracts-0.1.0/evaluation/research_pipeline/figures/fig_tokens.png +0 -0
  86. ai_agent_contracts-0.1.0/evaluation/research_pipeline/figures/fig_web_searches.png +0 -0
  87. ai_agent_contracts-0.1.0/evaluation/research_pipeline/orchestrator.py +687 -0
  88. ai_agent_contracts-0.1.0/evaluation/research_pipeline/run_experiment.py +573 -0
  89. ai_agent_contracts-0.1.0/evaluation/research_pipeline/topics.py +1154 -0
  90. ai_agent_contracts-0.1.0/evaluation/strategy_modes/RESULTS.md +318 -0
  91. ai_agent_contracts-0.1.0/evaluation/strategy_modes/__init__.py +42 -0
  92. ai_agent_contracts-0.1.0/evaluation/strategy_modes/analyze_logic_results.py +684 -0
  93. ai_agent_contracts-0.1.0/evaluation/strategy_modes/analyze_results.py +600 -0
  94. ai_agent_contracts-0.1.0/evaluation/strategy_modes/figures/fig1a_reasoning_tokens.png +0 -0
  95. ai_agent_contracts-0.1.0/evaluation/strategy_modes/figures/fig1b_execution_time.png +0 -0
  96. ai_agent_contracts-0.1.0/evaluation/strategy_modes/figures/fig1c_rouge_quality.png +0 -0
  97. ai_agent_contracts-0.1.0/evaluation/strategy_modes/figures/fig1d_quality_vs_reasoning.png +0 -0
  98. ai_agent_contracts-0.1.0/evaluation/strategy_modes/figures/fig_logic_accuracy.png +0 -0
  99. ai_agent_contracts-0.1.0/evaluation/strategy_modes/figures/fig_logic_combined.png +0 -0
  100. ai_agent_contracts-0.1.0/evaluation/strategy_modes/figures/fig_logic_reasoning_tokens.png +0 -0
  101. ai_agent_contracts-0.1.0/evaluation/strategy_modes/figures/fig_logic_success_rate.png +0 -0
  102. ai_agent_contracts-0.1.0/evaluation/strategy_modes/figures/fig_logic_tokens.png +0 -0
  103. ai_agent_contracts-0.1.0/evaluation/strategy_modes/logic_orchestrator.py +382 -0
  104. ai_agent_contracts-0.1.0/evaluation/strategy_modes/logic_tasks.py +317 -0
  105. ai_agent_contracts-0.1.0/evaluation/strategy_modes/math_metrics.py +114 -0
  106. ai_agent_contracts-0.1.0/evaluation/strategy_modes/math_orchestrator.py +341 -0
  107. ai_agent_contracts-0.1.0/evaluation/strategy_modes/math_tasks.py +322 -0
  108. ai_agent_contracts-0.1.0/evaluation/strategy_modes/metrics.py +241 -0
  109. ai_agent_contracts-0.1.0/evaluation/strategy_modes/orchestrator.py +436 -0
  110. ai_agent_contracts-0.1.0/evaluation/strategy_modes/run_experiment.py +331 -0
  111. ai_agent_contracts-0.1.0/evaluation/strategy_modes/run_logic_experiment.py +380 -0
  112. ai_agent_contracts-0.1.0/evaluation/strategy_modes/run_math_experiment.py +381 -0
  113. ai_agent_contracts-0.1.0/evaluation/strategy_modes/run_soft_cutoff_experiment.py +258 -0
  114. ai_agent_contracts-0.1.0/evaluation/strategy_modes/tasks.py +171 -0
  115. ai_agent_contracts-0.1.0/main.py +7 -0
  116. ai_agent_contracts-0.1.0/pyproject.toml +160 -0
  117. ai_agent_contracts-0.1.0/results/code_review/figures/code_review_by_difficulty.png +0 -0
  118. ai_agent_contracts-0.1.0/results/code_review/figures/code_review_comparison.png +0 -0
  119. ai_agent_contracts-0.1.0/results/code_review/figures/code_review_token_distribution.png +0 -0
  120. ai_agent_contracts-0.1.0/results/code_review/figures/statistics.md +35 -0
  121. ai_agent_contracts-0.1.0/src/agent_contracts/__init__.py +134 -0
  122. ai_agent_contracts-0.1.0/src/agent_contracts/core/__init__.py +127 -0
  123. ai_agent_contracts-0.1.0/src/agent_contracts/core/capabilities.py +467 -0
  124. ai_agent_contracts-0.1.0/src/agent_contracts/core/contract.py +797 -0
  125. ai_agent_contracts-0.1.0/src/agent_contracts/core/delegation.py +488 -0
  126. ai_agent_contracts-0.1.0/src/agent_contracts/core/enforcement.py +351 -0
  127. ai_agent_contracts-0.1.0/src/agent_contracts/core/executor.py +606 -0
  128. ai_agent_contracts-0.1.0/src/agent_contracts/core/monitor.py +740 -0
  129. ai_agent_contracts-0.1.0/src/agent_contracts/core/planning.py +490 -0
  130. ai_agent_contracts-0.1.0/src/agent_contracts/core/prompts.py +358 -0
  131. ai_agent_contracts-0.1.0/src/agent_contracts/core/skillspec.py +237 -0
  132. ai_agent_contracts-0.1.0/src/agent_contracts/core/tokens.py +274 -0
  133. ai_agent_contracts-0.1.0/src/agent_contracts/core/wrapper.py +414 -0
  134. ai_agent_contracts-0.1.0/src/agent_contracts/integrations/__init__.py +77 -0
  135. ai_agent_contracts-0.1.0/src/agent_contracts/integrations/_token_utils.py +74 -0
  136. ai_agent_contracts-0.1.0/src/agent_contracts/integrations/google_adk.py +843 -0
  137. ai_agent_contracts-0.1.0/src/agent_contracts/integrations/langchain.py +435 -0
  138. ai_agent_contracts-0.1.0/src/agent_contracts/integrations/langgraph.py +536 -0
  139. ai_agent_contracts-0.1.0/src/agent_contracts/integrations/litellm_wrapper.py +539 -0
  140. ai_agent_contracts-0.1.0/src/agent_contracts/py.typed +2 -0
  141. ai_agent_contracts-0.1.0/src/agent_contracts/templates.py +507 -0
  142. ai_agent_contracts-0.1.0/tests/__init__.py +1 -0
  143. ai_agent_contracts-0.1.0/tests/conftest.py +48 -0
  144. ai_agent_contracts-0.1.0/tests/core/__init__.py +0 -0
  145. ai_agent_contracts-0.1.0/tests/core/test_capabilities.py +828 -0
  146. ai_agent_contracts-0.1.0/tests/core/test_capabilities_litellm.py +324 -0
  147. ai_agent_contracts-0.1.0/tests/core/test_contract.py +380 -0
  148. ai_agent_contracts-0.1.0/tests/core/test_delegation.py +545 -0
  149. ai_agent_contracts-0.1.0/tests/core/test_enforcement.py +515 -0
  150. ai_agent_contracts-0.1.0/tests/core/test_executor.py +607 -0
  151. ai_agent_contracts-0.1.0/tests/core/test_fine_grained_tokens.py +354 -0
  152. ai_agent_contracts-0.1.0/tests/core/test_monitor.py +852 -0
  153. ai_agent_contracts-0.1.0/tests/core/test_output_specification.py +299 -0
  154. ai_agent_contracts-0.1.0/tests/core/test_planning.py +531 -0
  155. ai_agent_contracts-0.1.0/tests/core/test_prompts.py +343 -0
  156. ai_agent_contracts-0.1.0/tests/core/test_temporal_monitor.py +490 -0
  157. ai_agent_contracts-0.1.0/tests/core/test_tokens.py +385 -0
  158. ai_agent_contracts-0.1.0/tests/core/test_wrapper.py +580 -0
  159. ai_agent_contracts-0.1.0/tests/evaluation/__init__.py +1 -0
  160. ai_agent_contracts-0.1.0/tests/evaluation/test_indeterminacy_evaluator.py +551 -0
  161. ai_agent_contracts-0.1.0/tests/integrations/__init__.py +0 -0
  162. ai_agent_contracts-0.1.0/tests/integrations/test_google_adk.py +565 -0
  163. ai_agent_contracts-0.1.0/tests/integrations/test_langchain.py +788 -0
  164. ai_agent_contracts-0.1.0/tests/integrations/test_langgraph.py +694 -0
  165. ai_agent_contracts-0.1.0/tests/integrations/test_litellm_wrapper.py +471 -0
  166. ai_agent_contracts-0.1.0/tests/integrations/test_token_utils.py +67 -0
  167. ai_agent_contracts-0.1.0/tests/test_templates.py +432 -0
  168. ai_agent_contracts-0.1.0/uv.lock +4496 -0
@@ -0,0 +1,15 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "pip"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ day: "monday"
8
+ open-pull-requests-limit: 10
9
+ labels:
10
+ - "dependencies"
11
+ groups:
12
+ minor-and-patch:
13
+ update-types:
14
+ - "minor"
15
+ - "patch"
@@ -0,0 +1,59 @@
1
+ name: CI and Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ release:
8
+ types: [created]
9
+ workflow_dispatch:
10
+ inputs:
11
+ run_publish:
12
+ description: 'Set to true to run the publish job'
13
+ required: false
14
+ default: 'false'
15
+
16
+ jobs:
17
+ lint:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - uses: astral-sh/setup-uv@v3
22
+ with:
23
+ enable-cache: true
24
+ cache-dependency-glob: "pyproject.toml"
25
+ - run: uv python install 3.13
26
+ - run: uv sync --all-extras --dev
27
+ - run: uv run ruff check src/ tests/
28
+ - run: uv run ruff format --check src/ tests/
29
+ - run: uv run mypy src/agent_contracts/ --strict --ignore-missing-imports
30
+
31
+ test:
32
+ runs-on: ubuntu-latest
33
+ strategy:
34
+ matrix:
35
+ python-version: ["3.12", "3.13"]
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+ - uses: astral-sh/setup-uv@v3
39
+ with:
40
+ enable-cache: true
41
+ cache-dependency-glob: "pyproject.toml"
42
+ - run: uv python install ${{ matrix.python-version }}
43
+ - run: uv sync --all-extras --dev
44
+ - run: uv run pytest --cov=agent_contracts --cov-report=term-missing
45
+
46
+ publish:
47
+ needs: [lint, test]
48
+ if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_publish == 'true')
49
+ runs-on: ubuntu-latest
50
+ permissions:
51
+ id-token: write
52
+ steps:
53
+ - uses: actions/checkout@v4
54
+ - uses: astral-sh/setup-uv@v3
55
+ with:
56
+ enable-cache: true
57
+ - run: uv python install 3.13
58
+ - run: uv build --no-sources
59
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,234 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # Markdownlint
195
+ .markdownlint-cli2.jsonc
196
+ .markdownlintrc
197
+
198
+ # PyPI configuration file
199
+ .pypirc
200
+
201
+ # Cursor
202
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
203
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
204
+ # refer to https://docs.cursor.com/context/ignore-files
205
+ .cursorignore
206
+ .cursorindexingignore
207
+
208
+ # Marimo
209
+ marimo/_static/
210
+ marimo/_lsp/
211
+ __marimo__/
212
+
213
+ # Benchmark results
214
+ benchmarks/**/results/
215
+ benchmarks/quality_validation/samples/
216
+ benchmarks/quality_validation/extended_samples/
217
+ *.png
218
+ *.pdf
219
+ paper/
220
+ .DS_Store
221
+
222
+ # Results folder (raw experiment data)
223
+ results/
224
+ # Exception: track publication figures for COINE 2026 paper
225
+ !results/code_review/
226
+ !results/code_review/figures/
227
+ !results/code_review/figures/*.png
228
+ !results/code_review/figures/*.md
229
+ !results/research_pipeline/
230
+ !results/research_pipeline/figures/
231
+ !results/research_pipeline/figures/*.png
232
+ !results/research_pipeline/figures/*.md
233
+ # Also allow evaluation figures
234
+ !evaluation/**/figures/*.png
@@ -0,0 +1,115 @@
1
+ # Pre-commit hooks for agent-contracts
2
+ # See https://pre-commit.com for more information
3
+ # See https://pre-commit.com/hooks.html for more hooks
4
+
5
+ repos:
6
+ # uv-specific hooks
7
+ - repo: https://github.com/astral-sh/uv-pre-commit
8
+ # uv version
9
+ rev: 0.10.12
10
+ hooks:
11
+ # Update uv.lock when pyproject.toml changes
12
+ - id: uv-lock
13
+ name: uv-lock
14
+
15
+ # Ruff - Fast Python linter and formatter (replaces black, isort, flake8, etc.)
16
+ - repo: https://github.com/astral-sh/ruff-pre-commit
17
+ rev: v0.15.7
18
+ hooks:
19
+ # Run the linter
20
+ - id: ruff
21
+ args: [--fix]
22
+ name: ruff-lint
23
+ # Run the formatter
24
+ - id: ruff-format
25
+ name: ruff-format
26
+
27
+ # Type checking with mypy (uses project venv via uv for consistent behavior with CI)
28
+ - repo: local
29
+ hooks:
30
+ - id: mypy
31
+ name: mypy-type-check
32
+ entry: uv run mypy --strict --ignore-missing-imports
33
+ language: system
34
+ types: [python]
35
+ files: ^src/agent_contracts/
36
+ exclude: ^(tests/|examples/)
37
+ pass_filenames: false
38
+ args: [src/agent_contracts/]
39
+
40
+ # General file quality checks
41
+ - repo: https://github.com/pre-commit/pre-commit-hooks
42
+ rev: v6.0.0
43
+ hooks:
44
+ # Validate Python syntax
45
+ - id: check-ast
46
+ name: check-ast
47
+ # Remove trailing whitespace
48
+ - id: trailing-whitespace
49
+ name: trailing-whitespace
50
+ # Ensure files end with newline
51
+ - id: end-of-file-fixer
52
+ name: end-of-file-fixer
53
+ # Check YAML file syntax
54
+ - id: check-yaml
55
+ name: check-yaml
56
+ # Check for accidentally committed merge conflict markers
57
+ - id: check-merge-conflict
58
+ name: check-merge-conflict
59
+ # Prevent committing large files
60
+ - id: check-added-large-files
61
+ name: check-added-large-files
62
+ args: [--maxkb=1000]
63
+ # Check for files that would conflict on case-insensitive filesystems
64
+ - id: check-case-conflict
65
+ name: check-case-conflict
66
+ # Check JSON file syntax
67
+ - id: check-json
68
+ name: check-json
69
+ # Check TOML file syntax
70
+ - id: check-toml
71
+ name: check-toml
72
+ # Prevent committing private keys
73
+ - id: detect-private-key
74
+ name: detect-private-key
75
+
76
+ # Markdown linting
77
+ - repo: https://github.com/igorshubovych/markdownlint-cli
78
+ rev: v0.48.0
79
+ hooks:
80
+ - id: markdownlint
81
+ name: markdownlint
82
+ args: [--fix, --disable, MD013, MD033, MD041]
83
+ # MD013: Line length (disabled - many code blocks)
84
+ # MD033: Inline HTML (disabled - we use HTML in docs)
85
+ # MD041: First line in file should be a top level heading (disabled)
86
+
87
+ # Configuration for pre-commit itself
88
+ default_language_version:
89
+ python: python3.12
90
+
91
+ # Exclude certain files/directories
92
+ exclude: |
93
+ (?x)^(
94
+ \.git/.*|
95
+ \.venv/.*|
96
+ __pycache__/.*|
97
+ \.pytest_cache/.*|
98
+ \.mypy_cache/.*|
99
+ \.ruff_cache/.*|
100
+ dist/.*|
101
+ build/.*
102
+ )$
103
+
104
+ # CI configuration
105
+ ci:
106
+ autofix_commit_msg: |
107
+ [pre-commit.ci] auto fixes from pre-commit hooks
108
+
109
+ for more information, see https://pre-commit.ci
110
+ autofix_prs: true
111
+ autoupdate_branch: ''
112
+ autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
113
+ autoupdate_schedule: weekly
114
+ skip: []
115
+ submodules: false
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,51 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-03-26
11
+
12
+ Initial public release. A formal framework for governing autonomous AI agents through
13
+ explicit resource constraints and temporal boundaries.
14
+
15
+ ### Added
16
+
17
+ **Core Framework**
18
+ - Contract data structures (C = I, O, S, R, T, Phi, Psi)
19
+ - ResourceConstraints: tokens, API calls, cost, iterations, per-tool limits
20
+ - TemporalConstraints: deadlines, max duration, soft/hard deadline types
21
+ - Resource monitoring with real-time tracking (thread-safe)
22
+ - Constraint enforcement with strict/lenient modes and callbacks
23
+ - Contract delegation with conservation laws
24
+ - Strategic contract modes (URGENT, ECONOMICAL, BALANCED)
25
+ - Budget-aware prompt generation
26
+
27
+ **Integrations**
28
+ - LiteLLM integration (100+ LLM providers)
29
+ - LangChain integration with multi-call budget protection
30
+ - LangGraph integration with cycle/loop protection
31
+ - Google ADK integration
32
+
33
+ **Extensions**
34
+ - SkillSpec: agentskills.io standard for reusable agent behaviors
35
+ - Per-tool resource limits (fine-grained control per tool name)
36
+ - Indeterminacy-aware LLM-as-Judge evaluator (NeurIPS 2025 framework)
37
+ - Research and Code Review evaluation pipelines
38
+
39
+ **Infrastructure**
40
+ - CI: linting (ruff), type checking (mypy), Python 3.12/3.13 matrix
41
+ - 609+ tests, 91%+ coverage
42
+ - Shared test fixtures in `tests/conftest.py`
43
+ - Shared token extraction utilities for integrations (`_token_utils.py`)
44
+ - LICENSE file (Apache-2.0)
45
+
46
+ ### Changed
47
+ - License changed from CC-BY-4.0 (paper) to Apache-2.0 (software)
48
+ - PyPI package name: `ai-agent-contracts` (the name `agent-contracts` was already taken)
49
+
50
+ [Unreleased]: https://github.com/flyersworder/agent-contracts/compare/v0.1.0...HEAD
51
+ [0.1.0]: https://github.com/flyersworder/agent-contracts/releases/tag/v0.1.0
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 Qing Ye
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.