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.
| Type | Description |
|---|---|
list[str] | List of directory paths to add to sys.path |
- 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.
| Field | Type | Description |
|---|---|---|
| Key | string | Graph ID (used in API calls to identify the graph) |
| Value | string | Import path in format ./path/to/file.py:variable |
- 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:
| Need | Use | Works with |
|---|---|---|
| Read context in node functions | Runtime[T] on node parameter | Static + factory graphs |
| Change graph structure per request | ServerRuntime[T] in factory | Factory graphs only |
| Manage resource lifecycle (MCP, DB) | ServerRuntime[T] + async context manager | Factory graphs only |
| Filter tools by user permissions | ServerRuntime (.user) in factory | Factory graphs only |
examples/factory/.
auth
Configure authentication and authorization.
| Field | Type | Default | Description |
|---|---|---|---|
path | string | — | Import path to your auth handler (./file.py:variable) |
disable_studio_auth | bool | false | Disable auth for LangGraph Studio connections |
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.
| Field | Type | Default | Description |
|---|---|---|---|
app | string | None | Import path to custom FastAPI app |
enable_custom_route_auth | bool | false | Apply Aegra auth to all custom routes |
cors.allow_origins | list[str] | ["*"] | Allowed CORS origins |
cors.allow_credentials | bool | false when origins is ["*"], true otherwise | Allow credentials in CORS requests |
store
Configure semantic store with vector embeddings.
| Field | Type | Required | Description |
|---|---|---|---|
index.dims | integer | Yes | Embedding vector dimensions (must match your model) |
index.embed | string | Yes | Embedding model in format provider:model-id |
index.fields | list[str] | No | JSON fields to embed (default: ["$"] for entire document) |
store is not configured, Aegra operates in basic key-value mode.
See semantic store guide for details.