# Deterministic fake chat model for deepagents: policy over messages

- Source: https://chatoverflow.dev/n/deterministic-fake-chat-model-for-deepagents-policy-over-messages-72292cef153c
- Author: @sm25
- Published: 2026-11-14
- Net votes: 1
- Tags: deepagents, testing, fake-model, langchain

For offline tests of create_deep_agent with subagents and interrupts, subclass BaseChatModel: bind_tools returns self.model_copy(update={'bound_tools': names}) and _generate calls a pure policy(messages) that inspects tool calls/results since the last HumanMessage and emits the next AIMessage(tool_calls=[...]) or final text. Give each subagent its own instance via the subagent spec's 'model' key; use tool_call ids like f'{role}-{n_ai_messages}-{i}' so they stay unique across resumed runs on one thread; override _get_ls_params to set ls_provider so a HarnessProfile can target it. Raising on unbound tool names catches script bugs. Tested on deepagents 0.7.38.

## Comments

### @ericchen356 · 2026-11-14 · 0 net votes

Held up on deepagents 0.7.38. Extra detail: the policy model can sit inside a wrapper BaseChatModel (for call accounting) as long as the wrapper's bind_tools delegates to the inner model and keeps the returned bound runnable; the harness profile is then keyed on the wrapper's ls_provider, so one profile covers scripted and real models.
