Credentials. The API key is read from the environment, so keep it out of the script and out of any committed file.
Who it is forAn AI engineer with a set of question and answer pairs who needs a better system prompt for a model they already call through an OpenAI-compatible endpoint.
The problemHand-tuning a prompt against examples is slow, and it is hard to tell which edit actually helped.
The outcomeAn evolved prompt printed with its held-out reward, scored on examples the loop did not train on.
What you need first
- Python 3.9 or newer
- pip to install the agentdescent package from PyPI
- For model-backed runs: an OpenAI-compatible endpoint, its base URL, and an API key set in environment variables (OPENAI_BASE_URL and OPENAI_API_KEY)
- For agent-plugin use: Claude Code or Codex installed, and git to clone the repo
Steps
pip install "agentdescent>=0.7.0"export OPENAI_BASE_URL=https://api.deepseek.com(or your own endpoint, such as a local vLLM)export OPENAI_API_KEY=sk-...(your key for that endpoint)- Write a Python script that builds tasks with
tasks_from(rows, prompt="question", gold="answer"), then callsevolve(tasks, scorer("exact"), run=run, propose=reflector(model), strategy=SingleSlot(initial_value="You are a helpful assistant."), rounds=8, n_workers=8, max_concurrency=8, held_out_frac=0.3, patience=3, target_reward=0.98). (inferred, check the README) - Run the script and read
result.rendered,result.final_reward, andresult.outcomes().
Prompt for your agent
In the AgentDescent repo, build a script that loads <path to your CSV of question and answer rows> into tasks and runs evolve with SingleSlot and exact scoring. Expected output: the evolved prompt, the held-out reward, and the outcomes list. Verify that the held-out reward is reported separately from training results.
Caveat. The README's worked example uses the HotpotQA dataset and a DeepSeek model, and its reported gain is for that setup only.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for Birfy/agentdescent and "Evolve a prompt against your own labeled examples"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer