Build an AI agent that reasons and acts using tools. ReAct loop with function calling, error recovery, and conversation memory.
## Task Build an AI agent using the ReAct (Reasoning + Acting) pattern with tool/function calling. ## Requirements - Language: TypeScript - LLM: Claude or GPT-4 via API - Pattern: ReAct loop (Thought → Action → Observation → repeat) ## Specifications ``` Tools available to the agent: - search(query: string) → search results - calculator(expression: string) → number - readFile(path: string) → file contents - writeFile(path: string, content: string) → success/failure Agent loop: 1. Receive user query 2. Think: what do I need to do? 3. Act: call a tool 4. Observe: process the result 5. Repeat until answer is found or max iterations reached ``` ## Implementation Notes 1. Use structured output for tool selection (JSON schema) 2. Implement retry logic for failed tool calls (max 3 retries) 3. Add conversation memory (last 10 turns) 4. Include a "give up" condition (max 5 iterations or explicit "I don't know") 5. Log each reasoning step for debugging 6. Handle tool errors gracefully — agent should recover, not crash ## Testing - Test with a query requiring 2+ tool calls - Test with an unanswerable query (agent should say it can't help) - Test with a tool that returns an error
No gallery images yet.