{"record":{"id":"5454a95274c8fde4","repo":"langchain-ai/deepagents","slug":"harnessprofile-excluded-middleware-entries-matched","errorCode":null,"errorMessage":"HarnessProfile.excluded_middleware entries matched no middleware across any assembled stack: {', '.join(labels)}. Typo or stale profile — every exclusion must correspond to a middleware actually present at runtime. (Tip: use class-form exclusion when the class is available to catch typos at import time.)","messagePattern":"HarnessProfile\\.excluded_middleware entries matched no middleware across any assembled stack: (.+?)\\. Typo or stale profile — every exclusion must correspond to a middleware actually present at runtime\\. \\(Tip: use class-form exclusion when the class is available to catch typos at import time\\.\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/_excluded_middleware.py","lineNumber":225,"sourceCode":"            excluded_names.add(entry)\n\n    unmatched_classes = excluded_classes - matched_classes - required_classes\n    unmatched_names = excluded_names - matched_names - required_names\n    # Private-prefix names are rejected by the config guard; skip them here\n    # so the coverage error stays focused on legitimate \"didn't match\" cases.\n    unmatched_names = {name for name in unmatched_names if not name.startswith(\"_\")}\n    if not unmatched_classes and not unmatched_names:\n        return\n\n    labels = sorted({cls.__name__ for cls in unmatched_classes} | {f\"{name!r} (string)\" for name in unmatched_names})\n    msg = (\n        f\"HarnessProfile.excluded_middleware entries matched no middleware \"\n        f\"across any assembled stack: {', '.join(labels)}. Typo or stale \"\n        f\"profile — every exclusion must correspond to a middleware actually \"\n        f\"present at runtime. (Tip: use class-form exclusion when the class \"\n        f\"is available to catch typos at import time.)\"\n    )\n    raise ValueError(msg)\n","sourceCodeStart":207,"sourceCodeEnd":226,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/_excluded_middleware.py#L207-L226","documentation":"`create_deep_agent` verifies that every entry in `HarnessProfile.excluded_middleware` actually matched a middleware in the assembled runtime stacks. If one or more entries matched nothing anywhere, `_verify_excluded_middleware_coverage` raises `ValueError` naming the unmatched entries, since a no-op exclusion almost always indicates a typo or a stale profile referencing middleware that no longer exists.","triggerScenarios":"Passing a `HarnessProfile` whose `excluded_middleware` contains a class not included in any stack, or a string name matching no middleware class present at runtime (typo, renamed class, middleware removed in a newer version).","commonSituations":"Upgrading the library where a middleware was renamed/removed while the profile still lists the old name; misspelling a string exclusion; excluding middleware that is conditionally not assembled for the chosen configuration.","solutions":["Remove or correct the unmatched entry in `excluded_middleware` (fix the typo or delete the stale name).","Prefer class-form exclusions so typos are caught at import time (`NameError` instead of runtime `ValueError`).","Check the installed library version and update the profile to the current middleware names."],"exampleFix":"// before\nHarnessProfile(excluded_middleware=[\"SumarizationMiddleware\"])  # typo\n// after\nfrom deepagents import SummarizationMiddleware\nHarnessProfile(excluded_middleware=[SummarizationMiddleware])","handlingStrategy":"validation","validationCode":"available = {cls.__name__ for stack in stacks for cls in stack_middleware_classes(stack)}\nunmatched = [m for m in profile.excluded_middleware if name_of(m) not in available]\nif unmatched:\n    raise ValueError(f\"exclusions match nothing: {unmatched}\")","typeGuard":null,"tryCatchPattern":"try:\n    agent = create_deep_agent(profile=profile, ...)\nexcept ValueError as e:\n    if \"matched no middleware\" in str(e):\n        profile = prune_stale_exclusions(profile)\n        agent = create_deep_agent(profile=profile, ...)\n    else:\n        raise","preventionTips":["Use class-form exclusions so typos fail at import time.","After upgrading the library, diff profile exclusions against current middleware names.","Derive exclusions from an explicit list of imported classes, not hand-typed strings."],"tags":["configuration","harness-profile","middleware","typo"],"backgroundTag":"stale-middleware-exclusion","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}