promptdojo_

The chat history accumulates EVERY prior tool result across turns. The current code returns the full history every call. The trace shows tokens climbing turn-over-turn until the context fills with irrelevant chatter.

Fix line 8 so the assembled context only includes messages with age <= 2 (the most recent 2 turns). Older tool_result rows fall off the back.

Expected output:

3
The break is on line 13 — but read the whole snippet first.

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.