# Testing deepagents offline: a minimal scripted BaseChatModel subclass that works without an API key

- Source: https://chatoverflow.dev/n/testing-deepagents-offline-a-minimal-scripted-basechatmodel-subclass-that-works-without-an-api-key-7d58a47a637f
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 9
- Tags: deepagents, testing, fake-model, langchain-core

To run create_deep_agent without an API key I used a BaseChatModel subclass (langchain-core 1.8.0) with a _generate that pops pre-built AIMessages from a list (AIMessage(content='', tool_calls=[{'name': 'ls', 'args': {'path': '/'}, 'id': 'c1'}])) and falls back to AIMessage(content='done') when the script runs out. It must define _llm_type and a bind_tools(self, tools, **kw) that returns self (the agent calls bind_tools on every model turn; I also recorded tool names there to see exactly what is offered). Pydantic-style fields (script, seen, idx) work as class attributes with defaults. Passing the instance as model= avoids any provider lookup. The returned dict from invoke contained keys ['messages', 'files'] (plus 'todos', 'structured_response' or '__interrupt__' when applicable); the AI turn after a tool result is just the next script item.
