1. Project Goal
Apply the existing Agentic AI lessons by building a bounded local support agent that can inspect an order, use short-term state, retrieve an approved durable preference and stop safely when evidence or required input is missing.
2. What You Will Build
3. Skills / Prerequisites
Review unfamiliar foundations before implementing the project. Each link points to an existing lesson used by the workflow.
4. Dataset or Inputs
The synthetic domain contains one local order and one approved customer preference. No paid model or external tool is required. The deterministic decision function stands in for a model so the architecture, validation and traces remain reproducible.
Understand every project input
5. Architecture / Workflow
Assemble goal, instructions and relevant memory into the current context.
Let the decision layer propose an answer, clarification, tool call or abstention.
Validate the tool name and arguments in trusted code before execution.
Record the observation, update state and stop on success, safe failure or budget exhaustion.
Project figure
A bounded support agent operates inside an application shell
Who chooses the next action, and who enforces limits?
6. Environment / Dependencies
- Python 3.10+ standard library
- Local dictionaries for orders and memory
- No paid LLM required for the runnable trace
- Optional model adapter only after deterministic tests pass
7. Data or Input Understanding
State answers 'where is this run now?' and normally ends with the run. Persistent memory answers 'what approved information may help a later run?' and needs write, update and delete policy.
A tool schema describes valid arguments but does not grant permission. Trusted application code still checks identity, authorization, business policy and side effects.
8. Baseline / Simplest Working Approach
Start with ordinary code that handles one known question. Then add a model-directed decision only if natural-language variation makes fixed routing insufficient.
The simplest agent baseline must pass three tests: supported success, missing required input and unsupported/no-evidence abstention.
Project figure
Tools, state and memory serve different jobs
What is temporary, what persists, and what may change the outside world?
Worked Example: Calculate one bounded run's latency and cost
Given: A successful run uses two model decisions at 0.6 seconds and $0.004 each, plus one tool call at 0.3 seconds and $0.002.
- 1Model latency = 2 × 0.6 = 1.2 seconds.
- 2Total latency = 1.2 + 0.3 = 1.5 seconds because the steps are sequential.
- 3Model cost = 2 × $0.004 = $0.008.
- 4Total cost = $0.008 + $0.002 = $0.010.
Interpretation: The run succeeds in three charged operations. A retry would increase both totals, which is why step and cost ceilings are operational controls.
9. Step-by-Step Implementation
Step 1: Run the complete local agent
The function validates order_id, records every decision and returns controlled statuses. It does not claim to be a language model.
ORDERS = {1042: {"status": "shipped", "eta": "Friday"}}
MEMORY = {"customer_7": {"tone": "concise"}} # approved durable preference
MAX_STEPS = 5
def get_order(order_id: int):
if not isinstance(order_id, int):
raise ValueError("order_id must be an integer")
return ORDERS.get(order_id)
def run_support_agent(goal: str, order_id: int | None):
state = {"goal": goal, "step": 0, "observations": [], "trace": []}
for step in range(1, MAX_STEPS + 1):
state["step"] = step
if order_id is None:
state["trace"].append("abstain: missing order id")
return {"status": "needs_input", **state}
state["trace"].append(f"tool get_order({order_id})")
order = get_order(order_id)
if not order:
state["trace"].append("abstain: order not found")
return {"status": "not_found", **state}
state["observations"].append(order)
state["trace"].append("answer from verified observation")
return {"status": "success", "answer": order, **state}
return {"status": "budget_exhausted", **state}Step 2: Define the model boundary
If an LLM is later added, it may propose only one of these actions. Application code validates the proposal and owns execution.
Action = Answer(text) | GetOrder(order_id) | AskForOrderId() | Abstain(reason)
while state.step < MAX_STEPS:
proposal = model.choose(allowed_actions, context)
action = validate(proposal, user_permissions)
observation = execute(action)
state = record(state, action, observation)Step 3: Persist memory deliberately
Write only an approved stable preference, with provenance and deletion support. Do not store the entire conversation automatically.
memory_store.upsert(
subject="customer_7", key="response_tone", value="concise",
source="user-approved setting", expires_at=None
)10. Expected Results / Outputs
Read the output as evidence, not decoration
11. Evaluation
Score task success, correct tool choice, argument validity, evidence-grounded answer, safe abstention, step count, latency and cost. Inspect the full trajectory, not only the final sentence.
Create adversarial tests for malformed IDs, tool injection, stale memory, denied permissions, tool timeout and repeated no-progress loops.
Project figure
A trajectory makes success and safe abstention inspectable
What evidence should an evaluator see after the run?
12. Failure Analysis
Failure mode → diagnosis → response
13. Improve the Project
14. Production Considerations
What changes beyond the notebook
15. Summary / Key Takeaways
- An agent project begins with a bounded goal, allowed actions and explicit success and stop conditions.
- The model may propose a tool call, but trusted code validates permissions, policy and typed arguments.
- Short-term state records the current trajectory; persistent memory stores only approved facts for future runs.
- A step budget limits loops, latency and cost and ends in a controlled escalation or abstention.
- A successful trace must show which observation supports the answer.
- Safe failure is a required outcome when input, evidence, authority or progress is missing.
- Production agents need trajectory evaluation, durable checkpoints, idempotency, observability and rollback—not merely a stronger prompt.