ciagent 0.2.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 (48) hide show
  1. ciagent-0.2.0/.gitignore +24 -0
  2. ciagent-0.2.0/CHANGELOG.md +11 -0
  3. ciagent-0.2.0/LICENSE +201 -0
  4. ciagent-0.2.0/PKG-INFO +322 -0
  5. ciagent-0.2.0/README.md +283 -0
  6. ciagent-0.2.0/pyproject.toml +77 -0
  7. ciagent-0.2.0/src/agentci/__init__.py +78 -0
  8. ciagent-0.2.0/src/agentci/_version.py +1 -0
  9. ciagent-0.2.0/src/agentci/adapters/__init__.py +3 -0
  10. ciagent-0.2.0/src/agentci/adapters/base.py +49 -0
  11. ciagent-0.2.0/src/agentci/adapters/generic.py +7 -0
  12. ciagent-0.2.0/src/agentci/adapters/langgraph.py +97 -0
  13. ciagent-0.2.0/src/agentci/adapters/openai_agents.py +261 -0
  14. ciagent-0.2.0/src/agentci/assertions.py +494 -0
  15. ciagent-0.2.0/src/agentci/baselines.py +200 -0
  16. ciagent-0.2.0/src/agentci/capture.py +253 -0
  17. ciagent-0.2.0/src/agentci/cli.py +1027 -0
  18. ciagent-0.2.0/src/agentci/config.py +45 -0
  19. ciagent-0.2.0/src/agentci/cost.py +51 -0
  20. ciagent-0.2.0/src/agentci/diff_engine.py +293 -0
  21. ciagent-0.2.0/src/agentci/engine/__init__.py +27 -0
  22. ciagent-0.2.0/src/agentci/engine/correctness.py +241 -0
  23. ciagent-0.2.0/src/agentci/engine/cost.py +113 -0
  24. ciagent-0.2.0/src/agentci/engine/diff.py +449 -0
  25. ciagent-0.2.0/src/agentci/engine/judge.py +348 -0
  26. ciagent-0.2.0/src/agentci/engine/metrics.py +122 -0
  27. ciagent-0.2.0/src/agentci/engine/parallel.py +233 -0
  28. ciagent-0.2.0/src/agentci/engine/path.py +226 -0
  29. ciagent-0.2.0/src/agentci/engine/reporter.py +290 -0
  30. ciagent-0.2.0/src/agentci/engine/results.py +53 -0
  31. ciagent-0.2.0/src/agentci/engine/runner.py +183 -0
  32. ciagent-0.2.0/src/agentci/engine/span_assertions.py +329 -0
  33. ciagent-0.2.0/src/agentci/exceptions.py +96 -0
  34. ciagent-0.2.0/src/agentci/loader.py +106 -0
  35. ciagent-0.2.0/src/agentci/mocks.py +459 -0
  36. ciagent-0.2.0/src/agentci/models.py +336 -0
  37. ciagent-0.2.0/src/agentci/py.typed +0 -0
  38. ciagent-0.2.0/src/agentci/pytest_plugin.py +192 -0
  39. ciagent-0.2.0/src/agentci/report.py +15 -0
  40. ciagent-0.2.0/src/agentci/runner.py +192 -0
  41. ciagent-0.2.0/src/agentci/schema/__init__.py +23 -0
  42. ciagent-0.2.0/src/agentci/schema/agentci_spec.schema.json +722 -0
  43. ciagent-0.2.0/src/agentci/schema/generate_schema.py +22 -0
  44. ciagent-0.2.0/src/agentci/schema/spec_models.py +340 -0
  45. ciagent-0.2.0/src/agentci/templates/__init__.py +0 -0
  46. ciagent-0.2.0/src/agentci/templates/agentci.yaml +16 -0
  47. ciagent-0.2.0/src/agentci/templates/github_action.yml.j2 +152 -0
  48. ciagent-0.2.0/src/agentci/templates/pre_push_hook.sh.j2 +19 -0
@@ -0,0 +1,24 @@
1
+
2
+ # Python
3
+ __pycache__/
4
+ *.py[cod]
5
+ *$py.class
6
+ venv/
7
+ .venv/
8
+ env/
9
+ .env
10
+
11
+ # Distribution
12
+ dist/
13
+ build/
14
+ *.egg-info/
15
+
16
+ # IDEs
17
+ .idea/
18
+ .vscode/
19
+ *.swp
20
+ .DS_Store
21
+
22
+ # Agent CI
23
+ golden/
24
+ test_results/
@@ -0,0 +1,11 @@
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.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Initial project structure and setup.
ciagent-0.2.0/LICENSE ADDED
@@ -0,0 +1,201 @@
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 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 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 Derivative
95
+ 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 those 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
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
ciagent-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,322 @@
1
+ Metadata-Version: 2.4
2
+ Name: ciagent
3
+ Version: 0.2.0
4
+ Summary: Continuous Integration for AI Agents. Catch cost spikes and logic regressions before production.
5
+ Project-URL: Documentation, https://github.com/agentci-org/agentci#readme
6
+ Project-URL: Repository, https://github.com/agentci-org/agentci.git
7
+ Project-URL: Issues, https://github.com/agentci-org/agentci/issues
8
+ License: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: agents,ai,ci-cd,llm,regression,testing
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Framework :: Pytest
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Software Development :: Testing
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: click>=8.0
17
+ Requires-Dist: jinja2>=3.0
18
+ Requires-Dist: opentelemetry-api>=1.20
19
+ Requires-Dist: opentelemetry-sdk>=1.20
20
+ Requires-Dist: pydantic>=2.0
21
+ Requires-Dist: pytest>=7.0
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: rich>=13.0
24
+ Provides-Extra: all
25
+ Requires-Dist: agentci[anthropic,jsonschema,langgraph,openai]; extra == 'all'
26
+ Provides-Extra: anthropic
27
+ Requires-Dist: anthropic>=0.20; extra == 'anthropic'
28
+ Provides-Extra: dev
29
+ Requires-Dist: mypy; extra == 'dev'
30
+ Requires-Dist: pytest>=8.0; extra == 'dev'
31
+ Requires-Dist: ruff; extra == 'dev'
32
+ Provides-Extra: jsonschema
33
+ Requires-Dist: jsonschema>=4.0; extra == 'jsonschema'
34
+ Provides-Extra: langgraph
35
+ Requires-Dist: langgraph>=0.1; extra == 'langgraph'
36
+ Provides-Extra: openai
37
+ Requires-Dist: openai>=1.0; extra == 'openai'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # AgentCI
41
+
42
+ Trace-based regression testing for AI agents. Catch semantic drift, tool call changes, and cost spikes before production.
43
+
44
+ [![Python](https://img.shields.io/pypi/pyversions/agentci)]()
45
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)]()
46
+ [![CI](https://github.com/agentci-org/agentci/actions/workflows/ci.yml/badge.svg)]()
47
+ [![AGENTS.md](https://img.shields.io/badge/AGENTS.md-supported-blue)](AGENTS.md)
48
+
49
+ You swap `gpt-4o-mini` for `gpt-4o`. Your support bot starts routing billing questions to the wrong agent. You change a retrieval prompt. Your RAG pipeline silently skips the vector search step. You don't find out until users complain.
50
+
51
+ AgentCI records what your agent *actually did* — every tool call, LLM invocation, routing decision, and cost — then diffs it against a known-good baseline. When something drifts, you see exactly what changed.
52
+
53
+ ## See It Work
54
+
55
+ ```bash
56
+ # Run your agent's test suite — all green
57
+ $ pytest tests/ -v
58
+ ======================== test session starts =========================
59
+ tests/test_routing.py::test_billing_routes_correctly PASSED
60
+ tests/test_routing.py::test_refund_flow_tool_sequence PASSED
61
+ tests/test_routing.py::test_cost_under_budget PASSED
62
+ tests/test_rag.py::test_retrieval_step_executed PASSED
63
+ tests/test_rag.py::test_no_hallucination PASSED
64
+ ==================== 5 passed in 0.8s (mock mode) ====================
65
+
66
+ # Now change one line — swap the model
67
+ - model = "gpt-4o-mini"
68
+ + model = "gpt-4o"
69
+
70
+ # Run again — AgentCI catches the drift
71
+ $ pytest tests/test_regression.py -v
72
+ ====================== AgentCI Diff Report =======================
73
+ ⚠️ ROUTING_CHANGED "I can't log in and I'm being charged"
74
+ baseline → Account Agent
75
+ current → Billing Agent
76
+
77
+ ⚠️ COST_SPIKE "Can I get a refund?"
78
+ baseline: $0.0004 → current: $0.0025 (6.2x increase)
79
+
80
+ ✅ TOOLS_IDENTICAL [lookup_invoice, process_refund]
81
+ ✅ OUTPUT_SIMILAR cosine_similarity=0.94
82
+
83
+ SUMMARY: 1 routing change, 1 cost spike across 5 test cases
84
+ =================================================================
85
+ ```
86
+
87
+ ## Quickstart
88
+
89
+ ```bash
90
+ pip install agentguard
91
+ git clone https://github.com/agentci-org/DemoAgents.git
92
+ cd DemoAgents
93
+ make test
94
+ ```
95
+
96
+ You'll see 90+ tests pass across three demo agents — RAG, DevOps, and customer support routing — in under 2 seconds with zero API keys required.
97
+
98
+ ## What It Catches
99
+
100
+ | What went wrong | How you'd find out today | How AgentCI catches it |
101
+ |----------------|--------------------------|----------------------|
102
+ | Model swap changes routing decisions | User complaints, days later | `ROUTING_CHANGED` diff with exact before/after agents |
103
+ | Prompt edit silently skips a tool call | Manual testing, maybe | `TOOLS_CHANGED` — "vector_search was called, now it's not" |
104
+ | New model costs 6x more per query | Surprise invoice at month-end | `COST_SPIKE` with threshold alerts and `@assert_budget` |
105
+ | RAG retriever returns irrelevant docs | Hallucinated answers in prod | LLM-as-judge assertions: `assert_llm_judge("answer is relevant")` |
106
+ | Guardrail stops firing after refactor | PII leaks through to specialist agent | `guardrails_triggered` trace assertions |
107
+ | Agent responds instead of routing | Support quality drops silently | `assert_handoff_count(expected=1)` catches the missing handoff |
108
+
109
+ ## Works With Your Stack
110
+
111
+ AgentCI is framework-agnostic. Same assertions, same diff engine, same CLI — regardless of how you built your agent.
112
+
113
+ | Framework | Integration | Demo |
114
+ |-----------|------------|------|
115
+ | **OpenAI Agents SDK** | Native `AgentCITraceProcessor` — 2 lines to enable | [Support Router](https://github.com/agentci-org/DemoAgents/tree/main/examples/support-router) — multi-agent handoff with guardrails |
116
+ | **LangGraph / LangChain** | `ctx.attach_langgraph_state()` captures conditional edges and tool calls | [RAG Agent](https://github.com/agentci-org/DemoAgents/tree/main/examples/rag-agent) — retrieval + grading + generation pipeline |
117
+ | **Anthropic (raw)** | `AnthropicMocker` for zero-cost replay; native tool_use capture | [DevAgent](https://github.com/agentci-org/DemoAgents/tree/main/examples/dev-agent) — 8-tool sequential repo analysis |
118
+ | **Any Python agent** | Manual `Trace` / `Span` construction for custom frameworks | See [Core Concepts](#core-concepts) below |
119
+
120
+ All three demo agents run with **zero API keys** using AgentCI's mock system.
121
+
122
+ ## Core Concepts
123
+
124
+ ### Trace & Assert
125
+
126
+ Every agent run produces a `Trace` — a structured record of LLM calls, tool invocations, handoffs, and guardrail checks.
127
+
128
+ ```python
129
+ from agentci.models import Trace
130
+
131
+ trace = run_your_agent("I was charged twice")
132
+
133
+ # What tools did the agent call?
134
+ assert "lookup_invoice" in trace.tool_call_sequence
135
+ assert "process_refund" in trace.tool_call_sequence
136
+
137
+ # Did it route correctly?
138
+ handoffs = trace.get_handoffs()
139
+ assert handoffs[0].to_agent == "Billing Agent"
140
+
141
+ # Did it stay under budget?
142
+ assert trace.total_cost_usd < 0.01
143
+
144
+ # Did guardrails fire when they should?
145
+ assert "pii_guardrail" not in trace.guardrails_triggered
146
+ ```
147
+
148
+ ### Golden Baselines
149
+
150
+ Record a known-good trace. Diff future runs against it.
151
+
152
+ ```bash
153
+ # Record a baseline
154
+ $ agentci record --test-name "billing_flow" --output golden/
155
+
156
+ # Later, after a change, diff against it
157
+ $ agentci diff --test-name "billing_flow"
158
+
159
+ # AgentCI reports:
160
+ # TOOLS_CHANGED — vector_search was called, now it's not
161
+ # COST_SPIKE — $0.0004 → $0.0025 (6.2x)
162
+ # ROUTING_CHANGED — Account Agent → Billing Agent
163
+ ```
164
+
165
+ Or use the pytest-native approach with `assert_golden_match`:
166
+
167
+ ```python
168
+ from agentci.assertions import assert_golden_match
169
+
170
+ def test_billing_regression():
171
+ trace = run_your_agent("I was charged twice")
172
+ assert_golden_match(trace, "golden/billing_flow.json")
173
+ ```
174
+
175
+ ### Zero-Cost Testing
176
+
177
+ Mock LLM responses for deterministic, instant, free test runs.
178
+
179
+ ```python
180
+ from agentci.mocks import OpenAIMocker
181
+ from agents import set_default_openai_client
182
+
183
+ # Define a scripted sequence of tool calls + final response
184
+ mocker = OpenAIMocker([
185
+ {"tool": "transfer_to_BillingAgent", "arguments": {}},
186
+ {"tool": "lookup_invoice", "arguments": {"email": "user@test.com"}},
187
+ {"text": "I found your invoice. The duplicate charge has been refunded."}
188
+ ])
189
+
190
+ # Inject into the OpenAI Agents SDK — no API key needed
191
+ set_default_openai_client(mocker.client)
192
+
193
+ trace = run_your_agent("I was charged twice")
194
+ assert trace.tool_call_sequence == ["transfer_to_BillingAgent", "lookup_invoice"]
195
+ ```
196
+
197
+ Works the same for Anthropic:
198
+
199
+ ```python
200
+ from agentci.mocks import AnthropicMocker
201
+
202
+ mocker = AnthropicMocker([
203
+ {"tool": "search_knowledge_base", "arguments": {"query": "billing"}},
204
+ {"text": "Here's what I found about billing..."}
205
+ ])
206
+ ```
207
+
208
+ ## Try Breaking It
209
+
210
+ Clone the [DemoAgents](https://github.com/agentci-org/DemoAgents) repo and try these:
211
+
212
+ **Break 1: Remove a specialist agent.** In `examples/support-router/support_router/agents/triage.py`, remove `account_agent` from the `handoffs` list. Run `pytest tests/test_routing.py`. Watch 6 tests fail with: `ROUTING_CHANGED: Expected 'Account Agent', got 'General Agent'`.
213
+
214
+ **Break 2: Disable retrieval guardrails.** In `examples/support-router/support_router/agents/triage.py`, remove the `input_guardrails` list. Run `pytest tests/test_guardrails.py`. Watch `test_off_topic_blocked` fail: `Expected guardrail 'relevance_guardrail' to trigger, but no guardrails fired.`
215
+
216
+ **Break 3: Inject bad context.** In `examples/rag-agent/agent.py`, modify the system prompt to remove the "only answer from context" instruction. Run `pytest tests/test_rag.py`. Watch the LLM-as-judge assertion catch the hallucination: `FAILED — Agent used pre-trained knowledge instead of declining.`
217
+
218
+ ## CLI
219
+
220
+ ```bash
221
+ agentci init # Generate CI config (GitHub Actions + pre-push hooks)
222
+ agentci run # Run all tests (pytest-compatible)
223
+ agentci record # Record golden baseline traces
224
+ agentci diff # Diff current run against baseline
225
+ agentci report # Generate HTML report from results
226
+ ```
227
+
228
+ ## CI/CD
229
+
230
+ ```bash
231
+ agentci init
232
+ ```
233
+
234
+ Generates a GitHub Actions workflow and optional pre-push git hook. Every push runs your agent tests and diffs against golden baselines.
235
+
236
+ ```yaml
237
+ # .github/workflows/agentci.yml (auto-generated)
238
+ name: AgentCI
239
+ on: [push, pull_request]
240
+ jobs:
241
+ test:
242
+ runs-on: ubuntu-latest
243
+ steps:
244
+ - uses: actions/checkout@v4
245
+ - uses: actions/setup-python@v5
246
+ with:
247
+ python-version: "3.10"
248
+ - run: pip install -e ".[all]"
249
+ - run: pytest tests/ -v
250
+ - run: agentci diff --baseline golden/
251
+ ```
252
+
253
+ ## For Coding Agents
254
+
255
+ If you're a coding agent (Claude Code, Cursor, Codex, Copilot) integrating AgentCI into a project, see [`AGENTS.md`](AGENTS.md) for structured setup instructions, import patterns, and the full assertion API reference.
256
+
257
+ Quick setup for any agent project:
258
+ 1. `pip install agentguard`
259
+ 2. Copy the test template from AGENTS.md
260
+ 3. Run `agentci init` to generate CI config
261
+ 4. Run `agentci run` to execute tests
262
+
263
+ ## Assertions
264
+
265
+ | Assertion | What it checks |
266
+ |-----------|---------------|
267
+ | `trace.tool_call_sequence` | Ordered list of tool names invoked during the run |
268
+ | `trace.total_cost_usd` | Total LLM cost in USD |
269
+ | `trace.get_handoffs()` | List of agent-to-agent routing decisions |
270
+ | `trace.guardrails_triggered` | Which safety guardrails fired |
271
+ | `trace.agents_involved` | Ordered list of agent names that executed |
272
+ | `assert_golden_match(trace, path)` | Diff against a saved golden baseline |
273
+ | `evaluate_assertion(type="llm_judge")` | LLM-as-judge evaluation of output quality |
274
+ | `evaluate_assertion(type="handoff_target")` | Verify routing destination |
275
+ | `evaluate_assertion(type="handoff_count")` | Verify number of handoffs |
276
+ | `@assert_budget(max_cost=0.10)` | Decorator: fail if run exceeds cost limit |
277
+ | `evaluate_assertion(type="tool_called")` | Verify a specific tool was invoked |
278
+ | `evaluate_assertion(type="output_contains")` | Check output includes expected content |
279
+ | `evaluate_assertion(type="cost_under")` | Check total cost below threshold |
280
+
281
+ ## Diff Report Types
282
+
283
+ When you diff a current run against a golden baseline, AgentCI flags these change categories:
284
+
285
+ | Diff Type | Meaning |
286
+ |-----------|---------|
287
+ | `TOOLS_CHANGED` | Different tools were called vs. baseline |
288
+ | `ARGS_CHANGED` | Same tools, but arguments changed |
289
+ | `SEQUENCE_CHANGED` | Tools called in a different order |
290
+ | `COST_SPIKE` | Cost increased beyond threshold |
291
+ | `LATENCY_SPIKE` | Duration increased beyond threshold |
292
+ | `STOP_REASON_CHANGED` | LLM stopped for a different reason |
293
+ | `ROUTING_CHANGED` | Agent handoff went to a different target |
294
+ | `GUARDRAILS_CHANGED` | Different guardrails fired vs. baseline |
295
+ | `OUTPUT_CHANGED` | Final output semantically different |
296
+ | `AVAILABLE_HANDOFFS_CHANGED` | Set of reachable agents changed |
297
+
298
+ ## Status
299
+
300
+ AgentCI is in **early release** (v0.1.x). The core trace model, diffing engine, assertion library, mock system, and CLI are stable. The API may evolve based on community feedback.
301
+
302
+ **What's here today:**
303
+ - Trace capture for LangGraph, Anthropic, and OpenAI Agents SDK
304
+ - Golden baseline recording and regression diffing
305
+ - LLM mocking for all three frameworks (zero API keys)
306
+ - LLM-as-judge assertions for subjective output grading
307
+ - Pytest plugin for native integration
308
+ - GitHub Actions generator via `agentci init`
309
+
310
+ **What's next:**
311
+ - Dashboard UI for trace visualization
312
+ - Trace export (OpenTelemetry format)
313
+ - More framework adapters (CrewAI, AutoGen)
314
+ - MCP server for native coding agent integration
315
+ - Agent Skills distribution for auto-discovery
316
+ - Hosted regression tracking
317
+
318
+ ## Contributing
319
+
320
+ AgentCI is open source under the Apache 2.0 License. Issues, PRs, and feedback welcome.
321
+
322
+ If you build an agent and test it with AgentCI, I'd love to hear about it — open an issue or reach out.