{"record":{"id":"1770cd89e76cfc3f","repo":"langchain-ai/deepagents","slug":"dynamic-deprecation-warning-message-from-captured","errorCode":null,"errorMessage":"<dynamic deprecation warning message from captured record>","messagePattern":"<dynamic deprecation warning message from captured record>","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"libs/deepagents/deepagents/_api/deprecation.py","lineNumber":97,"sourceCode":"    \"\"\"\n    with warnings.catch_warnings(record=True) as captured:\n        warnings.simplefilter(\"always\")\n        _lc_warn_deprecated(\n            since,\n            message=message,\n            name=name,\n            alternative=alternative,\n            alternative_import=alternative_import,\n            pending=pending,\n            obj_type=obj_type,\n            addendum=addendum,\n            removal=removal,\n            package=package,\n        )\n    if not captured:\n        return\n    record = captured[0]\n    warnings.warn(record.message, category=record.category, stacklevel=stacklevel + 1)\n\n\ndef reset_deprecation_dedupe(*targets: object) -> None:\n    \"\"\"Reset the `@deprecated` decorator's dedupe flag for testing.\n\n    The langchain_core `@deprecated` decorator emits each warning at most once\n    per process via a closure-bound `warned` flag. Tests that assert per-call\n    emission must reset that flag between cases — otherwise the assertions\n    become reorder-sensitive (notably under `pytest -n auto`).\n\n    Accepts decorated functions, methods, and `property` objects (in which\n    case the `fget` closure is reset). Targets without the expected `warned`\n    freevar are silently skipped, so passing non-decorated callables is safe.\n\n    Args:\n        *targets: Decorated callables (or properties wrapping them) to reset.\n    \"\"\"\n    for target in targets:","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/_api/deprecation.py#L79-L115","documentation":"This is a LangChainDeprecationWarning emitted by deepagents' `warn_deprecated` helper (a wrapper around `langchain_core._api.deprecation.warn_deprecated`). It fires when your code calls an API, parameter, or value that deepagents has deprecated; the wrapper re-emits the upstream-formatted warning with a corrected stacklevel so it points at your actual call site. It is informational: the API still works, but it will be removed (or has a scheduled removal version).","triggerScenarios":"Any call into deepagents code that invokes `warn_deprecated` internally: accessing a module-level `__getattr__` alias for a moved symbol, calling `create_deep_agent` with a deprecated parameter/value, calling a function or property wrapped in `@deprecated`, or calling an internal `helper` marked deprecated. Emission is deduped per process by the `@deprecated` decorator's `warned` closure flag (resettable via `reset_deprecation_dedupe` for tests).","commonSituations":"Upgrading deepagents past a version that renamed `create_deep_agent` parameters or moved public symbols; importing a symbol from its old module path; test suites that surface DeprecationWarning because `filterwarnings = error` is enabled; running old example/snippet code against a newer release.","solutions":["Read the warning message: it names the deprecated object, the `since` version, and the recommended `alternative`/`alternative_import`.","Migrate to the suggested replacement (new parameter name, new import path, or new function).","If the warning comes from a third-party dependency you cannot change, silence it narrowly with `warnings.filterwarnings('ignore', category=LangChainDeprecationWarning, message='...')` scoped to the offending call.","Pin the current deepagents version temporarily if you cannot migrate yet, and plan the migration before the stated removal version."],"exampleFix":"// before\nfrom deepagents import old_module\nagent = old_module.create_deep_agent(tools=tools, deprecated_param=True)\n\n// after\nfrom deepagents import create_deep_agent\nagent = create_deep_agent(tools=tools, new_param=True)","handlingStrategy":"try-catch","validationCode":"// check for deprecated usage before calling\nimport warnings\nwith warnings.catch_warnings(record=True) as w:\n    warnings.simplefilter(\"always\")\n    result = call_api(...)\n    deprecations = [x for x in w if issubclass(x.category, DeprecationWarning)]\n    assert not deprecations, [str(x.message) for x in deprecations]","typeGuard":"null","tryCatchPattern":"import warnings\nfrom deepagents._api.deprecation import LangChainDeprecationWarning\nwith warnings.catch_warnings():\n    warnings.filterwarnings(\"error\", category=LangChainDeprecationWarning)\n    try:\n        result = call_api(...)\n    except LangChainDeprecationWarning as dw:\n        migrate_to(dw.message)  # warning text names the alternative\n        result = call_api(...)","preventionTips":["Run CI with `-W error::DeprecationWarning` to catch deprecated usage at test time.","Check the changelog/upgrading guide when bumping deepagents minor versions.","Prefer the import paths and parameter names shown in current docs over old snippets.","Pin and review deprecation warnings in dependency update PRs."],"tags":["deprecation","python","api-migration","langchain"],"backgroundTag":"deprecation-warning","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}