Imported from KooshaPari/phenotype-tooling (docs/absorbed-from-phenotype-request-id/AGENTS.md). Install upstream with npx skills add KooshaPari/phenotype-tooling --skill absorbed-from-phenotype-request-id. Copyright stays with the author.
phenotype-request-id
Zero-dep request-ID propagation (contextvars) for Python ASGI services,
with optional FastAPI/Starlette middleware and structlog binder.
Layout
src/phenotype_request_id/context.py — ContextVar store (zero deps)
src/phenotype_request_id/fastapi.py — ASGI middleware (lazy import of starlette)
tests/test_middleware.py — auto-skips when fastapi/httpx absent
Conventions
Core must remain zero-dep. All optional integrations via lazy import.
No class larger than 50 lines.
Use contextvars (stdlib), not threading.local.
Use it
Copy one of these into your project. Installing also returns the manifest and these snippets.
yaml
targets:
- https://api.opensmartroute.ai/api/v1/registry/kooshapari-phenotype-tooling-absorbed-from-phenotype-request-id/manifest # or paste the manifest below
Manifest
An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.