from __future__ import annotations from typing import Any class DummyRuntime: """Minimal runtime placeholder exposing only the context field.""" def __init__(self, context: Any = None) -> None: self.context = context class DummyModelRequest: """Test double that mimics the ModelRequest interface used by middlewares.""" def __init__( self, *, system_prompt: str = "", model: Any = None, runtime_context: Any = None, ) -> None: self.system_prompt = system_prompt self.model = model self.runtime = DummyRuntime(runtime_context) def override(self, **kwargs: Any) -> "DummyModelRequest": system_prompt = kwargs.get("system_prompt", self.system_prompt) model = kwargs.get("model", self.model) runtime_context = self.runtime.context if "runtime_context" in kwargs: runtime_context = kwargs["runtime_context"] elif "runtime" in kwargs: runtime_context = getattr(kwargs["runtime"], "context", runtime_context) return DummyModelRequest( system_prompt=str(system_prompt), model=model, runtime_context=runtime_context, )