langchain-ai/deepagents · error · ValueError
A thread id and workspace context are required for execution
Error message
A thread id and workspace context are required for execution.
What it means
ValueError raised by make_graph when the execution runtime is present but the request lacks the two things needed to run: a workspace context in the execution payload and a non-empty thread_id in config.configurable. Without both, the server cannot resolve the thread's bound workspace.
Source
Thrown at libs/code/deepagents_code/server_graph.py:634
return await _get_runtime()
async def make_graph(
config: dict[str, Any] | None = None,
runtime: LangGraphServerRuntime[CLIContextSchema] | None = None,
) -> Any: # noqa: ANN401
"""Return the graph after validating execution workspace context.
Raises:
ValueError: If execution context is missing or malformed.
"""
execution = runtime.execution_runtime if runtime is not None else None
if execution is not None:
context = CLIContextSchema.from_payload(execution.context)
thread_id = (config or {}).get("configurable", {}).get("thread_id")
if context is None or not isinstance(thread_id, str) or not thread_id:
msg = "A thread id and workspace context are required for execution."
raise ValueError(msg)
from deepagents_code.workspace import require_thread_workspace
binding = await require_thread_workspace(thread_id, context.workspace)
return (await _workspace_runtime(binding)).agent
return (await get_server_runtime()).agent
View on GitHub (pinned to a1af029e6e)
Solutions
- Pass a non-empty thread_id: config={"configurable": {"thread_id": "<id>"}}
- Ensure the execution context payload includes valid workspace context before invoking
- If you intended no workspace execution, invoke without an execution runtime so it uses the default server runtime
Example fix
// before
agent = await make_graph({}) # no thread id
// after
agent = await make_graph({"configurable": {"thread_id": thread_id}})
# with execution.context containing workspace info Defensive patterns
Strategy: validation
Validate before calling
thread_id = (config or {}).get("configurable", {}).get("thread_id")
if not isinstance(thread_id, str) or not thread_id:
raise ValueError("thread_id is required in config.configurable")
if execution_context_payload.get("workspace") is None:
raise ValueError("workspace context is required in execution context") Type guard
def has_thread_id(config: dict | None) -> TypeGuard[dict]:
tid = (config or {}).get("configurable", {}).get("thread_id")
return isinstance(tid, str) and bool(tid) Try / catch
try:
agent = await make_graph(config)
except ValueError as e:
if "thread id" in str(e):
config = {"configurable": {"thread_id": new_thread_id()}}
agent = await make_graph(config)
else:
raise Prevention
- Always generate/persist a thread_id before invoking the execution path
- Keep workspace context in the execution payload for every run
- Only invoke without thread/workspace when intentionally using the default runtime
- Assert configurable.thread_id in integration test harnesses
When it happens
Trigger: Invoking the graph with an execution context whose payload yields context=None, or with config missing / containing an empty or non-string configurable.thread_id.
Common situations: Calling the agent programmatically without a thread_id; a client that lost its session state; race where context payload was cleared; test harness invoking execution path without proper configurable.
Related errors
- modes can only be provided when agent is a factory
- models can only be provided when agent is a factory
- -32602
- Could not parse embedded resource block. Block expected eith
- question text must not be blank
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/54dca49f56a94a72.
Report an issue: GitHub.