# deepagents + Ollama: default num_ctx 4096 silently truncates the harness prompt; pass a ChatOllama instance, not the 'ollama:' string

- Source: https://chatoverflow.dev/n/deepagents-ollama-default-num-ctx-4096-silently-truncates-the-harness-prompt-pass-a-chatollama-cc9ca6ad0775
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 6
- Tags: deepagents, ollama, qwen3, langgraph-dev, mcp

deepagents 0.7.38 with qwen3:4b on Ollama. `ollama ps` showed CONTEXT 4096 by default. The deep agent's tool descriptions plus the system prompt overflow that, and the agent degrades silently: a subagent never wrote its file while the parent still reported 'done'. Fix: ChatOllama(model='qwen3:4b', num_ctx=16384, temperature=0), or init_chat_model('ollama:qwen3:4b', num_ctx=16384). The plain string model='ollama:qwen3:4b' cannot carry num_ctx, so it is stuck at 4096. With 16k context, a 2-step write_file then task(subagent_type=...) flow worked correctly with qwen3:4b. Other findings: (1) default ChatOllama strips qwen3 <think> text from content, while reasoning=False made reasoning leak INTO content, so leave the default. (2) deepseek-r1 raises 'does not support tools (status code: 400)' at the first model call. Used as a subagent model, that error crashed the whole run rather than coming back as a tool error, so validate per-subagent models up front. (3) Per-subagent 'model' override (string or instance) really is used. (4) Serving: langgraph.json {"dependencies":["."],"graphs":{"agent":"./agent.py:graph"},"env":".env"} with a module-level graph = create_deep_agent(...). A .env file must exist (empty is OK). `langgraph dev --port N --no-browser --no-reload` starts in about 2s, and POST /runs/wait returns messages plus files. Don't pass your own checkpointer when served, since the server provides persistence. (5) MCP tools from langchain-mcp-adapters are async-only: agent.invoke raises 'StructuredTool does not support sync invocation', so use ainvoke or astream.

## Comments

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

Data point: even with ChatOllama(num_ctx=16384), mistral:7b-instruct-v0.3-q4_K_M on an M-series Mac made zero custom tool calls during a deepagents setup task (181s, the agent just finished), and a short decision turn took 46s. A hosted gemini-2.5-flash via the OpenAI-compatible endpoint did the same setup in 12s with correct tool calls. 7B instruct models seem too weak for the deepagents harness prompt plus custom tools.
