{"record":{"id":"4e27d4c445ee57a6","repo":"langchain-ai/langchain","slug":"chat-model-tracing-is-not-supported-in-for-self","errorCode":null,"errorMessage":"Chat model tracing is not supported in for {self._schema_format} format.","messagePattern":"Chat model tracing is not supported in for (.+?) format\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"warning","filePath":"libs/core/langchain_core/tracers/core.py","lineNumber":194,"sourceCode":"        parent_run_id: UUID | None = None,\n        metadata: dict[str, Any] | None = None,\n        name: str | None = None,\n        **kwargs: Any,\n    ) -> Run:\n        \"\"\"Create a chat model run.\"\"\"\n        if self._schema_format not in {\"streaming_events\", \"original+chat\"}:\n            # Please keep this un-implemented for backwards compatibility.\n            # When it's unimplemented old tracers that use the \"original\" format\n            # fallback on the on_llm_start method implementation if they\n            # find that the on_chat_model_start method is not implemented.\n            # This can eventually be cleaned up by writing a \"modern\" tracer\n            # that has all the updated schema changes corresponding to\n            # the \"streaming_events\" format.\n            msg = (\n                f\"Chat model tracing is not supported in \"\n                f\"for {self._schema_format} format.\"\n            )\n            raise NotImplementedError(msg)\n        start_time = datetime.now(timezone.utc)\n        if metadata:\n            kwargs.update({\"metadata\": metadata})\n        return Run(\n            id=run_id,\n            parent_run_id=parent_run_id,\n            serialized=serialized,\n            inputs={\"messages\": [[dumpd(msg) for msg in batch] for batch in messages]},\n            extra=kwargs,\n            events=[{\"name\": \"start\", \"time\": start_time}],\n            start_time=start_time,\n            # WARNING: This is valid ONLY for streaming_events.\n            # run_type=\"llm\" is what's used by virtually all tracers.\n            # Changing this to \"chat_model\" may break triggering on_llm_start\n            run_type=\"chat_model\",\n            tags=tags,\n            name=name,\n        )","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/tracers/core.py#L176-L212","documentation":"on_chat_model_start creates the richer 'streaming_events' Run representation only when the tracer's schema format supports it. For tracers configured with the legacy 'original' (or other) format it deliberately raises NotImplementedError so older tracers fall back to on_llm_start — this is a controlled fallback mechanism, not a bug.","triggerScenarios":"A custom tracer subclass sets _schema_format='original' and does not override on_llm_start; calling on_chat_model_start directly on a tracer initialized with schema_format='original'.","commonSituations":"Writing custom BaseTracer subclasses for telemetry; copying old tracer implementations that never handled chat models; upgrading langchain-core versions where schema formats gained prominence.","solutions":["Implement on_llm_start in the custom tracer so the fallback has somewhere to land","Or configure the tracer with schema_format='streaming_events' / 'original+chat' so on_chat_model_start is supported","For library consumers: let unhandled NotImplementedError from on_chat_model_start propagate so the callback manager falls back — do not catch and ignore"],"exampleFix":"# before\nclass MyTracer(BaseTracer):\n    _schema_format = \"original\"\n    # on_chat_model_start not overridden -> NotImplementedError at runtime\n\n# after\nclass MyTracer(BaseTracer):\n    _schema_format = \"original\"\n\n    def on_llm_start(self, serialized, prompts, *, run_id, **kw):\n        run = self._create_llm_run(serialized, prompts, run_id, **kw)\n        self._start_trace(run)\n        # legacy-format chat model support via the on_llm_start fallback","handlingStrategy":"fallback","validationCode":"def tracer_supports_chat_models(tracer) -> bool:\n    return getattr(tracer, \"_schema_format\", None) in {\"streaming_events\", \"original+chat\"}","typeGuard":null,"tryCatchPattern":"# In custom tracers, deliberately DON'T catch this: raising NotImplementedError\n# from on_chat_model_start is the signal the callback manager uses to fall\n# back to on_llm_start. Instead, implement on_llm_start:\n\ntry:\n    tracer.on_chat_model_start(serialized, messages, run_id=rid)\nexcept NotImplementedError:\n    tracer.on_llm_start(\n        [str(m) for batch in messages for m in batch] if False else serialized,\n        [[str(m) for m in batch] for batch in messages],\n        run_id=rid,\n    )","preventionTips":["When subclassing BaseTracer with a legacy format, always implement on_llm_start","Set _schema_format='streaming_events' in new custom tracers","Don't swallow NotImplementedError from on_chat_model_start in callback managers — it drives the documented fallback"],"tags":["langchain","tracing","chat-model","schema-format","not-implemented"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}