An LLM agent combines reasoning, tool use, and memory in a loop until a goal is met. Patterns like ReAct (think→act→observe), Plan-and-Execute (decompose first), and Reflexion (self-critique) provide reliable scaffolding around the model's autonomous decisions.
ReAct loop: Thought → Action → Observation, repeated until Done.
Each new tool grows the prompt and confuses the model. Curate to <10 tools per agent; merge similar ones.
Always set max_iterations (e.g., 10). Runaway agents burn tokens. Add a "give up gracefully" exit.
Long ReAct chains exceed context. Summarize older steps; keep only the last few raw observations.
For multi-step goals, Plan-and-Execute beats ReAct: cheaper plan with mini model, execute with stronger model.
On failure, ask the LLM to critique its trajectory and retry. Lifts task success ~10-20% with minor cost.
Persist (thought, action, observation) tuples. Critical for debugging "why did it do that?" in production.
Sign in to share your feedback and join the discussion.