Repository navigation
feat(plugins): Add an afterToolExecute hook for checks on finished tool calls - #2646
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
|
rebase this, main is probably fixed? |
…ol calls Plugins can now check a tool call after it runs, with the Run's sandbox, the active Workspace repositories, the decision model, and the structured model. A check can add a note to the tool result or reject the result. A before-hook cannot see what bash wrote, so file-change rules need this.
An abort during afterToolExecute made the pipeline report the call as preempted, so a resumed agent could retry work that already ran. Stop the checks and keep the result instead.
Document how a check limits itself to named Workspaces.
A nudge was added to the tool result content. A Code Mode script got the structured details, so it lost the nudge, or the content text with the nudge joined in, which breaks JSON.parse. Return nudges next to the result and show them under the call in the codemode result.
a9af419 to
7181332
Compare
|
4 screenshot changes — 4 changed · 0 added · 0 removed Review screenshots in Frameshift
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7181332. Configure here.
dcramer
left a comment
There was a problem hiding this comment.
gonna get this out so i can experiment with some hardcoded hooks

Adds a plugin hook that runs after a tool call finishes. It lets us add deterministic rules to tool calls, such as "when the agent edits an eval, check that the eval is not overfit."
beforeToolExecutesees only the tool input, so it can't tell whatbashwrote (sed -i, heredocs,git apply).afterToolExecuteruns after the call and gets:ctx.sandbox: the Run's sandbox, so a rule can rungit diffctx.workspace: the active Workspace's repos and checkout paths, so a rule runs only on the repos it coversctx.decider.decide(...): the decision model (Jev) for one narrow choicectx.model.completeObject(...): the structured model, for judgments that need reasoningctx.decision.nudge(message): adds a<plugin-note>after the tool result, which the agent readsctx.decision.deny(reason): replaces the result with a policy refusal. The message says the action already ran.The hook runs in the shared tool pipeline, so direct calls,
executeTool, and Code Mode script calls all get it. If a hook throws, Junior logs the error and keeps the tool result as it was. The tool already ran, so a broken check must not turn the result into an error that the agent retries.basePluginContext,withPluginHookSpan, andcreateSandboxCapabilitymove fromagent-hooks.tstoplugins/hook-context.ts, so the new hook phase can live in its own file.The first rule is the eval-overfit check. It goes in junior-prod as an inline plugin after this is released: it nudges the agent when a diff under
packages/junior-evals/evals/ingetsentry/juniorlooks overfit.via @dcramer.
--
View Session [Sentry]