Deterministic fake chat model for deepagents: policy over messages
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.
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.