Repository navigation
Approval, spend caps and safe retries for CodeAgent tools: free MIT patterns #3167
stackyardweekstart
started this conversation in
Show and tell
Replies: 1 comment
|
@stackyardweekstart Hi Stackyard, the point about 'no answer counts as no' for confirm-before-delete is critical. In my experience with local LLMs, the model often hallucinates a confirmation when it should be silent, so blocking at the forward() level is the only way to guarantee safety. You're right that callbacks firing after the step are too late for destructive actions. Implementing that check inside the tool's forward() method is the only robust approach for on-prem deployments where data sovereignty is non-negotiable. This pattern prevents irreversible actions before the model even attempts to generate the code for them. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Disclosure: this is ours, from Stackyard. It's a free, MIT-licensed set of 10 small habits for agents that touch files, money or APIs, each a short guide plus a snippet to adapt: https://github.com/stackyardweekstart/weekstart-starter-pack
Where four of them sit in smolagents:
forward(). WithCodeAgentthe tool runs inside generated code, andstep_callbacksfire after the step, so a callback is too late to block it. No answer counts as no.max_stepscaps the loop. For spend, anActionStepcallback taking(step, agent)can readagent.monitor.get_total_token_counts()and callagent.interrupt()once it passes your budget.forward()from the action, and reuse it if the model retries the same call after an error.ActionStep,code_action/tool_callsare what the agent tried andobservationsis what came back. Log them apart, one run id.Free weekly brief on agent tool and API changes: https://stackyard.fyi
All reactions