langchain-ai/deepagents · error · RequestError
-32602
-32602
Error message
cwd: must match the working directory used to create the session
What it means
Every `[models].allowed` entry must be a non-empty string in `provider:model` form; `parse_model_allowlist` raises `ValueError` for non-string entries or blank strings. This keeps a silently-broken allowlist from degrading into an unintended deny-all.
Source
Thrown at libs/acp/deepagents_acp/server.py:415
session_id: str,
additional_directories: list[str] | None = None, # noqa: ARG002 # capability is not advertised
mcp_servers: list[McpServer] | None = None,
**kwargs: Any, # noqa: ARG002 # ACP protocol interface parameter
) -> LoadSessionResponse:
"""Restore and replay a persisted ACP session."""
if not self._load_sessions:
method = "session/load"
raise RequestError.method_not_found(method)
self._session_cwds[session_id] = cwd
agent = self._checkpointed_agent(session_id)
metadata = (await agent.aget_state(self._session_config(session_id))).metadata or {}
if metadata.get(_ACP_SESSION_METADATA_KEY) is not True:
self._forget_session(session_id)
raise RequestError.resource_not_found(session_id)
if metadata.get("cwd") != cwd:
self._forget_session(session_id)
raise RequestError.invalid_params(
{"cwd": "must match the working directory used to create the session"}
)
self._session_mcp_servers[session_id] = list(mcp_servers or [])
self._initialize_session_options(session_id)
if self._restore_session_options(session_id, metadata):
self._reset_agent(session_id)
await self._replay_session(session_id, agent)
return LoadSessionResponse(
modes=self._session_mode_states.get(session_id),
config_options=self._build_config_options(session_id) or None,
)
async def set_session_mode(
self,
mode_id: str,
session_id: str,View on GitHub (pinned to a1af029e6e)
Solutions
- Remove empty or non-string entries from the array
- Ensure every entry is a quoted `provider:model` or `provider:*` string
- Regenerate or re-check the config after automated edits/templates
Example fix
# before allowed = ["", "anthropic:claude-sonnet-4-5"] # after allowed = ["anthropic:claude-sonnet-4-5"]
Defensive patterns
Strategy: validation
Validate before calling
def clean_allowlist(entries: object) -> list[str]:
if not isinstance(entries, list):
raise TypeError("expected a list")
cleaned = [e for e in entries if isinstance(e, str) and e.strip()]
if len(cleaned) != len(entries):
raise ValueError("allowlist contains empty or non-string entries")
return cleaned Type guard
def is_allowlist_value(value: object) -> bool:
return isinstance(value, list) and all(
isinstance(e, str) and e.strip() for e in value
) Try / catch
try:
parsed = parse_model_allowlist(raw)
except ValueError as exc:
logger.error("malformed [models].allowed: %s", exc)
parsed = () Prevention
- Filter empty strings out of generated config arrays
- Keep every allowlist entry a quoted string — no bare numbers/booleans
- Review templated config output for leftover empty placeholders
When it happens
Trigger: An entry like `allowed = ["", "anthropic:claude-sonnet-4-5"]`, `allowed = [42]`, `allowed = [true]`, or whitespace-only `" "` in the TOML array.
Common situations: Leftover empty string from templated config generation; wrong TOML type (integer/boolean) in the array; entries removed leaving an empty `""` behind.
Related errors
- -32002
- modes can only be provided when agent is a factory
- models can only be provided when agent is a factory
- recursion_limit must be None or a positive integer
- `interpreter_ptc` cannot be set to True; use 'safe', 'all',
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/b66c69e8316662ba.
Report an issue: GitHub.