DeterministicIntegrationChatModel()Deterministic chat model for CLI integration tests.
This subclasses LangChain's GenericFakeChatModel so the implementation
stays aligned with the core fake-chat-model test surface, while overriding
generation to remain prompt-driven and restart-safe for real CLI server
integration tests.
Why the existing langchain_core fakes cannot be reused here:
Every core fake (GenericFakeChatModel, FakeListChatModel,
FakeMessagesListChatModel) pops from an iterator or cycles an index —
the actual prompt is ignored. CLI integration tests start and stop the
server process, which resets in-memory state. An iterator-based model
either raises StopIteration or replays from the beginning after a
restart, producing wrong or missing responses. This model derives output
solely from the prompt text, so identical input always produces
identical output regardless of process lifecycle.
The agent runtime calls model.bind_tools(schemas) during
initialization. None of the core fakes implement bind_tools, so they
raise AttributeError in any agent-loop context. This model provides a
no-op passthrough.
The CLI server reads model.profile for capability negotiation (e.g.
tool_calling, max_input_tokens). Core fakes have no such attribute,
causing AttributeError or silent misconfiguration at runtime.
Additionally, the compact middleware issues summarization prompts mid- conversation. A list-based model cannot distinguish these from normal user turns without pre-knowledge of exact call ordering, whereas this model detects summary requests by inspecting the prompt content.
Return self so the agent can bind tool schemas during tests.