zenofagents 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,32 @@
1
+ """The Zen of Agents. Like ``import this``, importing prints the principles.
2
+
3
+ Set the environment variable ZENOFAGENTS_QUIET=1 to import without printing,
4
+ e.g. when using ``zenofagents.PRINCIPLES`` as data.
5
+ """
6
+
7
+ import os
8
+ import sys
9
+
10
+ from .principles import PRINCIPLES, THEMES, Principle, by_theme, get
11
+ from .render import concise as _concise
12
+
13
+ __version__ = "0.1.0"
14
+ __author__ = "Anuj Sadani"
15
+ __all__ = ["PRINCIPLES", "THEMES", "Principle", "by_theme", "get", "ZEN_CONCISE"]
16
+
17
+ ZEN_CONCISE = _concise()
18
+
19
+
20
+ def _running_cli() -> bool:
21
+ # `zenofagents ...` console script, or `python -m zenofagents ...`: the CLI prints instead.
22
+ if os.path.basename(sys.argv[0] or "").split(".")[0] == "zenofagents":
23
+ return True
24
+ orig = sys.orig_argv
25
+ if "-m" in orig:
26
+ i = orig.index("-m")
27
+ return i + 1 < len(orig) and orig[i + 1] == "zenofagents"
28
+ return False
29
+
30
+
31
+ if not os.environ.get("ZENOFAGENTS_QUIET") and not _running_cli():
32
+ print(ZEN_CONCISE)
@@ -0,0 +1,48 @@
1
+ """Command line: ``zenofagents`` or ``python -m zenofagents``."""
2
+
3
+ import argparse
4
+ import random
5
+ import sys
6
+
7
+ from . import __version__
8
+ from . import render
9
+ from .principles import PRINCIPLES, get
10
+
11
+
12
+ def main(argv=None) -> int:
13
+ parser = argparse.ArgumentParser(prog="zenofagents", description="The Zen of Agents.")
14
+ mode = parser.add_mutually_exclusive_group()
15
+ mode.add_argument("-v", "--verbose", action="store_true", help="principles with explanations")
16
+ mode.add_argument("-e", "--examples", action="store_true", help="verbose, plus a do/don't example for each")
17
+ mode.add_argument("-t", "--themes", action="store_true", help="grouped by theme: scope, autonomy, oversight, delegation")
18
+ mode.add_argument("-n", "--number", type=int, metavar="N", help="show one principle in full (1-%d)" % len(PRINCIPLES))
19
+ mode.add_argument("-r", "--random", action="store_true", help="one random principle, e.g. for a daily reminder")
20
+ mode.add_argument("--checklist", action="store_true", help="Markdown checklist for PR templates or AGENTS.md")
21
+ mode.add_argument("--json", action="store_true", help="machine-readable output")
22
+ parser.add_argument("--version", action="version", version="zenofagents " + __version__)
23
+ args = parser.parse_args(argv)
24
+
25
+ if args.verbose:
26
+ out = render.verbose()
27
+ elif args.examples:
28
+ out = render.verbose(examples=True)
29
+ elif args.themes:
30
+ out = render.themed()
31
+ elif args.checklist:
32
+ out = render.checklist()
33
+ elif args.json:
34
+ out = render.as_json()
35
+ elif args.number is not None or args.random:
36
+ try:
37
+ p = random.choice(PRINCIPLES) if args.random else get(args.number)
38
+ except KeyError:
39
+ parser.error("principle number must be 1-%d" % len(PRINCIPLES))
40
+ out = "%d. %s\n %s\n Do: %s\n Don't: %s" % (p.number, p.text, p.explanation, p.do, p.dont)
41
+ else:
42
+ out = render.concise()
43
+ print(out)
44
+ return 0
45
+
46
+
47
+ if __name__ == "__main__":
48
+ sys.exit(main())
@@ -0,0 +1,124 @@
1
+ """The principles as structured data."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Dict, List, Tuple
5
+
6
+ THEMES: Dict[str, str] = {
7
+ 'scope': 'Scope',
8
+ 'autonomy': 'Autonomy',
9
+ 'oversight': 'Oversight',
10
+ 'delegation': 'Delegation',
11
+ }
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class Principle:
16
+ number: int
17
+ text: str
18
+ explanation: str
19
+ theme: str
20
+ do: str
21
+ dont: str
22
+
23
+
24
+ PRINCIPLES: Tuple[Principle, ...] = (
25
+ Principle(
26
+ 1, "If a workflow will do, don't build an agent.",
27
+ "Fixed steps are cheaper, faster and easier to test than an agent choosing its own path. Use an agent only when the steps can't be known in advance.",
28
+ 'scope',
29
+ do='A fixed pipeline for "extract fields, validate, save".',
30
+ dont='An agent with open-ended tools for a three-step form fill.',
31
+ ),
32
+ Principle(
33
+ 2, 'Define done before you begin.',
34
+ 'An agent without a stopping condition stops too early or never stops. Say what finished looks like, what it may do, and when to give up.',
35
+ 'scope',
36
+ do='"Done when all tests pass and the PR is open; stop after 30 minutes."',
37
+ dont='"Improve the codebase."',
38
+ ),
39
+ Principle(
40
+ 3, 'Start narrow; earn breadth.',
41
+ 'Begin with one well-defined task and limited tools. Widen scope only after the agent has proven reliable at what it already does.',
42
+ 'scope',
43
+ do='Let it triage bug reports before letting it fix bugs.',
44
+ dont='Launch with access to email, calendar, code and payments on day one.',
45
+ ),
46
+ Principle(
47
+ 4, 'Autonomy should shrink as stakes grow.',
48
+ 'The more an action costs, and the harder it is to undo, the less the agent should do alone. Free rein for drafts; a checkpoint for anything that ships, spends or deletes.',
49
+ 'autonomy',
50
+ do='Let it draft replies freely; require approval before sending to customers.',
51
+ dont='Grant the same autonomy for renaming a variable and dropping a table.',
52
+ ),
53
+ Principle(
54
+ 5, 'A visible plan is better than a surprising result.',
55
+ 'Before consequential work, the agent should say what it intends to do, so a human can redirect it cheaply. Correcting a plan costs less than undoing an outcome.',
56
+ 'autonomy',
57
+ do='Show the migration plan before running it.',
58
+ dont="Discover the agent's approach by inspecting the damage.",
59
+ ),
60
+ Principle(
61
+ 6, 'An honest "I\'m stuck" is better than a confident guess.',
62
+ "An agent should stop and ask when it's blocked or unsure, instead of inventing a result to look finished. Make asking easy, and never penalize it.",
63
+ 'autonomy',
64
+ do='Give the agent a clear way to report "blocked: need API credentials".',
65
+ dont='Instruct it to never stop, then accept whatever it produced.',
66
+ ),
67
+ Principle(
68
+ 7, 'Pre-approve the routine; escalate the exceptional.',
69
+ 'Approval on every step trains people to click yes without reading. Pre-authorize well-understood, bounded actions and save human judgment for the unusual and the high-stakes.',
70
+ 'oversight',
71
+ do='Auto-approve refunds below a set limit; escalate larger or unusual ones.',
72
+ dont='Ask for approval on every file read.',
73
+ ),
74
+ Principle(
75
+ 8, "Accountability can't be delegated.",
76
+ 'The person or team that deploys an agent owns what it does. "The agent did it" is an explanation, not an excuse.',
77
+ 'oversight',
78
+ do='Name an owner for each agent in production.',
79
+ dont='Answer an incident with "the agent did it".',
80
+ ),
81
+ Principle(
82
+ 9, 'Partial and honest is better than complete and wrong.',
83
+ "An agent should report what it did, what it didn't, and what it's unsure of. A clear partial result is useful; a falsely complete one is dangerous.",
84
+ 'oversight',
85
+ do='"Migrated 47 of 50 tables; 3 failed on foreign keys—details below."',
86
+ dont='Report "Done!" over silent failures.',
87
+ ),
88
+ Principle(
89
+ 10, 'Delegate with a contract, not a hope.',
90
+ "When one agent hands work to another, specify the inputs, the scope and the shape of the answer. Vague handoffs produce duplicated work and results that don't fit together.",
91
+ 'delegation',
92
+ do='"Search these three repos for uses of X; return file paths and line numbers only."',
93
+ dont='"Go look into X."',
94
+ ),
95
+ Principle(
96
+ 11, 'Each extra agent should earn its cost.',
97
+ "Every added agent multiplies cost, latency and failure modes, and makes behavior harder to trace. Add one only when a single agent can't hold the job: parallel work, a separate context, or a different trust level.",
98
+ 'delegation',
99
+ do='Use research subagents to keep the main context small.',
100
+ dont='Build a five-agent "team" for a task one agent can finish.',
101
+ ),
102
+ Principle(
103
+ 12, 'Delegation can narrow authority, never widen it.',
104
+ 'A subagent should never hold permissions its delegator lacks, or delegation becomes a way around your controls.',
105
+ 'delegation',
106
+ do='Give a research subagent read-only tools.',
107
+ dont='Let a sandboxed agent spawn a helper with production access.',
108
+ ),
109
+ )
110
+
111
+
112
+ def by_theme(theme: str) -> List[Principle]:
113
+ """Return the principles in one theme (scope, autonomy, oversight, delegation)."""
114
+ if theme not in THEMES:
115
+ raise ValueError("unknown theme %r; choose from %s" % (theme, ", ".join(THEMES)))
116
+ return [p for p in PRINCIPLES if p.theme == theme]
117
+
118
+
119
+ def get(number: int) -> Principle:
120
+ """Return a principle by its stable number."""
121
+ for p in PRINCIPLES:
122
+ if p.number == number:
123
+ return p
124
+ raise KeyError(number)
zenofagents/render.py ADDED
@@ -0,0 +1,53 @@
1
+ """Turn the principles into text: concise, verbose, by theme, checklist, JSON."""
2
+
3
+ import json
4
+ from dataclasses import asdict
5
+
6
+ from .principles import PRINCIPLES, THEMES, by_theme
7
+
8
+ TITLE = "The Zen of Agents, by Anuj Sadani"
9
+
10
+
11
+ def concise() -> str:
12
+ lines = [TITLE, ""]
13
+ lines += ["%d. %s" % (p.number, p.text) for p in PRINCIPLES]
14
+ return "\n".join(lines) + "\n"
15
+
16
+
17
+ def verbose(examples: bool = False) -> str:
18
+ lines = ["The Zen of Agents (Verbose Edition)", "by Anuj Sadani", ""]
19
+ for p in PRINCIPLES:
20
+ pad = " " * (len(str(p.number)) + 2)
21
+ lines.append("%d. %s" % (p.number, p.text))
22
+ lines.append("%s— %s" % (pad, p.explanation))
23
+ if examples:
24
+ lines.append("%sDo: %s" % (pad, p.do))
25
+ lines.append("%sDon't: %s" % (pad, p.dont))
26
+ lines.append("")
27
+ return "\n".join(lines)
28
+
29
+
30
+ def themed() -> str:
31
+ lines = [TITLE + " — by theme", ""]
32
+ for key, name in THEMES.items():
33
+ lines.append(name)
34
+ lines += [" %d. %s" % (p.number, p.text) for p in by_theme(key)]
35
+ lines.append("")
36
+ return "\n".join(lines)
37
+
38
+
39
+ def checklist() -> str:
40
+ """Markdown checklist for PR templates, AGENTS.md or CLAUDE.md."""
41
+ lines = ["## Agent design checklist (Zen of Agents)", ""]
42
+ for key, name in THEMES.items():
43
+ lines.append("### " + name)
44
+ lines += ["- [ ] %s _(#%d)_" % (p.do, p.number) for p in by_theme(key)]
45
+ lines.append("")
46
+ return "\n".join(lines)
47
+
48
+
49
+ def as_json() -> str:
50
+ return json.dumps(
51
+ {"themes": THEMES, "principles": [asdict(p) for p in PRINCIPLES]},
52
+ ensure_ascii=False, indent=2,
53
+ )
zenofagents/verbose.py ADDED
@@ -0,0 +1,10 @@
1
+ """``from zenofagents import verbose`` prints the verbose edition."""
2
+
3
+ import os
4
+
5
+ from .render import verbose as _verbose
6
+
7
+ VERBOSE_ZEN = _verbose()
8
+
9
+ if not os.environ.get("ZENOFAGENTS_QUIET"):
10
+ print(VERBOSE_ZEN)
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: zenofagents
3
+ Version: 0.1.0
4
+ Summary: The Zen of Agents: principles for deciding what an AI agent may do on its own. Printed on import.
5
+ Author-email: Anuj Sadani <anuj.sadani3@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/asadani/zenofagents
8
+ Project-URL: Issues, https://github.com/asadani/zenofagents/issues
9
+ Project-URL: Changelog, https://github.com/asadani/zenofagents/blob/main/CHANGELOG.md
10
+ Keywords: AI agents,agentic AI,LLM,human oversight,AI safety,Zen
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Topic :: Software Development
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Dynamic: license-file
20
+
21
+ # zenofagents
22
+
23
+ [![CI](https://github.com/asadani/zenofagents/actions/workflows/ci.yml/badge.svg)](https://github.com/asadani/zenofagents/actions/workflows/ci.yml)
24
+ [![PyPI](https://img.shields.io/pypi/v/zenofagents)](https://pypi.org/project/zenofagents/)
25
+
26
+ ### The Zen of Agents: principles for deciding what an AI agent may do on its own.
27
+
28
+ The hard part of an agent isn't what it can do; it's what it should be allowed to do. These principles cover scope, autonomy, oversight and delegation.
29
+
30
+ `import this` gave Python a shared mindset. `import zenofagents` does the same for this corner of AI engineering: 12 short principles you can remember, cite by number and argue about.
31
+
32
+ ```bash
33
+ pip install zenofagents # or: uv pip install zenofagents / uv add zenofagents
34
+ uvx zenofagents --random # run the CLI without installing (uv)
35
+ ```
36
+
37
+ ```python
38
+ >>> import zenofagents
39
+ The Zen of Agents, by Anuj Sadani
40
+
41
+ 1. If a workflow will do, don't build an agent.
42
+ 2. Define done before you begin.
43
+ ...
44
+ ```
45
+
46
+ ---
47
+
48
+ ## The principles
49
+
50
+ Numbers are stable across releases, so "see principle 3" in a review always means the same thing.
51
+
52
+ ### Scope
53
+ 1. If a workflow will do, don't build an agent.
54
+ 2. Define done before you begin.
55
+ 3. Start narrow; earn breadth.
56
+
57
+ ### Autonomy
58
+ 4. Autonomy should shrink as stakes grow.
59
+ 5. A visible plan is better than a surprising result.
60
+ 6. An honest "I'm stuck" is better than a confident guess.
61
+
62
+ ### Oversight
63
+ 7. Pre-approve the routine; escalate the exceptional.
64
+ 8. Accountability can't be delegated.
65
+ 9. Partial and honest is better than complete and wrong.
66
+
67
+ ### Delegation
68
+ 10. Delegate with a contract, not a hope.
69
+ 11. Each extra agent should earn its cost.
70
+ 12. Delegation can narrow authority, never widen it.
71
+
72
+ Every principle comes with an explanation and a concrete do/don't example: `zenofagents --examples`.
73
+
74
+ ---
75
+
76
+ ## Usage
77
+
78
+ ### On import
79
+
80
+ ```python
81
+ import zenofagents # prints the principles
82
+ from zenofagents import verbose # prints them with explanations
83
+ ```
84
+
85
+ Set `ZENOFAGENTS_QUIET=1` to import without printing.
86
+
87
+ ### Command line
88
+
89
+ ```bash
90
+ zenofagents # the principles
91
+ zenofagents --verbose # with explanations
92
+ zenofagents --examples # with a do/don't example for each
93
+ zenofagents --themes # grouped by theme
94
+ zenofagents -n 3 # one principle in full
95
+ zenofagents --random # one at random: a daily reminder for your shell profile
96
+ zenofagents --checklist # Markdown checklist for PRs and agent instructions
97
+ zenofagents --json # machine-readable
98
+ ```
99
+
100
+ `python -m zenofagents` works the same way.
101
+
102
+ ### As data
103
+
104
+ ```python
105
+ import os; os.environ["ZENOFAGENTS_QUIET"] = "1"
106
+ import zenofagents
107
+
108
+ zenofagents.get(3).text # "Start narrow; earn breadth."
109
+ zenofagents.by_theme("scope") # list of Principle objects
110
+ [p.text for p in zenofagents.PRINCIPLES]
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Putting it into your workflow
116
+
117
+ A slogan is not a process. The principles help most where decisions are made:
118
+
119
+ - **Pull requests.** Paste `zenofagents --checklist` into `.github/pull_request_template.md`. Reviewers can then point to a principle by number.
120
+ - **Coding agents.** Add the checklist (or `zenofagents --themes`) to `AGENTS.md`, `CLAUDE.md` or your editor's rules file, so your agent works by the same standard you review by.
121
+ - **Onboarding.** `zenofagents --examples` is a short read for anyone new to the team's approach.
122
+
123
+ ---
124
+
125
+ ## What this is, and isn't
126
+
127
+ - It **is** a compact, opinionated philosophy and a shared vocabulary for teams.
128
+ - It **isn't** a linter, a framework or a replacement for engineering judgment.
129
+ - It's **vendor-neutral**: no principle depends on a particular model, framework or vendor.
130
+
131
+ ---
132
+
133
+ ## Contributing
134
+
135
+ The principles should evolve through discussion, not by decree. Propose a new principle, a rewording or a better example by opening an issue. See [CONTRIBUTING.md](CONTRIBUTING.md).
136
+
137
+ ## License
138
+
139
+ [MIT](LICENSE)
@@ -0,0 +1,11 @@
1
+ zenofagents/__init__.py,sha256=Ai9IXEDAv1bP4KkrTMxk-unqyj9hF5Sml3CUvnM9Ev8,972
2
+ zenofagents/__main__.py,sha256=FZTQPCSjzpo35dGEUsk47pvJOmdhJg-M3t7qt6KGq6c,2023
3
+ zenofagents/principles.py,sha256=AqZzx2lhDbmONBxE-y6xvYlxkOV3Q9Vyr47pEJxDm00,5772
4
+ zenofagents/render.py,sha256=PLMGxotNHn84DsQb0D8z8lgsA1dGKAtkbY2zKXba_QM,1642
5
+ zenofagents/verbose.py,sha256=OUHkLa978sQbnuCnPYFD281LlCiwjHTXE4ZOdsc6AYE,216
6
+ zenofagents-0.1.0.dist-info/licenses/LICENSE,sha256=ZLTwi-H42dk58Vbp1Ih8Grg_JqoJ1PkddBD5MpPf8gY,1068
7
+ zenofagents-0.1.0.dist-info/METADATA,sha256=EJDq4ZTllsRqlrNHXsi-YEnT0LjFAn4sTMW9GEzCBm0,4766
8
+ zenofagents-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
9
+ zenofagents-0.1.0.dist-info/entry_points.txt,sha256=z0EWH48gJcbpJMQYYXf9AgBSaCbvICdiQFleEtF8YLs,58
10
+ zenofagents-0.1.0.dist-info/top_level.txt,sha256=UVcL6S11utht3nKVY2tNA17kBFyibAzaywAQVbPi2VY,12
11
+ zenofagents-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ zenofagents = zenofagents.__main__:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anuj Sadani
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ zenofagents