langchain-ai/deepagents · error · ValueError

Invalid `interpreter_ptc` string {raw!r}; expected 'safe', '

Error message

Invalid `interpreter_ptc` string {raw!r}; expected 'safe', 'all', or a list of tool names.

What it means

_parse_interpreter_ptc accepts only the sentinel strings 'safe' and 'all' (case-insensitive) as scalar string values; any other string is rejected with this error listing the valid options. Strings are not treated as tool names at the scalar level — tool names must come as a list.

Source

Thrown at libs/code/deepagents_code/config.py:2441

            list containing `"all"`, or a string other than `"safe"`/`"all"`.
    """
    if raw is None or raw is False:
        return False
    if raw is True:
        msg = (
            "`interpreter_ptc` cannot be set to True; use 'safe', 'all', or "
            "an explicit list of tool names."
        )
        raise ValueError(msg)
    if isinstance(raw, str):
        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)."
                )

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Use exactly "safe" or "all" (spelling-insensitive) as the string value.
  2. If you meant one specific tool, write it as a list: interpreter_ptc = ["tool_name"].
  3. If you meant to disable it, use interpreter_ptc = false.

Example fix

// before
interpreter_ptc = "everything"
// after
interpreter_ptc = "all"  # or ["specific_tool"]
Defensive patterns

Strategy: validation

Validate before calling

VALID = {"safe", "all"}
if isinstance(raw, str) and raw.strip().lower() not in VALID:
    raise ValueError(f"interpreter_ptc string must be 'safe' or 'all'; got {raw!r}")

Type guard

def is_ptc_sentinel(v: object) -> bool:
    return isinstance(v, str) and v.strip().lower() in {"safe", "all"}

Try / catch

try:
    ptc = _parse_interpreter_ptc(raw)
except ValueError as e:
    sys.exit(f"invalid interpreter_ptc: {e}")

Prevention

When it happens

Trigger: Setting interpreter_ptc = "true", "yes", "everything", or a misspelled sentinel like "saef" / "ALL COMMANDS" in config or via coerce_toml_value.

Common situations: Typo in the sentinel, treating a single tool name as a bare string instead of a one-element list, or copying a boolean-style config from another tool.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/6b328f7a3b43a4bd. Report an issue: GitHub.