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

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.
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.

Common configurations

Minimal

With authentication

With custom routes

Production