P.02Agents
Build an agent that completes multi-step tasks by calling a small set of well-defined tools, with explicit workflow state, step limits and predictable failure handling.
01
Agent demos often work once and then fail in unclear ways: a tool returns an error, the model repeats the same call, or the run drifts away from the original goal. Without structure, these failures are hard to reproduce and harder to fix.
In this project you build an agent that operates on a bounded task — for example, researching an internal issue tracker and drafting a summary — using typed tools, a persisted state object and clear stopping rules. You treat the model as one component in a controlled loop, not as the whole system.
02
A Python orchestrator runs a plan–act–observe loop. Each tool has a Pydantic input schema, timeouts and permission checks. Workflow state is persisted after every step so runs can be inspected, resumed or replayed.
plan
next action from goal + state
select tool
allow-listed registry only
validate args
schema check before running
execute
timeout + idempotency key
observe
append result to state
Exits
✓ respond
goal met, cite tool results
⏸ ask a human
approval required for write actions
✕ fail safely
step limit (8) or invalid tool call
Task intake
Validate the user request and create a run record with the goal, allowed tools and a step budget.
Plan
Ask the model to choose the next action from the registered tools, returned as a schema-validated tool call.
Execute tool
Run the tool with argument validation, a timeout and permission checks; capture results and errors as structured observations.
Update state
Append the observation to workflow state, persist it and check stop conditions such as goal reached or budget exhausted.
Recover or escalate
Retry transient failures with backoff, route repeated failures to a fallback path, and hand off to a human when needed.
Report
Produce a final answer along with a readable trace of every step, tool call and decision.
03
Suggested stack. Equivalent tools are fine; document the choice in your decision record.
04
Stage 01
Define three or four narrowly scoped tools with typed inputs and outputs, and test them without any model in the loop.
Stage 02
Implement the plan–act–observe loop with a step budget, persisted state and structured tool-call parsing.
Stage 03
Inject tool errors, timeouts and malformed calls, then add retries, fallbacks and a human-handoff path.
Stage 04
Add an allowlist of actions, confirmation steps for anything with side effects and limits on cost and run time.
Stage 05
Instrument each step with tracing, then review a batch of runs and document recurring failure patterns.
05
06
Build the foundations, projects, and habits needed to design more dependable AI applications.