promptdojo_

Write mini_harness(user_input, tools, fake_model, max_iters) that implements the four layers in under 50 lines:

  • Layer 1: build messages = [{"role": "user", "content": user_input}].
  • Loop up to max_iters times:
    • Layer 2: call fake_model(messages) (returns a dict with stop_reason and content).
    • Layer 3: filter content for text blocks (type=="text") and tool_use blocks (type=="tool_use").
    • If stop_reason == "end_turn": return {"text": <text joined with " ">, "iters": <iter count>, "tool_calls": <total tool runs across all iters>}.
    • Layer 4: for each tool_use block, dispatch tools[block["name"]](**block["input"]). Track total tool runs. Append assistant + user(tool_results) turns.
  • On cap: return {"text": "capped", "iters": max_iters, "tool_calls": <count>}.

Two cases run for you. Expected output:

text='Tokyo guide.' iters=2 tool_calls=1
text='capped' iters=2 tool_calls=2

this step needs the editor

on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.

open this same url on a laptop to keep going today.