FiddlerAgentMiddleware when
creating LLM spans. Supports both plain model instances and
RunnableBinding.
Passing None removes the context so that subsequent spans no longer
carry it. This is useful in multi-step agent workflows where context set
after a RAG step should not leak into later non-RAG LLM calls.
Parameters
The language model (or binding) to attach context to.
The context string to attach, or
None to clear.Raises
TypeError – If aRunnableBinding is provided but its bound
object is not a BaseLanguageModel.
Returns
None Example: default from langchain_openai import ChatOpenAI from fiddler_langchain import set_llm_context llm = ChatOpenAI(model=“gpt-4o”) set_llm_context(llm, “User prefers concise responses”) # Clear context before non-RAG steps set_llm_context(llm, None)