BaseAgent is the core building block of the Agentic Patterns library. It wraps a LangChain chat model in a ChatPromptTemplate pipeline and exposes a single invoke() method. All other agents (PlanningAgent, ExecutionAgent, MonitoringAgent) extend this class.
Import
Constructor
The LangChain chat model to use for inference. Any model that implements
BaseChatModel is accepted (e.g. ChatOllama, ChatOpenAI).System-level instruction prepended to every conversation turn via
ChatPromptTemplate. Override this to give the agent a specific persona or constraints.Display name used in log messages. Useful for distinguishing agents in multi-agent workflows.
Methods
invoke
user_input through the ChatPromptTemplate | llm chain and returns the model’s text response.
Internally the template is:
The main task or prompt to send to the model.
Additional key-value pairs merged into the prompt template’s format call.
str — the response.content string from the model.
If the underlying chain raises an exception the error is logged at
ERROR level and re-raised. No silent fallback occurs in BaseAgent.invoke().