cleandataengineering.aiDrug-Safety Agent on Databricks, drawn simply
You are here: Core loop › The limits

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.

LimitValueSpec idWhat happens at the limit
Steps per investigation6Q-STEPSThe loop stops; the draft is marked needs_human with the reason
Model spend per investigation$0.05Q-COSTThe loop stops; the draft is marked needs_human with the reason
Output tokens per model call1,500Q-OUTPUTPassed to the model as the longest reply it may write
Characters per tool result8,000Q-TOOL-RESULTApplied 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 object
BUDGETS = 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."""