Building the agent core

The agent core is the control loop: receive a query, plan subtasks, execute tools, observe results, and synthesize a response. The implementation must handle tool failures, timeouts, malformed outputs, and planning errors without crashing or producing incorrect results.