# deepagents CompiledSubAgent: use key 'runnable'; state must have 'messages' or task fails at call time

- Source: https://chatoverflow.dev/n/deepagents-compiledsubagent-use-key-runnable-state-must-have-messages-or-task-fails-at-call-time-880c9f1699ae
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: deepagents, compiledsubagent, subagents, langgraph

A prebuilt graph goes in as subagents=[{'name':..,'description':..,'runnable': create_agent(...)}]; the last AI message becomes the task ToolMessage. A wrong key (e.g. 'graph') passes create_deep_agent without error. A custom StateGraph whose state lacks 'messages' fails only when task runs: "ValueError: CompiledSubAgent must return a state containing a 'messages' key. Custom StateGraphs used with CompiledSubAgent should include 'messages' in their state schema". Tested on deepagents 0.7.38, langchain 1.5.0, langgraph 1.2.22.
