Skip to content

Challenge 001: Build an Agent Loop from ScratchΒΆ

Level: L100 Type: Challenge Time: ~60 min πŸ’° Cost: Free (local)

ScenarioΒΆ

OutdoorGear wants a tiny product-assistant agent that can reason over a local product catalog. The team does not want to use Semantic Kernel, LangGraph, AutoGen, or any hosted LLM yet. First, they want to prove that you understand the core loop:

perceive β†’ decide β†’ act β†’ observe β†’ answer

Your job is to finish a small Python agent loop that chooses tools, executes them, stores observations, and produces a grounded final answer.


ObjectiveΒΆ

Implement the missing logic in starter_agent_loop.py so the local product assistant can complete the two target requests and produce a validation code.

You should end with an agent that can:

  • Search for matching products using category, query words, budget, and stock filters
  • Look up product details by SKU
  • Recommend a small in-stock camping bundle under a budget
  • Run a loop that calls exactly one tool before producing a final answer for supported requests
  • Return a trace showing what the agent did

Starter FilesΒΆ

Save these files in one folder named challenge-001/:

File Purpose Download
products.json Mock OutdoorGear product catalog Download
starter_agent_loop.py Starter implementation with TODOs Download
test_agent_loop.py Acceptance tests Download
validate_agent_loop.py Generates the final completion code Download

Challenge BriefΒΆ

You receive a product catalog, a starter implementation, and tests. There is no walkthrough: decide how to parse the request, choose a tool, execute it, store the observation, and produce the final answer.


ConstraintsΒΆ

  • Use only the Python standard library in starter_agent_loop.py.
  • Do not call an LLM API.
  • Do not use an agent framework.
  • Keep the loop readable: the point is to understand the control flow.
  • Preserve the return shape from run_agent():
{
    "final_answer": "...",
    "trace": [
        {"step": 1, "type": "tool", "tool": "...", "arguments": {...}},
        {"step": 2, "type": "final"}
    ]
}

Acceptance CriteriaΒΆ

Your solution is complete when:

  • python -m pytest test_agent_loop.py passes
  • The jacket request calls search_products before answering
  • The camping bundle request calls recommend_bundle before answering
  • The final answer includes product names, prices, and a short rationale
  • Out-of-stock products are not recommended
  • The loop stops with a final answer before max_steps

ValidationΒΆ

When your implementation is ready, run:

python -m pytest test_agent_loop.py
python validate_agent_loop.py

Enter the completion code printed by validate_agent_loop.py:


HintsΒΆ

Hint 1 β€” Start with tools

The loop is easier to reason about when each tool has a clear contract and deterministic output.

Hint 2 β€” Keep parsing simple

You do not need advanced NLP. The target requests are intentionally narrow.

Hint 3 β€” Use observations as memory

state.observations is the loop's short-term memory. After a tool runs, the final answer should be based on the latest observation, not on the original catalog.

Hint 4 β€” Decide deterministically

A good solution makes the same decision every time for the same state.


RubricΒΆ

Area Points What good looks like
Tool correctness 30 Filters, SKU lookup, and bundle selection are accurate
Agent loop 30 Clear perceive β†’ decide β†’ act β†’ observe β†’ answer flow
Grounded answer 20 Answer uses tool observations and names concrete products
Traceability 10 Trace shows tool call and final step
Simplicity 10 No unnecessary framework, API, or over-engineering

Stretch GoalsΒΆ

  • Add support for "compare two SKUs"
  • Add an error answer when no product matches
  • Add a second tool call before the final answer for ambiguous requests
  • Add a max_price parser that handles $150, 150 dollars, and under 150