langchain-ai/deepagents · error · ValueError
`interpreter_ptc` list entries must be non-empty strings; go
Error message
`interpreter_ptc` list entries must be non-empty strings; got {entry!r}. What it means
When interpreter_ptc is given as a list, _parse_interpreter_ptc requires every entry to be a non-empty string; entries like None, numbers, empty strings, or whitespace-only strings raise this error. This prevents silently allowing an unnamed or malformed tool.
Source
Thrown at libs/code/deepagents_code/config.py:2452
normalized = raw.strip().lower()
if normalized in {INTERPRETER_PTC_SAFE_SENTINEL, INTERPRETER_PTC_ALL_SENTINEL}:
return normalized
msg = (
f"Invalid `interpreter_ptc` string {raw!r}; expected 'safe', 'all', "
"or a list of tool names."
)
raise ValueError(msg)
if isinstance(raw, list):
if not raw:
return False
names: list[str] = []
for entry in raw:
if not isinstance(entry, str) or not entry.strip():
msg = (
"`interpreter_ptc` list entries must be non-empty strings; "
f"got {entry!r}."
)
raise ValueError(msg)
cleaned = entry.strip()
if cleaned.lower() == INTERPRETER_PTC_ALL_SENTINEL:
msg = (
"`interpreter_ptc` list entries cannot include 'all'; use "
"'all' as a standalone value or list explicit tool names "
"(optionally with the 'safe' preset)."
)
raise ValueError(msg)
names.append(cleaned)
return names
msg = (
f"`interpreter_ptc` must be False, 'safe', 'all', or a list of tool "
f"names; got {type(raw).__name__}."
)
raise ValueError(msg)
@dataclass(frozen=True)View on GitHub (pinned to a1af029e6e)
Solutions
- Remove empty, whitespace-only, and non-string entries from the list.
- Filter the list before writing it: [t for t in raw if isinstance(t, str) and t.strip()].
- If disabling PTC, use the empty list [] or false rather than an entry of empties.
Example fix
// before interpreter_ptc = ["bash", ""] // after interpreter_ptc = ["bash"]
Defensive patterns
Strategy: validation
Validate before calling
if isinstance(raw, str):
raw = [t for t in raw.split(",") if t.strip()]
if isinstance(raw, list):
raw = [t for t in raw if isinstance(t, str) and t.strip()] Type guard
def is_valid_tool_list(v: object) -> bool:
return isinstance(v, list) and all(isinstance(t, str) and t.strip() for t in v) Try / catch
try:
ptc = _parse_interpreter_ptc(raw_list)
except ValueError as e:
logger.error("bad interpreter_ptc list: %s", e)
ptc = False Prevention
- Filter empty strings when splitting comma-separated input
- Coerce TOML arrays to clean string lists at load time
- Reject null/numeric placeholders instead of passing them through
When it happens
Trigger: Passing interpreter_ptc = ["bash", "", 42] or ["bash", None] in config, or building the list programmatically with empty/whitespace entries from splitting an input string.
Common situations: Parsing a comma-separated env var with str.split(',') producing empty strings ('a,,b'), TOML arrays with placeholder empties, or generated configs inserting nulls.
Related errors
- -32602
- `interpreter_ptc` cannot be set to True; use 'safe', 'all',
- Invalid `interpreter_ptc` string {raw!r}; expected 'safe', '
- `interpreter_ptc` list entries cannot include 'all'; use 'al
- modes can only be provided when agent is a factory
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/223494ba9bb48ccb.
Report an issue: GitHub.