Performance: ReAct agent implementation
This affects the responsiveness and speed of AI agent interactions by controlling how reasoning and actions are processed and rendered.
Jump into concepts and practice - no test required
async function reactAgent(input) { const reasoningPromise = reason(input); const actionPromise = reasoningPromise.then(reasoning => act(reasoning)); return await actionPromise; }
async function reactAgent(input) { const reasoning = await reason(input); // blocks until done const action = await act(reasoning); // blocks until done return action; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Sequential blocking awaits | Minimal DOM changes | 0 reflows | Low paint cost | [!] OK but blocks interaction |
| Asynchronous promise chaining | Minimal DOM changes | 0 reflows | Low paint cost | [OK] Good for responsiveness |
from langchain.agents import ReActAgent
from langchain.llms import OpenAI
llm = OpenAI(temperature=0)
tools = [search_tool, calculator_tool]
agent = ReActAgent(llm=llm, tools=tools)
response = agent.run('What is the capital of France and what is 5 plus 3?')TypeError: ReActAgent.__init__() missing 1 required positional argument: 'llm'