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

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

Описание и применение

Автор создал собственный ReAct‑цикл для проекта RepoPilot, чтобы иметь полный контроль над выбором инструментов, 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