aegra
Use when building, deploying, and managing self-hosted LangGraph agents. Reach for this skill when setting up agent infrastructure, configuring authentication, managing threads and state, streaming responses, implementing human-in-the-loop workflows, scheduling cron jobs, or deploying to production.
How do I install this agent skill?
npx skills add https://docs.aegra.dev --skill aegraIs this agent skill safe to install?
- Socketpass
No alerts
What does this agent skill do?
Aegra Skill
Product summary
Aegra is an open-source, self-hosted Agent Protocol server for running LangGraph agents on your own infrastructure. It's a drop-in replacement for LangSmith Deployments with the same SDK and APIs. Agents run on PostgreSQL with optional Redis for multi-instance scaling. Key files: aegra.json (configuration), pyproject.toml (dependencies), .env (secrets). Primary CLI commands: aegra init (create project), aegra dev (local development), aegra serve (production), aegra up (Docker Compose). Primary docs: https://docs.aegra.dev
When to use
Reach for this skill when:
- Setting up a new agent project — Initialize with templates, configure graphs, set environment variables
- Configuring authentication — Add JWT, OAuth, Firebase, or custom auth handlers
- Managing agent execution — Create threads, run agents, stream responses, handle interrupts
- Implementing approval workflows — Add human-in-the-loop gates before tool execution
- Scheduling recurring tasks — Create cron jobs with timezone support and webhooks
- Storing persistent data — Use key-value store or semantic search with vector embeddings
- Deploying to production — Configure for Docker, PaaS (Railway, Render, Fly.io), or Kubernetes
- Debugging and observability — Stream events, inspect thread state, trace to OTLP backends
Quick reference
CLI commands
| Command | Purpose |
|---|---|
aegra init | Create new project (prompts for template and location) |
aegra dev | Local dev server with hot reload and managed PostgreSQL |
aegra serve | Production server (requires external PostgreSQL) |
aegra up | Start Docker Compose services (PostgreSQL + app) |
aegra down | Stop Compose services |
aegra version | Show version info |
Configuration file (aegra.json)
| Section | Purpose |
|---|---|
graphs | Define LangGraph agents (path to compiled graph or factory function) |
auth | Authentication handler (JWT, OAuth, Firebase, or custom) |
http | Custom FastAPI routes and CORS settings |
store | Semantic search with vector embeddings (pgvector) |
checkpointer | Thread TTL and checkpoint durability defaults |
dependencies | Shared module paths to add to sys.path |
Environment variables (key ones)
| Variable | Purpose |
|---|---|
OPENAI_API_KEY | LLM API key (or your provider's key) |
DATABASE_URL | PostgreSQL connection (for aegra serve) |
REDIS_BROKER_ENABLED | Enable Redis workers for multi-instance (default: false) |
REDIS_URL | Redis connection URL |
AEGRA_CONFIG | Path to config file (default: aegra.json) |
AEGRA_THREAD_TTL | Thread expiry in minutes (overrides config) |
AEGRA_CHECKPOINT_DURABILITY | Default checkpoint mode: sync, async, or exit |
Core API patterns
Create and stream a run:
async for chunk in client.runs.stream(
thread_id=thread_id,
assistant_id="agent",
input={"messages": [{"type": "human", "content": "Hello"}]},
stream_mode=["values"],
):
print(chunk)
Create thread with metadata:
thread = await client.threads.create(
metadata={"user_id": "alice", "session": "onboarding"}
)
Get thread state:
state = await client.threads.get_state(thread_id)
print(state["values"]) # Current state
print(state["interrupts"]) # Pending interrupts
Resume interrupted run:
async for chunk in client.runs.stream(
thread_id=thread_id,
assistant_id="agent",
command={"resume": [{"type": "accept"}]},
):
print(chunk)
Decision guidance
When to use each CLI command
| Scenario | Command | Why |
|---|---|---|
| Local development | aegra dev | Manages PostgreSQL, hot reload, simplest setup |
| Self-hosted Docker | aegra up | Compose file handles both app and database |
| PaaS (Railway, Render, Fly.io) | aegra serve | No Docker needed, uses managed database |
| Kubernetes | aegra serve | Stateless, scales horizontally with Redis |
| Inside Docker container | aegra serve | Replaces itself with uvicorn as PID 1 |
When to use each stream mode
| Mode | Use when |
|---|---|
values | You need full state snapshots after each node |
updates | You only care about state deltas (smaller payloads) |
messages | You're streaming LLM tokens and tool calls |
custom | You emit custom data from graph nodes |
events | You need fine-grained LangGraph event tracing |
debug | You're debugging checkpoints and task results |
When to use each checkpoint durability
| Mode | Use when |
|---|---|
sync | You need to resume from the exact last step (slower) |
async (default) | You want background checkpointing with good recovery |
exit | You have high-volume runs that never time-travel or mid-run recover |
When to use factory graphs vs static graphs
| Approach | Use when |
|---|---|
| Static graph | Graph structure is fixed; no per-user customization needed |
| Factory function | You need to customize tools, models, or topology per user/request |
ServerRuntime[T] factory | You manage resources (MCP, DB connections) or filter tools by permissions |
Workflow
1. Initialize a new project
pip install aegra-cli
aegra init
# Choose: location, template (simple-chatbot or react-agent), name
cd <project>
cp .env.example .env
# Edit .env: add OPENAI_API_KEY
uv sync
uv run aegra dev
2. Define your agent graph
- Edit the graph file (e.g.,
src/agent/graph.py) - Export a compiled graph or factory function
- Register in
aegra.jsonundergraphs
3. Test locally
uv run aegra dev
# Visit http://localhost:2026/docs to test API
# Or use the LangGraph SDK to stream runs
4. Add authentication (if needed)
- Create
auth.pywith@auth.authenticatehandler - Reference in
aegra.jsonunderauth.path - Restart server
5. Add human-in-the-loop (if needed)
- Call
interrupt()in graph nodes at decision points - Client resumes with
command={"resume": [...]} - Thread status becomes
"interrupted"while paused
6. Configure for production
- Set
REDIS_BROKER_ENABLED=truefor multi-instance - Add
REDIS_URLand externalDATABASE_URL - Configure auth, CORS, and webhooks in
aegra.json - Use
aegra serveor Docker
7. Deploy
- Docker Compose:
aegra up(local) or push Dockerfile to registry - PaaS: Set
DATABASE_URL,REDIS_URL, runaegra serve - Kubernetes: Use
aegra servein pod spec, scale replicas with shared Redis/PostgreSQL
Common gotchas
- Always install
aegra-cli, notaegra— Theaegrapackage is a meta-package without version pinning. - Thread IDs and assistant IDs must be 1–255 non-blank characters — Longer values are rejected with 422.
- Graph IDs in
aegra.jsonare used directly in API calls — Use simple, URL-safe names. inputandcommandare mutually exclusive — Don't send both when creating a run; usecommandonly when resuming from an interrupt.- Checkpoint durability affects recovery behavior —
exitmode means a crashed run restarts from the thread's last checkpoint, not the last step. - Redis is required for multi-instance deployments — Without it, runs execute as in-process asyncio tasks (single-instance only).
- Webhooks must pass the URL policy — Loopback and private IPs are blocked by default; configure
webhooks.urlinaegra.jsonto allow them. - Stream mode
debugandupdatesare sent only if explicitly requested — They're used internally but hidden from clients unless you ask for them. - Factory graphs are called per-request — Use
runtime.execution_runtimeto detect introspection vs. actual execution. - Metadata on threads is user-scoped — When auth is enabled, threads are automatically isolated per user.
- Cron jobs fire immediately on creation — Pass
enabled=falseto suppress the first run.
Verification checklist
Before submitting work with Aegra:
- Configuration is valid — Run
aegra devoraegra serveand check for startup errors - Graphs are registered — All graph IDs in
aegra.jsonare correct and files exist - Environment variables are set —
.envhas all required keys (API keys, database URL, etc.) - Authentication is configured — If
auth.pathis set, the handler exists and is importable - Threads and runs work — Test creating a thread and streaming a run via SDK or API
- State is persisted — Create a thread, run an agent, then fetch state and verify it matches
- Interrupts work (if using HITL) — Verify thread status becomes
"interrupted"and can be resumed - Streaming reconnects — Drop a connection mid-stream and reconnect with
Last-Event-IDheader - Crons fire on schedule — Create a cron and verify it runs at the expected time
- Webhooks are called (if configured) — Check that run-completion webhooks reach your endpoint
- Production settings are correct — If deploying, verify
REDIS_BROKER_ENABLED,DATABASE_URL, and auth are set
Resources
- Full documentation navigation: https://docs.aegra.dev/llms.txt
- Configuration reference: https://docs.aegra.dev/reference/configuration
- CLI reference: https://docs.aegra.dev/reference/cli
- Streaming guide: https://docs.aegra.dev/guides/streaming
- Authentication guide: https://docs.aegra.dev/guides/authentication
- Deployment guide: https://docs.aegra.dev/guides/deployment
For additional documentation and navigation, see: https://docs.aegra.dev/llms.txt
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/docs.aegra.dev/aegra">View aegra on skillZs</a>