Create

Sign in to ReadmeX

or

How we handle your data: Privacy Policy

ReadmeX

Your AI reading companion

What would you like to catch up on?

Pick a briefing, or ask your own question.

Your community and people briefings stay personal to you.

Story

Building a LangChain Agent with Tools, Structured Output, and Streaming

AI summary

A tutorial explains how to build an assistant with LangChain’s create_agent. It covers tool definitions, automatic tool-call loops, runtime context, schema-based structured output, retries for invalid structured responses, and streaming events. The article describes create_agent as LangChain’s minimal Harness implementation and concludes with an example combining multiple tools, structured output, and streaming.

In-depth insight

The tutorial shows developers how to assemble a runnable LangChain assistant without manually implementing the tool-calling loop or constructing ToolMessage objects.

LangChain Agent智能助手构建笔记:创建、工具调用、结构化输出与流式输出

1. 智能助手的核心公式

LangChain 官方将 Agent 定义为 “模型 + Harness(执行框架)”。Harness 是模型循环之外的一切:提示词、工具、中间件、状态管理。create_agent 就是这个 Harness 的最小实现,让你用最少的代码组装出一个可运行的智能助手[citation:1][citation:9]。

一个智能助手的最小闭环是:用户输入 → 模型决策 → 调用工具(如果需要)→ 结果回传 → 模型组织最终回复。你之前学过的 Tool Calling 闭环、Message 流转、结构化输出,都在这个循环里各司其职。


#LangChain#create_agent#LangGraph#LangSmith

Original · 7 min readRead the original
Group chat

No comments yet. Start the conversation.