langchain-ai/langchain · warning · NotImplementedError
Chat model tracing is not supported in for {self._schema_for
Error message
Chat model tracing is not supported in for {self._schema_format} format. What it means
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.
Source
Thrown at libs/core/langchain_core/tracers/core.py:194
parent_run_id: UUID | None = None,
metadata: dict[str, Any] | None = None,
name: str | None = None,
**kwargs: Any,
) -> Run:
"""Create a chat model run."""
if self._schema_format not in {"streaming_events", "original+chat"}:
# Please keep this un-implemented for backwards compatibility.
# When it's unimplemented old tracers that use the "original" format
# fallback on the on_llm_start method implementation if they
# find that the on_chat_model_start method is not implemented.
# This can eventually be cleaned up by writing a "modern" tracer
# that has all the updated schema changes corresponding to
# the "streaming_events" format.
msg = (
f"Chat model tracing is not supported in "
f"for {self._schema_format} format."
)
raise NotImplementedError(msg)
start_time = datetime.now(timezone.utc)
if metadata:
kwargs.update({"metadata": metadata})
return Run(
id=run_id,
parent_run_id=parent_run_id,
serialized=serialized,
inputs={"messages": [[dumpd(msg) for msg in batch] for batch in messages]},
extra=kwargs,
events=[{"name": "start", "time": start_time}],
start_time=start_time,
# WARNING: This is valid ONLY for streaming_events.
# run_type="llm" is what's used by virtually all tracers.
# Changing this to "chat_model" may break triggering on_llm_start
run_type="chat_model",
tags=tags,
name=name,
)View on GitHub (pinned to e32fa9a52e)
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
Example fix
# before
class MyTracer(BaseTracer):
_schema_format = "original"
# on_chat_model_start not overridden -> NotImplementedError at runtime
# after
class MyTracer(BaseTracer):
_schema_format = "original"
def on_llm_start(self, serialized, prompts, *, run_id, **kw):
run = self._create_llm_run(serialized, prompts, run_id, **kw)
self._start_trace(run)
# legacy-format chat model support via the on_llm_start fallback Defensive patterns
Strategy: fallback
Validate before calling
def tracer_supports_chat_models(tracer) -> bool:
return getattr(tracer, "_schema_format", None) in {"streaming_events", "original+chat"} Try / catch
# In custom tracers, deliberately DON'T catch this: raising NotImplementedError
# from on_chat_model_start is the signal the callback manager uses to fall
# back to on_llm_start. Instead, implement on_llm_start:
try:
tracer.on_chat_model_start(serialized, messages, run_id=rid)
except NotImplementedError:
tracer.on_llm_start(
[str(m) for batch in messages for m in batch] if False else serialized,
[[str(m) for m in batch] for batch in messages],
run_id=rid,
) Prevention
- 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
When it happens
Trigger: 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'.
Common situations: Writing custom BaseTracer subclasses for telemetry; copying old tracer implementations that never handled chat models; upgrading langchain-core versions where schema formats gained prominence.
Related errors
- RunnableEach does not support astream_events yet.
- Tool does not support sync invocation.
- StructuredTool does not support sync invocation.
- If env_var is set, handle_class must also be set to a non-No
- No indexed run ID {run_id}.
AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14).
Data as JSON: /api/errors/4e27d4c445ee57a6.
Report an issue: GitHub.