{"record":{"id":"97fb0050cdae8b3b","repo":"langchain-ai/deepagents","slug":"invalid-interpreter-ptc-string-ptc-r-expected","errorCode":null,"errorMessage":"Invalid interpreter_ptc string {ptc!r}; expected 'safe', 'all', or a list of tool names.","messagePattern":"Invalid interpreter_ptc string (.+?); expected 'safe', 'all', or a list of tool names\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/agent.py","lineNumber":1040,"sourceCode":"                raise ValueError(msg)\n            # `all` can only enumerate the tools passed to `create_cli_agent`;\n            # SDK runtime built-ins (filesystem, `task`, …) are injected later\n            # and are not enumerable here. Exposing them under `all` needs an\n            # \"expose everything\" sentinel in `CodeInterpreterMiddleware`\n            # (tracked in langchain-ai/deepagents#3847).\n            included = sorted(live_set)\n            write_included = sorted(_INTERPRETER_WRITE_TOOLS & live_set)\n            if write_included:\n                logger.info(\n                    \"interpreter_ptc='all' includes write/shell tools: %s\",\n                    write_included,\n                )\n            return included\n        msg = (\n            f\"Invalid interpreter_ptc string {ptc!r}; expected 'safe', 'all', \"\n            \"or a list of tool names.\"\n        )\n        raise ValueError(msg)\n\n    if isinstance(ptc, list):\n        from deepagents_code.config import INTERPRETER_PTC_SAFE_PRESET\n\n        if any(name.strip().lower() == \"all\" for name in ptc):\n            msg = (\n                \"interpreter_ptc list entries cannot include 'all'; use 'all' \"\n                \"as a standalone value or list explicit tool names (optionally \"\n                \"with the 'safe' preset).\"\n            )\n            raise ValueError(msg)\n\n        resolved: list[str] = []\n        seen: set[str] = set()\n\n        def _add(name: str) -> None:\n            if name not in seen:\n                seen.add(name)","sourceCodeStart":1022,"sourceCodeEnd":1058,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/agent.py#L1022-L1058","documentation":"_resolve_ptc_option normalizes the interpreter_ptc option into a list of tool names exposed to Python-tool-call (PTC) execution. A string value must be exactly 'safe' or 'all' (after strip/lower); anything else is rejected so an unrecognized sentinel never silently narrows or widens the exposed toolset. This is an eager fail-fast ValueError raised at agent construction time.","triggerScenarios":"Calling create_cli_agent(interpreter_ptc=<str>) where the string is not 'safe' or 'all' — e.g. interpreter_ptc=' Safe-Mode ', interpreter_ptc='builtin', interpreter_ptc='ALL ' is fine but 'everything', 'none' (use False), or a single tool name passed as a string instead of a list all raise.","commonSituations":"Config-file value like interpreter_ptc = \"safe-preset\" or \"enabled\"; passing a single tool name as a bare string instead of a one-element list; typos like 'safelist' or 'whitelist'; copying an older option value that predates the 'safe'/'all' sentinel vocabulary.","solutions":["Use exactly 'safe' for the curated preset or 'all' (with interpreter_ptc_acknowledge_unsafe=True or auto_approve=True) — the check is case-insensitive and whitespace-tolerant, so casing is not the issue.","If you meant one specific tool, pass a list: interpreter_ptc=[\"execute\"].","If you meant to disable PTC, pass interpreter_ptc=False.","Check the configured value in your dcode config file / env mapping for typos or stale values."],"exampleFix":"// before\ncreate_cli_agent(interpreter_ptc=\"safe-preset\")\n// after\ncreate_cli_agent(interpreter_ptc=\"safe\")\n// or for one tool\ncreate_cli_agent(interpreter_ptc=[\"execute\"])","handlingStrategy":"validation","validationCode":"VALID = {\"safe\", \"all\"}\nif isinstance(ptc, str) and ptc.strip().lower() not in VALID:\n    raise ValueError(f\"interpreter_ptc must be 'safe' or 'all', got {ptc!r}\")","typeGuard":"def is_valid_ptc_string(v: object) -> TypeGuard[Literal['safe', 'all']]:\n    return isinstance(v, str) and v.strip().lower() in {\"safe\", \"all\"}","tryCatchPattern":"try:\n    agent = create_cli_agent(interpreter_ptc=ptc)\nexcept ValueError as exc:\n    logger.error(\"Bad interpreter_ptc value: %s\", exc)\n    agent = create_cli_agent(interpreter_ptc=\"safe\")","preventionTips":["Treat interpreter_ptc as an enum: only pass the literals 'safe', 'all', or False.","Pass single tool names as a one-element list, never a bare string.","Centralize the value in one config constant instead of repeating string literals."],"tags":["python","configuration","valueerror","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}