Guidelines for coding agents working on this repository.
agent-internet is the control plane, transport, and federation layer for
autonomous agents. It provides identity, routing, trust, discovery, and a
web browser — all in pure Python stdlib.
- Zero external dependencies. Only Python stdlib. No exceptions.
No
requests, noaiohttp, noplaywright.urllib.requestfor HTTP,html.parserfor HTML,jsonfor serialization,sqlite3for persistence. - Frozen dataclasses with
slots=Truefor all data models.@dataclass(frozen=True, slots=True)— immutable, memory-efficient, hashable. - Protocol-based interfaces (
typing.Protocol), notabc.ABC. Structural subtyping — implementations don't inherit from the interface. - ADR-0003 rule: External web content is transport, not substrate. The browser projects the public web into agent-consumable structures without importing foreign identity or governance.
- Ruff for linting (
ruff check). - All public functions: docstring + return type annotation.
- No
except Exception:without a specific exception class. Always log caught exceptions with at leastlogger.debug(). - No magic numbers — use
BrowserConfigfields or named constants. - Imports at module top, sorted. No lazy imports inside functions.
- Each file < 500 lines (hard limit), < 400 (target).
_make_page()factory for allBrowserPageconstruction.PageSourceprotocol for pluggable browser sources (GitHub, federation, etc.).- CBR-inspired compression via
compress_page()for token-budget control. - llms.txt discovery: check
/llms.txtbefore HTML scraping (strangler fig). - agents.json discovery: enrich pages with
/.well-known/agents.jsonmetadata.
pytestwith stdlibunittest.mockfor mocking.- No test fixtures that require network access. All HTTP calls mocked.
- Tests in
tests/mirror the source module structure. - Run:
python -m pytest tests/ -x -q
- No JavaScript rendering, no CSS parsing, no browser engine dependencies.
- No Lotus/IPv7 integration (Phase 5 — design doc only for now).
- No plugin systems, middleware stacks, or event pipelines. KISS.
- No new external dependencies. If you think you need one, you don't.
| Module | Responsibility | Lines |
|---|---|---|
agent_web_browser.py |
Models, config, browser class, session management | ~860 |
agent_web_browser_parser.py |
HTML parser, parse_html, _clean_text |
~265 |
agent_web_browser_http.py |
HTTP fetch, JSON rendering, llms.txt/agents.json discovery | ~385 |
agent_web_browser_compress.py |
CBR compression, token budgets, nav-chrome stripping | ~155 |
agent_web_browser_env.py |
Environment probe, GAD-000 manifest, federation discovery | ~355 |
agent_web_browser_github.py |
GitHub API PageSource (repos, issues, PRs, releases) | ~740 |
agent_web_browser_semantic.py |
Semantic layer bridge (page → record → index) | ~280 |
from agent_internet import AgentWebBrowser, GitHubBrowserSource
browser = AgentWebBrowser()
browser.register_source(GitHubBrowserSource())
# Browse — llms.txt auto-discovered when available
page = browser.open("https://docs.stripe.com")
print(page.headers.get("x-content-source")) # "llms.txt"
# GitHub repos via API, not HTML scraping
page = browser.open("https://github.com/kimeisele/agent-internet")
print(page.title, page.link_count)