Agent Building
Intermediate
These concepts cover agents that complete multi-step tasks, use several tools, handle failures, track progress, and recover in code. This level is about building the control layer around the loop. The learner should be able to implement planning with correct task order, validated tool calls, state and context handling, error recovery, and replanning within execution limits, approval gates, and testable final output with reporting.
Key Concepts and Activities
- Planning and Task Dependencies
- Activities: Make the agent output a plan as a JSON task list with depends_on fields, and block tasks until their dependencies are done.
- Reason: A machine-readable plan with dependency checks turns free-form output into ordered execution.
- Example task: Build a task runner in which report writing cannot start until the research and outline tasks are marked as done.
- Tool Selection and Schemas
- Activities: Give the agent multiple tools with clear descriptions and typed input schemas, validate arguments before running, and fix wrong picks by iterating.
- Reason: Validation on both sides of a call keeps the loop stable and reduces wrong actions.
- Example task: Give an agent search, file, and calculator tools, run 10 mixed requests, log tool picks, and fix the two most common wrong picks.
- State and Context Management
- Activities: Build a state object for progress and results, and compress old history when it grows so the context stays small.
- Reason: Without a state, agents repeat work and forget results; bloated history costs accuracy.
- Example task: Build a state object that resumes a failed checklist from step 4, not step 1, and a compaction step that summarizes finished research before writing starts.
- Error Handling, Replanning, and Limits
- Activities: Detect failed tool calls in code, route to retry, skip, or ask the user, and trigger a replan that cannot repeat the failed action — all inside max attempts, timeouts, and loop detection.
- Reason: Real workflows hit dead ends; the agent must recover in code, not stall or loop.
- Example task: Handle a database lookup with no result: one retry with a broader query, then a replan with a different source, rejecting any plan that reuses the failed one, and stopping cleanly after two failed attempts.
- Validation and Approval Gates
- Activities: Write checks that verify tool outputs and final results against the goal, and pause the loop for user approval before real actions.
- Reason: Validation blocks bad data; approval gates block irreversible actions without consent.
- Example task: Build a validation function that lists exact missing fields before submission, and an approval gate that shows the full email draft before sending.
- Reporting and Workflow Testing
- Activities: Generate a final report from the state with completed and blocked tasks, and build test cases that check tool use, ordering, and failure handling.
- Reason: The report shows users what happened, and tests catch workflow breaks and manual checking misses.
- Example task: Build a 5-case test harness for a planning agent, including one failing tool, and verify that it replans and correctly reports the blocked task.