The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
docs: `create_agent` style and clarify `system_prompt` (#33470)
Mason Daugherty9105573cb331
diff --git a/libs/langchain_v1/langchain/agents/factory.py b/libs/langchain_v1/langchain/agents/factory.pyindex a373774538..32d3e9b6af 100644--- a/libs/langchain_v1/langchain/agents/factory.py+++ b/libs/langchain_v1/langchain/agents/factory.py@@ -537,13 +537,12 @@ def create_agent( # noqa: PLR0915(e.g., `"openai:gpt-4"`), a chat model instance (e.g., `ChatOpenAI()`).tools: A list of tools, dicts, or callables. If `None` or an empty list,the agent will consist of a model node without a tool calling loop.- system_prompt: An optional system prompt for the LLM. If provided as a string,- it will be converted to a SystemMessage and added to the beginning- of the message list.+ system_prompt: An optional system prompt for the LLM. Prompts are converted to a+ `SystemMessage` and added to the beginning of the message list.middleware: A sequence of middleware instances to apply to the agent.Middleware can intercept and modify agent behavior at various stages.response_format: An optional configuration for structured responses.- Can be a ToolStrategy, ProviderStrategy, or a Pydantic model class.+ Can be a `ToolStrategy`, `ProviderStrategy`, or a Pydantic model class.If provided, the agent will handle structured output during theconversation flow. Raw schemas will be wrapped in an appropriate strategybased on model capabilities.@@ -560,14 +559,14 @@ def create_agent( # noqa: PLR0915This is useful if you want to return directly or run additional processingon an output.debug: A flag indicating whether to enable debug mode.- name: An optional name for the CompiledStateGraph.+ name: An optional name for the `CompiledStateGraph`.This name will be automatically used when adding the agent graph toanother graph as a subgraph node - particularly useful for buildingmulti-agent systems.- cache: An optional BaseCache instance to enable caching of graph execution.+ cache: An optional `BaseCache` instance to enable caching of graph execution.Returns:- A compiled StateGraph that can be used for chat interactions.+ A compiled `StateGraph` that can be used for chat interactions.The agent node calls the language model with the messages list (after applyingthe system prompt). If the resulting AIMessage contains `tool_calls`, the graph will