Drug-Safety Agent on Databricks · Core loop · The limits
The limits that stop the loop
An agent without limits can loop forever or spend without end. These four numbers come from the specification and are enforced by the shared loop on every trip, not left to the model's judgement.
| Limit | Value | Spec id | What happens at the limit |
|---|---|---|---|
| Steps per investigation | 6 | Q-STEPS | The loop stops; the draft is marked needs_human with the reason |
| Model spend per investigation | $0.05 | Q-COST | The loop stops; the draft is marked needs_human with the reason |
| Output tokens per model call | 1,500 | Q-OUTPUT | Passed to the model as the longest reply it may write |
| Characters per tool result | 8,000 | Q-TOOL-RESULT | Applied by the library to each tool result before the model reads it |
Cost per draft is reported. Each draft carries its step count and its spend, so we can measure cost per successful draft, which is the number that matters, not the price per token.
Honest gap. There is not yet a test per limit that shows the loop actually stops at it. The specification asks for one; the features gate counts that as unfinished.
The real code
Cut from the repository each time this site is built, so it always matches what runs. Each header names the file and the line it was cut from.
src/drugsafety/hagent.py:30The four limits in one objectBUDGETS = Budgets(max_steps=6, max_cost_usd=0.05, max_output_tokens=1500, max_tool_result_chars=8000) """AOAS Q-STEPS, Q-COST, Q-OUTPUT, Q-TOOL-RESULT: the specification's numbers, enforced by the library's loop."""