Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Why I Hand-Rolled a ReAct Loop Instead of Using LangChain

说明与用途

作者为 RepoPilot 项目构建了自定义 ReAct 循环,以获得对工具选择、LLM 提供商和可观测性的完全控制,而不是使用 LangChain,后者被证明不透明且受限于特定提供商。

问题

The author needed an agent that could inspect a local Git repository, communicate with an LLM through a provider‑agnostic interface, and record every decision for debugging, but LangChain’s opacity, provider lock‑in, and frequent API churn made it unsuitable.

结果

Phase 1 of RepoPilot is complete: a provider‑agnostic ReAct loop that calls a single git_status tool, records a structured JSON trace for every run, passes 68 automated tests, and runs end‑to‑end on a local repository.

工作流

  • Define a system prompt and user goal
  • Initialize messages with system and user roles
  • For each step up to max_steps:
  • Call LLM with current messages and tool schemas
  • If no tool calls, return LLM content
  • Append assistant message with LLM content
  • For each tool call: execute tool, append tool result as a message
  • Return final answer after loop or step limit

证据

I spent two days trying to make LangChain's AgentExecutor do what I wanted.

来源

When I tried to swap the LLM provider, the tracing broke.

来源

I wrote a ~270-line ReAct loop instead.

来源

Every agent run produces a structured trace. Every LLM call, every tool invocation, every result, every error.

来源

  • 记录日期: 2026-10-16T13:56:07.527Z