"""Lightweight runtime context type for app model overrides. Extracted from `configurable_model` so hot-path modules (`app`, `textual_adapter`) can import `CLIContext` without pulling in the langchain middleware stack. """ from __future__ import annotations from typing import Any from typing_extensions import TypedDict class CLIContext(TypedDict, total=False): """Runtime context passed via `context=` to the LangGraph graph. Carries per-invocation overrides that `ConfigurableModelMiddleware` reads from `request.runtime.context`. """ model: str | None """Model spec to swap at runtime (e.g. `'provider:model'`).""" model_params: dict[str, Any] """Invocation params (e.g. `temperature`, `max_tokens`) to merge into `model_settings`."""