Skip to main content
Aegra uses a JSON configuration file (aegra.json) to define graphs, authentication, HTTP settings, the semantic store, and checkpointer settings (thread TTL and the default checkpoint durability).

Config file resolution

Aegra resolves configuration files in this order:
  1. AEGRA_CONFIG environment variable — absolute or relative path
  2. aegra.json in the current working directory
  3. langgraph.json in the current working directory (compatibility fallback)

Complete example

dependencies

Add shared utility module paths to sys.path before graphs are loaded.
  • Relative paths are resolved from the config file’s directory
  • Paths are added in order (first has highest import priority)
  • Non-existent paths generate a warning but don’t prevent startup
See dependencies guide for details.

graphs

Define your LangGraph agents.
The variable can be:
  • A compiled graph — result of builder.compile() (static, cached once at startup)
  • A 0-arg callable — called once at startup to produce the graph (e.g., for MCP adapter setup)
  • A factory function — called per-request with config and/or ServerRuntime to produce a graph customized for the current user or request context

Static graphs

Factory graphs

Export a callable that accepts config (a RunnableConfig dict), runtime (a ServerRuntime), or both:
Supported factory signatures:
  • def graph() — 0-arg, called once at startup
  • def graph(config: dict) — receives the RunnableConfig per-request
  • def graph(runtime: ServerRuntime) — receives runtime with user, store, and access context
  • def graph(config: dict, runtime: ServerRuntime) — receives both (any parameter order)
Async factories and factories returning async context managers are also supported.

Typed context with Runtime[T] (node-level)

When a run is created with a context dict, Aegra passes it to graph.astream(context=...). LangGraph core coerces it to a typed object and injects it into nodes via Runtime[T]. This works for both static and factory graphs:
Pydantic BaseModel and dataclass types are both supported. Declare context_schema= on StateGraph and add a runtime: Runtime[T] parameter to any node that needs it.

Factory-level context with ServerRuntime[T]

For factory graphs, ServerRuntime[T] provides typed context at graph-build time — before execution starts. Use this for structural decisions that change the graph topology (adding/removing nodes, selecting tools, managing resource lifecycle):
Use runtime.execution_runtime to check whether the factory is being called for actual execution (returns the execution runtime with .context) or for introspection like schema extraction (returns None). When to use which: For a complete example combining both layers, see examples/factory/.

auth

Configure authentication and authorization.
The path supports multiple formats:
  • ./auth.py:auth — Load from a file relative to the config
  • ./src/auth/jwt.py:auth — Nested path
  • mypackage.auth:auth — Load from an installed package
If auth is not configured, Aegra runs in no-auth mode where all requests are allowed. See authentication guide for details.

http

Configure custom routes and CORS.
When allow_origin_regex is non-null, it is passed to Starlette’s CORSMiddleware and matched against the complete origin. If allow_origins is also provided, either the list or regex can authorize an origin. An explicit allow_origins: ["*"] remains a wildcard. An empty string still counts as configured; it does not match normal non-empty origins. Note: the allow_credentials default only recognizes an exact ["*"] or "*". A wildcard mixed with other concrete origins (e.g. ["*", "https://example.com"]) currently still defaults allow_credentials to true, even though Starlette treats that list as allow-all — tracked in #633. Set allow_credentials explicitly if you use a mixed list. See custom routes guide for details.

store

Configure semantic store with vector embeddings.
If store is not configured, Aegra operates in basic key-value mode. See semantic store guide for details.

checkpointer

Configure thread retention (TTL) and the default checkpoint durability.

ttl

When a ttl block is present, every newly created thread gets an expiry, and a background sweep deletes or compacts expired threads.
Notes:
  • Threads with pending or running runs are skipped and swept once their runs settle.
  • Deleting an expired thread cascades to its runs and thread-bound crons.
  • Individual threads can override the default via the ttl field on POST /threads; expired threads can be cleaned immediately with POST /threads/prune. See the threads guide.
  • The AEGRA_THREAD_TTL environment variable replaces this block entirely when set — see environment variables.
If neither checkpointer.ttl nor AEGRA_THREAD_TTL is configured, threads never expire.

durability

Sets when checkpoints are written for runs that do not choose a mode themselves.
Resolution order for each run:
  1. The run’s durability field (or the deprecated checkpoint_during).
  2. The AEGRA_CHECKPOINT_DURABILITY environment variable.
  3. checkpointer.durability in aegra.json.
  4. LangGraph’s default.
An invalid value stops the server at startup. LangGraph Platform has no server-wide durability setting, so this key is specific to Aegra. See checkpoint durability for what each mode trades off.

Common configurations

Minimal

With authentication

With custom routes

Production