{"record":{"id":"fc91271e7cccb597","repo":"langchain-ai/deepagents","slug":"trusted-compaction-tool-must-be-named-compact-conv","errorCode":null,"errorMessage":"trusted_compaction_tool must be named compact_conversation","messagePattern":"trusted_compaction_tool must be named compact_conversation","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/auto_mode.py","lineNumber":2168,"sourceCode":"            trusted_ask_user_tool: Built-in tool allowed to create consent receipts.\n            trusted_compaction_tool: Built-in tool that performs conversation\n                compaction.\n\n        Raises:\n            ValueError: If a trusted tool has an unexpected name.\n        \"\"\"\n        if (\n            trusted_ask_user_tool is not None\n            and trusted_ask_user_tool.name != \"ask_user\"\n        ):\n            msg = \"trusted_ask_user_tool must be named ask_user\"\n            raise ValueError(msg)\n        if (\n            trusted_compaction_tool is not None\n            and trusted_compaction_tool.name != \"compact_conversation\"\n        ):\n            msg = \"trusted_compaction_tool must be named compact_conversation\"\n            raise ValueError(msg)\n        # The review deadline is a security control's budget, so reject a\n        # nonsensical one at the boundary rather than trusting every caller:\n        # a zero, negative, or NaN timeout expires immediately, silently turning\n        # Auto into \"deny every gated batch, then escalate\". Callers that read\n        # user config go through `resolve_auto_classifier_timeout`, which bounds\n        # the value; this guards programmatic construction.\n        for name, budget in (\n            (\"classifier_timeout_seconds\", classifier_timeout_seconds),\n            (\n                \"classifier_construction_timeout_seconds\",\n                classifier_construction_timeout_seconds,\n            ),\n        ):\n            if not math.isfinite(budget) or budget <= 0:\n                msg = f\"{name} must be a positive finite number, got {budget!r}\"\n                raise ValueError(msg)\n        interrupt_map = dict(interrupt_on)\n        interrupt_map[\"create_temp_artifact\"] = {","sourceCodeStart":2150,"sourceCodeEnd":2186,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/auto_mode.py#L2150-L2186","documentation":"Like the ask_user check, the optional `trusted_compaction_tool` passed to `AutoModeHITLMiddleware` must be named exactly `compact_conversation`, because the middleware dispatches on that name to treat compaction as a trusted operation. `__init__` raises this ValueError if a tool with a different name is supplied.","triggerScenarios":"Constructing `AutoModeHITLMiddleware(trusted_compaction_tool=<tool>)` where `<tool>.name != 'compact_conversation'` — e.g. a renamed compaction tool or a wrapper object with a different `.name`.","commonSituations":"Customizing the compaction tool's name for clarity; wrapping the standard compaction tool so `.name` changes; mixing up the order of the two trusted-tool constructor arguments.","solutions":["Set the tool's `.name` to exactly 'compact_conversation' before passing it.","Leave `trusted_compaction_tool` unset (None) to use the default built-in compaction tool.","Check argument order: ensure the ask_user tool is bound to `trusted_ask_user_tool` and the compaction tool to `trusted_compaction_tool`."],"exampleFix":"// before\nmw = AutoModeHITLMiddleware(trusted_compaction_tool=compaction_tool.with_config(name='summarize_thread'))\n// after\nmw = AutoModeHITLMiddleware(trusted_compaction_tool=compaction_tool)  # name must be 'compact_conversation'","handlingStrategy":"validation","validationCode":"tool = get_trusted_compaction_tool()\nif tool is not None and tool.name != 'compact_conversation':\n    raise ValueError(f\"fix: trusted_compaction_tool name is {tool.name!r}\")","typeGuard":"def is_trusted_compaction_tool(tool: BaseTool | None) -> bool:\n    return tool is None or tool.name == 'compact_conversation'","tryCatchPattern":"try:\n    mw = AutoModeHITLMiddleware(trusted_compaction_tool=tool)\nexcept ValueError as e:\n    if 'trusted_compaction_tool must be named compact_conversation' in str(e):\n        tool.name = 'compact_conversation'\n        mw = AutoModeHITLMiddleware(trusted_compaction_tool=tool)\n    else:\n        raise","preventionTips":["Keep compaction tool name exactly 'compact_conversation'.","Bind constructor arguments by keyword to avoid mixing up trusted_ask_user_tool and trusted_compaction_tool.","Prefer leaving the parameter unset to use the built-in compaction tool."],"tags":["validation","naming","auto-mode","constructor"],"backgroundTag":"trusted-tool-name-mismatch","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}