Skip to content

Commit 48d4016

Browse files
committed
Add "token efficiency" and move CLI section in README
1 parent bc963ed commit 48d4016

1 file changed

Lines changed: 24 additions & 22 deletions

File tree

README.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,37 @@ print(agent_help(Sensor))
106106

107107
`agent_help(Sensor)` now returns the same auto-generated public-API list, plus a `## Notes from class Sensor` section carrying the rules above. Full output and inheritance-with-notes behavior in [Example 2](#example-2-inheritance-with-accumulated-notes) below.
108108

109+
## CLI
110+
111+
```bash
112+
# Any stdlib class
113+
python -m agent_readable sqlite3:Connection
114+
115+
# A class in your own package
116+
python -m agent_readable my_package.temperature:CalibratedSensor
117+
118+
# The library itself — self-documenting
119+
python -m agent_readable agent_readable:AgentReadableMixin
120+
121+
# Any module
122+
python -m agent_readable pathlib
123+
124+
# A function or method
125+
python -m agent_readable json:dumps
126+
python -m agent_readable pathlib:Path.read_text
127+
```
128+
129+
Outputs agent-oriented documentation for the given class, module, function, or method to stdout.
130+
109131
## Why it matters
110132

111133
`agent_help()` covers two failure modes agents hit on real APIs:
112134

113135
1. **What exists.** The `## Public API` section is a curated list of current signatures pulled from runtime introspection — no hallucinated methods, no stale signatures from training data, no private members leaking in. If the agent reads this list first, it stops inventing methods that don't exist and stops calling real ones with the wrong arguments.
114136
2. **How to use it correctly.** Lifecycle order, pre-conditions, anti-patterns, *"this method is for X, that one for Y."* These don't fit in any single method's docstring and don't belong in a project-level `AGENTS.md` (which describes whole repos). They're class-level, and they need to travel with refactors. `__agent_notes__()` gives them a home next to the code.
115137

138+
**Token efficiency.** Hallucinated APIs don't just produce wrong code — they trigger failure-retry loops that burn context and tokens. A single invented method can cost multiple rounds of write, run, error, rewrite before the agent converges on a real API. `agent_help()` generates compact, precise, accurate descriptions of publicly exposed interfaces — accurate because they're runtime-checked against the live, installed package — so calling it before writing code against an unfamiliar class or module collapses those rounds to zero. Call `python -m agent_readable <target>` from the CLI, or `agent_help(target)` in code. If the agent-readable skill is installed, your agent will do this automatically before coding against unfamiliar APIs.
139+
116140
A concrete contrast:
117141

118142
```
@@ -493,28 +517,6 @@ import sys
493517
sys.modules[__name__].__agent_help__ = "Custom module help."
494518
```
495519

496-
## CLI
497-
498-
```bash
499-
# Any stdlib class
500-
python -m agent_readable sqlite3:Connection
501-
502-
# A class in your own package
503-
python -m agent_readable my_package.temperature:CalibratedSensor
504-
505-
# The library itself — self-documenting
506-
python -m agent_readable agent_readable:AgentReadableMixin
507-
508-
# Any module
509-
python -m agent_readable pathlib
510-
511-
# A function or method
512-
python -m agent_readable json:dumps
513-
python -m agent_readable pathlib:Path.read_text
514-
```
515-
516-
Outputs agent-oriented documentation for the given class, module, function, or method to stdout.
517-
518520
## FAQ
519521

520522
### How does my agent know to call `agent_help()` instead of `help()`?

0 commit comments

Comments
 (0)