All notable changes to the agentminds Python SDK are documented here.
Minor release. Backwards compatible.
agentminds.syncmodule — high-level helpers for the AgentMinds/syncAPI surface so integrators never hand-roll JSON payloads or manage theX-AgentMinds-Keyheader by hand.- Push (your data → AgentMinds):
sync.report(api_key, site_id, agent, metrics, warnings, learned_patterns, project_info)posts a structured agent report to/api/v1/sync/bulk. - Pull (AgentMinds insights → your code):
sync.recommendations(api_key, limit=...),sync.benchmarks(api_key, site_id),sync.my_role(api_key),sync.network_position(api_key),sync.issues(api_key, status="open"). All return parsed JSON; no manualrequests/ header plumbing.
- Push (your data → AgentMinds):
agentminds.metricsmodule — canonical metric emitters that mirror the server-side registry. Lets a Python app push metrics by the same names the central pool uses (hsts_present,ssl_days_remaining,bounce_rate, etc.) without hand-coding the schema. Avoids the "your push got grade-D because metric names didn't match" failure mode.
- README rewritten around the cross-site collective intelligence positioning: the SDK pushes runtime events + agent reports into a shared pool and pulls personalized recommendations back. Install steps unchanged; the framing leads with the network value rather than the captured-events value.
pyproject.tomlmetadata expanded:- 6 URL entries in
[project.urls]— Homepage, Documentation, Repository, Issues, Changelog, Spec. Speclink now points atagentmindsdev/profile(the public ARP spec repo, CC-BY-4.0).keywordsextended for collective-intelligence / ai-agents discoverability on PyPI.
- 6 URL entries in
- Compatible with AgentMinds backend
a8c23b3+(tier-aware shaping:/sync/trial-rules,/sync/personalized-rules). - Compatible with
agentminds-mcp 1.3.0+. - Implements the response-shape contract published in
ARP spec v1.3.0
(
top_production_observed+top_documentedsplit arrays,negative_evidence, optionalreversibilityfield — passed through unchanged from server response, no client-side parsing required). - Python
>=3.8supported.
- Test suite at 83 tests (pytest), all passing.
- 0 Turkish characters in
.py/.toml/.cfg/.mdsource files (English-only contract aligned with the company-wide user-facing strings rule). python -m build --sdistverified clean (hatchling backend, isolated venv).
-
agentminds: command not foundon Windows. Pip installs the binary in<python>/Scripts/which is NOT on PATH for--userinstalls by default — a fresh stranger runningpip install agentminds && agentminds connectwould get command-not-found even though install succeeded. Discovered when a real onboarding attempt failed silently in this exact way.Fix: added
agentminds/__main__.pysopython -m agentminds connectworks as the canonical entry point. The Python interpreter the user just used to runpipis always on PATH, so this form works regardless ofScripts/PATH state.All website + README install snippets now lead with the
python -m agentmindsform. The bareagentmindsconsole script still ships and still works for users whoseScripts/IS on PATH.
- Crash on Windows non-UTF8 consoles.
agentminds connectwas crashing withUnicodeEncodeError: 'charmap' codec can't encode character '→'on cp1254 (Turkish) and cp1252 (Western) Windows consoles. The CLI now detects whether stdout can encode unicode glyphs and falls back to ASCII (->,...,[ok]) when it can't. Discovered via real smoke test against PyPI 0.4.0. - Stale
agentminds>=0.2.1reference in install snippets bumped toagentminds>=0.4.1so generated requirements lines pull in a version that actually has theconnectcommand.
agentminds connect— one-command onboarding. New CLI subcommand that wraps the entire signup flow in a single shell command. Prompts for site URL + email (or accepts--url/--emailflags), POSTs to/api/v1/sync/onboard, builds the DSN from the returnedapi_keyandsite_id, then auto-detects framework + applies the SDK install in place (FastAPI / Flask). End-state:pip install agentminds && agentminds connectis the entire onboarding for a stranger.AGENTMINDS_APIenv var now overrides the onboarding endpoint host (used by self-hosted setups + tests). Defaults tohttps://api.agentminds.dev.- 23 new pytest cases for the connect command's pure helpers (URL + email validation, URL normalization, name derivation, DSN format).
_prompt()was infinite-looping when invoked with stdin closed. EOF on stdin now aborts withSystemExit(2)and a clear "pass it as a flag" hint.
- The previous flow was: register on agentminds.dev/onboard, copy the
DSN out of the dashboard, run
agentminds setup --applyseparately. Three steps, two surfaces.connectcollapses it into one — which is what the home page + /docs hero now promise.
- CLI installer.
pip install agentmindsnow ships anagentmindsconsole script.agentminds setupauto-detects the host project's framework (FastAPI / Flask / Django) and prints exact-line instructions for where to add the init call, where to attach the middleware, what to put in requirements.txt, and what env var to set in production. Optional--applyedits the entry file in place after creating a.agentminds.bakbackup.
- The dashboard install snippet works for someone who reads it
carefully. The CLI works for someone who has 30 seconds and
doesn't want to read at all.
agentminds setupis what a stranger runningnpm create-viteornpx create-next-appwould expect.
- Reads
requirements.txt/pyproject.toml/manage.pyto detect the framework. Walks common entry-file locations (api/app.py,app/main.py,main.py, etc.) to find theapp = FastAPI(…)orapp = Flask(…)line. - Prints the install steps with the actual file path of the detected entry file so the user knows exactly where to paste.
- Redacts the DSN secret in console output (only shows the public prefix + the site_id at the end) — safe to show in screen recordings or pair-programming.
- Idempotent: if
agentminds.init(is already in the file, exits cleanly with "no change".
| Command | What it does |
|---|---|
agentminds setup |
Detect + print steps |
agentminds setup --apply |
Edit the entry file in place (backs up first) |
agentminds setup --dsn=... |
Override / supply the DSN |
agentminds setup --root=PATH |
Run against a project other than cwd |
agentminds version |
Print SDK version |
- Django: doesn't auto-edit
manage.py; prints generic init steps (Django middleware integration is on the SDK roadmap). - Custom entry-file layouts: if
app = FastAPI()isn't auto-found, the CLI prints generic steps and skips--apply.
Internal review pass on the 0.2.0 introspection feature — three small correctness/perf fixes, no API changes.
- Walk timeout actually enforced.
SCAN_TIMEOUT_Swas declared in 0.2.0 but the walk had no timeout check. Now the entire pass (file walk + parse loop) is capped by atime.monotonic()deadline. If the deadline trips mid-walk we return whatever was found so far and tag the result withtimed_out: True. Init never blocks on a pathological project layout. - Stdlib detection uses
sys.stdlib_module_nameswhen available (Python 3.10+). The hand-curated fallback for 3.8/3.9 was missing common modules (socket, signal, struct, gzip, decimal, …) which meantthird_party_depscarried false positives. Net effect: thethird_party_depslist now actually reflects third-party deps. - Backend
/sync/code-signaturehistory. The SQL wasSELECT DISTINCT ON (hash) … LIMIT 30ordered by hash, which gave the alphabetically-first 30 hashes instead of the 30 most-recent distinct stacks. Wrapped in an outer SELECT so we sort byreceived_at DESCafter collapsing duplicates.
function_nameswas being collected as a list only to take its length at the end. Replaced with an integer counter — no behaviour change, drops O(n) memory on large codebases.
- Code introspection at init time —
agentminds.init()now walks the host app's codebase once at startup and ships a structured "code signature" so AgentMinds knows what it's monitoring without any follow-up step. No MCP, no cron, no manual push. One DSN, full picture: frameworks, routes, decorator patterns, third-party deps, function counts.
- Detected web frameworks (fastapi, flask, django, starlette, …) + observability + DB + LLM libs
- HTTP route handlers — method, path literal, handler name, async/sync
- Decorator patterns repeated ≥3 times across the codebase
- Top-level package layout (depth ≤6, file count caps)
- Third-party dependency list pulled from imports
- Async vs sync function ratio
- Test file count
- Stable
signature_hashso repeat startups can short-circuit
- Function bodies, docstrings, comments, and string literals are NEVER read or sent — only structural facts (names, decorators, route paths).
- Walk skips
.git,node_modules,.venv,dist, build artifacts, third-party vendor dirs. - Hard caps: 800 files, 200 KB per file, depth 6, parse errors swallowed.
- Best-effort: if introspection fails, init continues.
- Disable via
agentminds.init(introspect_code=False)or override the scan root viaproject_root="...".
Initial public release.
agentminds.init(dsn=...)— single entry point. Idempotent; no-op without DSN.- Auto-capture for
sys.excepthookandthreading.excepthook(chains to existing handlers, never replaces). - Logging integration —
ERRORand above ship as events,INFO/WARNINGbecome breadcrumbs that ride along with the next captured event. - Manual capture API —
capture_exception,capture_message,capture_event. - Scope API —
set_user,set_tag,set_extra,set_transaction,add_breadcrumb,clear_scope. Thread-local so concurrent requests don't bleed state. - FastAPI integration —
agentminds.integrations.fastapi_app.AgentMindsMiddleware(per-request scope reset + handler exception capture + 5xx capture). - Flask integration —
agentminds.integrations.flask_app.init_app(app)(before_request/errorhandler(Exception)/after_requesthooks). - Release auto-detection from
git rev-parse --short HEAD. - Background worker thread + bounded queue (1000 events, drop-oldest under back-pressure) so capture is O(1) on the hot path.
atexithook flushes on interpreter shutdown.
- Posts batched events to
POST {api_base}/api/v1/sync/ingest/{site_id}/events?key={public_key}with body{ "events": [...] }. Identical envelope as the browser collector and the Node SDK — all three land in the sameruntime_eventstable.
send_default_pii=False— no request bodies, no DB query parameters captured.- Stack traces truncated to 8 KB; messages to 500 chars.
- User PII (email, IP) only sent if explicitly set via
set_user(...).