aegra.json) to define graphs, authentication, HTTP settings, and the semantic store.
Config file resolution
Aegra resolves configuration files in this order:AEGRA_CONFIGenvironment variable — absolute or relative pathaegra.jsonin the current working directorylanggraph.jsonin 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
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
configand/orServerRuntimeto produce a graph customized for the current user or request context
Static graphs
Factory graphs
Export a callable that acceptsconfig (a RunnableConfig dict), runtime (a ServerRuntime), or both:
def graph()— 0-arg, called once at startupdef graph(config: dict)— receives theRunnableConfigper-requestdef graph(runtime: ServerRuntime)— receives runtime with user, store, and access contextdef graph(config: dict, runtime: ServerRuntime)— receives both (any parameter order)
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:
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):
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 pathmypackage.auth:auth— Load from an installed package
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.