agent-canary 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 (67) hide show
  1. agent_canary-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +21 -0
  2. agent_canary-0.1.0/.github/ISSUE_TEMPLATE/check_not_seen.md +25 -0
  3. agent_canary-0.1.0/.github/ISSUE_TEMPLATE/false_positive.md +25 -0
  4. agent_canary-0.1.0/.github/ISSUE_TEMPLATE/missing_detection.md +25 -0
  5. agent_canary-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +11 -0
  6. agent_canary-0.1.0/.github/workflows/ci.yml +20 -0
  7. agent_canary-0.1.0/.gitignore +27 -0
  8. agent_canary-0.1.0/AGENTS.md +36 -0
  9. agent_canary-0.1.0/CHANGELOG.md +11 -0
  10. agent_canary-0.1.0/CONTRIBUTING.md +37 -0
  11. agent_canary-0.1.0/LICENSE +190 -0
  12. agent_canary-0.1.0/PKG-INFO +162 -0
  13. agent_canary-0.1.0/README.md +140 -0
  14. agent_canary-0.1.0/SECURITY.md +22 -0
  15. agent_canary-0.1.0/docs/ANALYSIS.md +96 -0
  16. agent_canary-0.1.0/docs/LAUNCH.md +133 -0
  17. agent_canary-0.1.0/docs/METHODOLOGY.md +43 -0
  18. agent_canary-0.1.0/docs/REPO_STRUCTURE.md +96 -0
  19. agent_canary-0.1.0/examples/agent-canary.yml +171 -0
  20. agent_canary-0.1.0/examples/demo_agent/__init__.py +0 -0
  21. agent_canary-0.1.0/examples/demo_agent/tools.py +53 -0
  22. agent_canary-0.1.0/examples/toolcalls.skyvern.yaml +46 -0
  23. agent_canary-0.1.0/pyproject.toml +46 -0
  24. agent_canary-0.1.0/src/agent_canary/__init__.py +3 -0
  25. agent_canary-0.1.0/src/agent_canary/__main__.py +7 -0
  26. agent_canary-0.1.0/src/agent_canary/analyzer/__init__.py +1 -0
  27. agent_canary-0.1.0/src/agent_canary/analyzer/checks.py +87 -0
  28. agent_canary-0.1.0/src/agent_canary/analyzer/guards.py +71 -0
  29. agent_canary-0.1.0/src/agent_canary/analyzer/scenarios.py +210 -0
  30. agent_canary-0.1.0/src/agent_canary/cli.py +258 -0
  31. agent_canary-0.1.0/src/agent_canary/models.py +62 -0
  32. agent_canary-0.1.0/src/agent_canary/reporter/__init__.py +1 -0
  33. agent_canary-0.1.0/src/agent_canary/reporter/json_report.py +34 -0
  34. agent_canary-0.1.0/src/agent_canary/reporter/markdown.py +134 -0
  35. agent_canary-0.1.0/src/agent_canary/reporter/registry.py +241 -0
  36. agent_canary-0.1.0/src/agent_canary/reporter/terminal.py +335 -0
  37. agent_canary-0.1.0/src/agent_canary/scanner/__init__.py +1 -0
  38. agent_canary-0.1.0/src/agent_canary/scanner/ast_scanner.py +656 -0
  39. agent_canary-0.1.0/src/agent_canary/scanner/patterns.py +663 -0
  40. agent_canary-0.1.0/src/agent_canary/scanner/yaml_scanner.py +199 -0
  41. agent_canary-0.1.0/tests/__init__.py +0 -0
  42. agent_canary-0.1.0/tests/fixtures/agent_calls.py +41 -0
  43. agent_canary-0.1.0/tests/fixtures/checked_ok_agent/tools.py +34 -0
  44. agent_canary-0.1.0/tests/fixtures/crewai_agent/__init__.py +1 -0
  45. agent_canary-0.1.0/tests/fixtures/crewai_agent/agent.py +51 -0
  46. agent_canary-0.1.0/tests/fixtures/crewai_agent/support_tools.py +62 -0
  47. agent_canary-0.1.0/tests/fixtures/dynamic_code.py +26 -0
  48. agent_canary-0.1.0/tests/fixtures/false_positives.py +28 -0
  49. agent_canary-0.1.0/tests/fixtures/false_positives_drop.py +19 -0
  50. agent_canary-0.1.0/tests/fixtures/false_positives_short_substring.py +25 -0
  51. agent_canary-0.1.0/tests/fixtures/fastapi_depends.py +56 -0
  52. agent_canary-0.1.0/tests/fixtures/langgraph_agent/__init__.py +1 -0
  53. agent_canary-0.1.0/tests/fixtures/langgraph_agent/tools.py +86 -0
  54. agent_canary-0.1.0/tests/fixtures/langgraph_agent/workflows.py +26 -0
  55. agent_canary-0.1.0/tests/fixtures/llm_calls.py +36 -0
  56. agent_canary-0.1.0/tests/fixtures/nested_test_dir/tests/utils/helpers.py +7 -0
  57. agent_canary-0.1.0/tests/fixtures/production_like/editor.py +12 -0
  58. agent_canary-0.1.0/tests/fixtures/production_like/tasks.py +19 -0
  59. agent_canary-0.1.0/tests/fixtures/raw_python_agent/__init__.py +1 -0
  60. agent_canary-0.1.0/tests/fixtures/raw_python_agent/agent_tools.py +121 -0
  61. agent_canary-0.1.0/tests/fixtures/raw_python_agent/services.py +60 -0
  62. agent_canary-0.1.0/tests/test_analyzer.py +209 -0
  63. agent_canary-0.1.0/tests/test_cli.py +108 -0
  64. agent_canary-0.1.0/tests/test_false_positives.py +958 -0
  65. agent_canary-0.1.0/tests/test_registry.py +212 -0
  66. agent_canary-0.1.0/tests/test_reporter.py +160 -0
  67. agent_canary-0.1.0/tests/test_scanner.py +443 -0
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: Bug report
3
+ about: Something isn't working correctly
4
+ labels: bug
5
+ ---
6
+
7
+ ## Describe the bug
8
+
9
+ ## To reproduce
10
+
11
+ ```bash
12
+ agent-canary [command you ran]
13
+ ```
14
+
15
+ ## Expected behavior
16
+
17
+ ## Environment
18
+
19
+ * agent-canary version:
20
+ * Python version:
21
+ * OS:
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: Check not recognized
3
+ about: A protection exists but agent-canary doesn't see it
4
+ labels: check-not-seen
5
+ ---
6
+
7
+ ## Function flagged as "no checks" or "partial checks"
8
+
9
+ **Function name**:
10
+ **File**:
11
+ **Line**:
12
+
13
+ ## The check that exists
14
+
15
+ (describe where the protection is: in the same function, in a decorator, in function parameters, in a middleware, in an API gateway, etc.)
16
+
17
+ ## Code snippet
18
+
19
+ ```python
20
+ (paste the function code AND the check code, even if in different files)
21
+ ```
22
+
23
+ ## Notes
24
+
25
+ If the check is in a different file (middleware, gateway), the correct resolution is `# checked:ok — protected by [where]` in your source code. This issue template is for checks that ARE in the same function scope but agent-canary doesn't detect them.
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: False positive
3
+ about: A function flagged that shouldn't be
4
+ labels: false-positive
5
+ ---
6
+
7
+ ## Function flagged
8
+
9
+ **Function name**:
10
+ **File**:
11
+ **Line**:
12
+
13
+ ## What agent-canary detected
14
+
15
+ (paste the terminal output for this function)
16
+
17
+ ## Why it's a false positive
18
+
19
+ (explain why this function doesn't actually change the real world, or why the detected "effect" is not a real side effect)
20
+
21
+ ## Code snippet
22
+
23
+ ```python
24
+ (paste the function code)
25
+ ```
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: Missing detection
3
+ about: A tool call that should be detected but isn't
4
+ labels: missing-detection
5
+ ---
6
+
7
+ ## Function missed
8
+
9
+ **Function name**:
10
+ **File**:
11
+ **Line**:
12
+
13
+ ## What it does
14
+
15
+ (describe the real-world effect: DB write, payment, email, etc.)
16
+
17
+ ## Code snippet
18
+
19
+ ```python
20
+ (paste the function code)
21
+ ```
22
+
23
+ ## Expected detection
24
+
25
+ (what category should it be: database_write, payment, http_write, etc.)
@@ -0,0 +1,11 @@
1
+ ## What this PR does
2
+
3
+ ## Related issue
4
+
5
+ Fixes #
6
+
7
+ ## Checklist
8
+
9
+ - [ ] Tests added for new patterns/features
10
+ - [ ] All tests pass (`python -m pytest tests/`)
11
+ - [ ] No new external dependencies added to core
@@ -0,0 +1,20 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+ branches: [main]
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ matrix:
13
+ python-version: ["3.10", "3.11", "3.12"]
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: ${{ matrix.python-version }}
19
+ - run: pip install -e ".[dev]"
20
+ - run: python -m pytest tests/ -v
@@ -0,0 +1,27 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .eggs/
8
+ *.egg
9
+ .pytest_cache/
10
+ .mypy_cache/
11
+ .venv/
12
+ venv/
13
+ env/
14
+ .env
15
+ *.so
16
+ .coverage
17
+ htmlcov/
18
+
19
+ # Internal research data
20
+ data/
21
+ *report*.json
22
+
23
+ # Claude Code session
24
+ .claude/
25
+
26
+ # OS
27
+ .DS_Store
@@ -0,0 +1,36 @@
1
+ # AGENTS.md — for AI coding assistants
2
+
3
+ ## What this repo is
4
+
5
+ agent-canary is a static analysis tool that scans Python codebases for tool calls (functions that change the real world: payments, database writes, HTTP calls, emails) and checks whether safety checks exist around them.
6
+
7
+ ## Architecture
8
+
9
+ - `src/agent_canary/scanner/` — AST visitor that detects effects and checks
10
+ - `src/agent_canary/scanner/patterns.py` — catalogue of all known patterns (data, not logic)
11
+ - `src/agent_canary/analyzer/` — computes verdict (UNGUARDED / PARTIALLY_GUARDED / GUARDED / LOW_RISK) and missing check hints
12
+ - `src/agent_canary/reporter/` — terminal, markdown, JSON, YAML registry outputs
13
+ - `src/agent_canary/models.py` — dataclasses: SideEffect, Guard, Tool, Scenario, ScanResult
14
+ - `src/agent_canary/cli.py` — argparse CLI entry point
15
+
16
+ ## Key design decisions
17
+
18
+ - **AST, not regex.** We parse Python source with the stdlib `ast` module. Regex would miss nested calls and produce false positives on strings/comments.
19
+ - **stdlib only.** Zero required dependencies. `rich` is optional for terminal color, `pyyaml` for YAML output.
20
+ - **No inter-procedural analysis.** Each function is analyzed in isolation. This limits depth but keeps the scanner fast and predictable.
21
+ - **Effects and checks, not risk scores.** The scanner reports what it sees. It does not assign severity or suggest fixes.
22
+
23
+ ## Running tests
24
+
25
+ ```bash
26
+ PYTHONPATH=src python -m pytest tests/ -v
27
+ ```
28
+
29
+ 201 tests. All must pass before merge.
30
+
31
+ ## Conventions
32
+
33
+ - Python 3.10+
34
+ - `from __future__ import annotations` in all source files
35
+ - No external dependencies in core scanner
36
+ - Patterns are data in `patterns.py`, not logic scattered across the codebase
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — 2026-03-23
4
+
5
+ Initial release.
6
+
7
+ - AST scanner detecting 11 effect categories and 7 check types in Python agents
8
+ - Terminal, Markdown, JSON, and YAML registry output formats
9
+ - `--fail-on-unchecked` CI gate (alias: `--fail-on-unguarded`) with baseline support
10
+ - `# checked:ok` inline annotation for acknowledged tool calls
11
+ - Benchmarked on Skyvern (382 findings), SurfSense (319), FinRobot (27)
@@ -0,0 +1,37 @@
1
+ # Contributing to agent-canary
2
+
3
+ ## Quick start
4
+
5
+ ```bash
6
+ git clone https://github.com/Diplomat-agents/agent-canary.git
7
+ cd agent-canary
8
+ pip install -e ".[dev]"
9
+ python -m pytest tests/
10
+ ```
11
+
12
+ ## How to contribute
13
+
14
+ ### Report a false positive
15
+
16
+ The most valuable contribution. Open an issue using the "False positive" template with the function code and the incorrect detection.
17
+
18
+ ### Report a missing tool call
19
+
20
+ If agent-canary misses a function that changes the real world, open an issue with the "Missing detection" template.
21
+
22
+ ### Add a pattern
23
+
24
+ Patterns are in `src/agent_canary/scanner/patterns.py`. Each pattern needs a test fixture in `tests/fixtures/` and a test in `tests/`.
25
+
26
+ ## Code style
27
+
28
+ * No external dependencies in core (stdlib only)
29
+ * `rich` and `pyyaml` are optional
30
+ * Run `python -m pytest tests/` before submitting
31
+
32
+ ## Pull request process
33
+
34
+ 1. Fork and create a branch from `main`
35
+ 2. Add tests for new patterns
36
+ 3. Ensure all tests pass
37
+ 4. Open a PR with a clear description
@@ -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 2026 Diplomat Services SAS
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.
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-canary
3
+ Version: 0.1.0
4
+ Summary: Scan your agentic codebase for unguarded tool calls with real-world side effects
5
+ Project-URL: Homepage, https://github.com/Diplomat-agents/agent-canary
6
+ Project-URL: Repository, https://github.com/Diplomat-agents/agent-canary
7
+ License: Apache-2.0
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.9
10
+ Provides-Extra: all
11
+ Requires-Dist: pyyaml>=6.0; extra == 'all'
12
+ Requires-Dist: rich>=13.0; extra == 'all'
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=8.0; extra == 'dev'
15
+ Requires-Dist: pyyaml>=6.0; extra == 'dev'
16
+ Requires-Dist: ruff>=0.4; extra == 'dev'
17
+ Provides-Extra: rich
18
+ Requires-Dist: rich>=13.0; extra == 'rich'
19
+ Provides-Extra: yaml
20
+ Requires-Dist: pyyaml>=6.0; extra == 'yaml'
21
+ Description-Content-Type: text/markdown
22
+
23
+ ![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue) ![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-green) ![Dependencies: 0](https://img.shields.io/badge/dependencies-0-brightgreen)
24
+
25
+ # agent-canary
26
+
27
+ Your agent can send emails, delete database rows, and charge credit cards — do you know which of those calls have no validation around them?
28
+
29
+ agent-canary scans your Python codebase and maps every function that can change the real world. For each one, it tells you what safety checks exist — and what's missing.
30
+
31
+ ```
32
+ $ agent-canary ./skyvern/
33
+ 382 tool calls · 307 with no checks · 66 partial · 9 confirmed
34
+
35
+ ⚠ terminate .../script_skyvern_page.py:868
36
+ actions:
37
+ shutil.rmtree(temp_dir)
38
+ os.kill(pid, signal.SIGTERM)
39
+ checks: none
40
+
41
+ ⚠ _analyze_gmail_messages .../composio_gmail_connector.py:228
42
+ actions:
43
+ session.execute(insert(messages))
44
+ checks: none
45
+ → no auth check · no rate limit · no idempotency key
46
+
47
+ ~ session_create .../browser.py:126
48
+ actions:
49
+ db.add(browser_session)
50
+ db.commit()
51
+ checks:
52
+ if not current_user: raise HTTPException(403)
53
+ → no rate limit
54
+
55
+ ✓ _get_or_create_browser_state .../script_skyvern_page.py:81 [idempotency: full]
56
+ ```
57
+
58
+ ## The problem
59
+
60
+ Your agent calls `stripe.Refund.create`, `session.commit`, `requests.post` — and nothing stops it from doing so twice, without auth, or with unbounded parameters. 1,075 GitHub issues across LangGraph, CrewAI, AutoGen, and OpenAI Agents SDK document tool calls executing multiple times without idempotency. 307 of 382 tool calls in Skyvern have no checks at all.
61
+
62
+ ## What it does
63
+
64
+ Scans your Python source with AST analysis. No network calls. No config. No dependencies. Finds every function that triggers a real-world action (DB write, payment, email, API call, LLM invocation, file delete) and checks whether protections exist (auth, rate limit, validation, idempotency, retry bounds).
65
+
66
+ ## Quickstart
67
+
68
+ ```bash
69
+ pip install agent-canary
70
+ agent-canary ./my_agent/
71
+ ```
72
+
73
+ Output in < 2 seconds. Zero dependencies. Try it on the included demo:
74
+
75
+ ```bash
76
+ agent-canary examples/demo_agent/
77
+ ```
78
+
79
+ ## What gets flagged
80
+
81
+ | Tool call | Why it's flagged |
82
+ |-----------|-----------------|
83
+ | `stripe.Refund.create(amount=amount)` | No bounds on `amount`, no rate limit, no idempotency key |
84
+ | `session.commit()` in an agent tool | No auth check before the write |
85
+ | `openai.chat.completions.create()` in a retry loop | No `max_retries` or `stop_after_attempt` — unbounded LLM spend |
86
+
87
+ ## CI integration
88
+
89
+ ```yaml
90
+ - run: pip install agent-canary
91
+ - run: agent-canary . --fail-on-unchecked --output-registry toolcalls.yaml
92
+ ```
93
+
94
+ Exit code 1 if any new tool call has no checks. Existing unguarded calls are visible but don't block CI until you address them.
95
+
96
+ ## The registry
97
+
98
+ ```bash
99
+ agent-canary . --format registry > toolcalls.yaml
100
+ ```
101
+
102
+ Generates a YAML inventory of every tool call, its checks, and what's missing. Commit it to your repo. Diff it on PRs. Each entry can be signed off with `# checked:ok` — creating an auditable record of who reviewed what.
103
+
104
+ This is what no other tool produces: a versionable, diffable artifact that tracks your agent's entire impact surface over time. See [`examples/toolcalls.skyvern.yaml`](examples/toolcalls.skyvern.yaml) for a real excerpt.
105
+
106
+ ## Benchmarked on real projects
107
+
108
+ | Project | Stars | Tool calls | Unguarded | Time |
109
+ |---------|------:|----------:|-----------:|-----:|
110
+ | [Skyvern](https://github.com/Skyvern-AI/skyvern) | 20.9k | 382 | 307 (80%) | ~2s |
111
+ | [SurfSense](https://github.com/MODSetter/SurfSense) | 13.3k | 319 | 169 (53%) | 1.4s |
112
+ | [FinRobot](https://github.com/AI4Finance-Foundation/FinRobot) | 6.5k | 27 | 18 (67%) | <1s |
113
+
114
+ ## How to resolve findings
115
+
116
+ | Action | How |
117
+ |--------|-----|
118
+ | **Fix** | Add validation in code. The next scan picks it up. |
119
+ | **Acknowledge** | Add `# checked:ok` as a comment on the function. |
120
+ | **Protected elsewhere** | Add `# checked:ok — protected by [middleware/gateway/etc]` |
121
+
122
+ ## What it detects
123
+
124
+ **Tool calls:** `session.commit`, `db.add`, `stripe.Refund.create`, `requests.post`, `send_mail`, `openai.chat.completions.create`, `exec()`, `s3.put_object`, `os.remove`, `shutil.rmtree`
125
+
126
+ **Checks:** `Depends()` / `Security()` (FastAPI), `@login_required`, `@rate_limit`, `get_or_create`, `Field(le=, ge=)`, `max_retries=`, `confirm` / `approve` in function body
127
+
128
+ ## Limitations
129
+
130
+ - **Import aliases** — `import requests as req` then `req.post()` is not detected
131
+ - **Cross-function analysis** — if the check is in the caller and the effect is in the callee, not detected
132
+ - **Python only** — TypeScript planned
133
+
134
+ ## Why this exists
135
+
136
+ We analyzed 3,047 GitHub issues across LangGraph, CrewAI, AutoGen, OpenAI Agents SDK, Claude Code, and Vercel AI SDK. 737 directly document tool calls executing without checks — duplicate executions, missing rate limits, loops without bounds, payments without validation.
137
+
138
+ The most common pattern (1,075 issues): a tool call that executes multiple times when it should execute once. The cause: no idempotency, no rate limit, no circuit breaker in the code around the tool.
139
+
140
+ agent-canary doesn't fix these problems. It makes them visible.
141
+
142
+ See [methodology](docs/METHODOLOGY.md) for data sources and classification criteria.
143
+
144
+ ## Configuration
145
+
146
+ For dynamic tools (MCP servers, plugins), create an `agent-canary.yml`:
147
+
148
+ ```yaml
149
+ tools:
150
+ - name: search_web
151
+ effects: [http_write]
152
+ - name: send_slack
153
+ effects: [messaging]
154
+ ```
155
+
156
+ ## License
157
+
158
+ Apache-2.0
159
+
160
+ ---
161
+
162
+ Built by the team behind Diplomat — runtime governance for AI agents.