{"record":{"id":"b938d83b36b2c755","repo":"langchain-ai/langchain","slug":"the-dispatcher-api-does-not-accept-additional-keyw","errorCode":null,"errorMessage":"The dispatcher API does not accept additional keyword arguments.Please do not pass any additional keyword arguments, instead include them in the data field.","messagePattern":"The dispatcher API does not accept additional keyword arguments\\.Please do not pass any additional keyword arguments, instead include them in the data field\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/callbacks/manager.py","lineNumber":1667,"sourceCode":"        tailored to their application.\n\n        Args:\n            name: The name of the adhoc event.\n            data: The data for the adhoc event.\n            run_id: The ID of the run.\n\n        Raises:\n            ValueError: If additional keyword arguments are passed.\n        \"\"\"\n        if not self.handlers:\n            return\n        if kwargs:\n            msg = (\n                \"The dispatcher API does not accept additional keyword arguments.\"\n                \"Please do not pass any additional keyword arguments, instead \"\n                \"include them in the data field.\"\n            )\n            raise ValueError(msg)\n        if run_id is None:\n            run_id = uuid7()\n\n        handle_event(\n            self.handlers,\n            \"on_custom_event\",\n            \"ignore_custom_event\",\n            name,\n            data,\n            run_id=run_id,\n            tags=self.tags,\n            metadata=self.metadata,\n        )\n\n    @classmethod\n    def configure(\n        cls,\n        inheritable_callbacks: Callbacks = None,","sourceCodeStart":1649,"sourceCodeEnd":1685,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/callbacks/manager.py#L1649-L1685","documentation":"`CallbackManager.on_custom_event` (manager.py) raises `ValueError` when callers pass extra `**kwargs`. The dispatcher API deliberately accepts only `name` and `data`; arbitrary keyword arguments are rejected so event payloads stay serializable and handler signatures stay stable. Put everything in the `data` dict instead.","triggerScenarios":"Calling `callback_manager.on_custom_event('my_event', payload, foo='bar')` (sync variant) — any non-empty kwargs dict triggers it; copying a call from user code to `adispatch_custom_event` while keeping kwargs; older snippets that passed `run_id=` or metadata as kwargs.","commonSituations":"Adapting pre-1.0 examples that spread kwargs into the event call; trying to attach run_id/tags per-call (must go through config or `data`); IDE autocompletion suggesting arbitrary kwargs because the signature has `**kwargs` only to raise on it.","solutions":["Move every extra keyword into the `data` dict: `on_custom_event('evt', {'foo': 'bar', ...})`","If you meant to set the run id, pass it positionally/dedicated parameter or dispatch from within a run via `dispatch_custom_event`","Audit call sites for `**` unpacking into the dispatcher call","Add a lint/test that asserts dispatcher calls use only (name, data)"],"exampleFix":"# before\nmanager.on_custom_event(\"tool_feedback\", result, user_id=\"42\")\n\n# after\nmanager.on_custom_event(\"tool_feedback\", {\"result\": result, \"user_id\": \"42\"})","handlingStrategy":"validation","validationCode":"def dispatch(manager, name: str, data: dict) -> None:\n    # enforce (name, data)-only contract before the manager does\n    manager.on_custom_event(name, data)\n\n# lint-level guard: reject call sites with extra kwargs\ndef _no_kwargs(**kw):\n    if kw:\n        raise TypeError('use data= for payloads')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrap dispatcher calls in a helper that only accepts (name, data)","Put metadata inside the data dict by convention","Grep codebase for `on_custom_event(` with trailing kwargs during reviews"],"tags":["callbacks","events","api-contract","validation"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}