Repository navigation
fix(agent): run the output contract check on a capped final answer - #192
Merged
Merged
Conversation
When a turn hits the tool-call cap, finalAnswer returned the model's tools-disabled reply without ev.CheckFinal, so a definition with an output contract could end a capped turn "succeeded" with no output: the daemon's correction round is what usually pushes a reviewer to the cap, and the answer it forced skipped the very check that asked for it. The capped answer now goes through the same check the loop runs on a no-tools reply, with the one correction round the check may ask for. A second miss fails the turn, as it does in the loop. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 8884403)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
A turn that hits the tool-call cap ends with a tools-disabled final answer from
finalAnswer, which returned the model's reply withoutev.CheckFinal. A definition with an output contract could therefore end a capped turnsucceededwith no output: the daemon's correction round is what usually pushes an agent to the cap, and the answer it forced skipped the very check that asked for it. Loupe hit this on reviewers that spent their budget exploring (.ai-docs/plans/loupe-sdk-ergonomics/PLAN.md, follow-up 1).finalAnswerruns the capped answer through the same final-message check the loop applies to a no-tools reply.CheckFinal.Validation
internal/agent/final_answer_test.go: a capped answer corrected on the second final call, and a second miss failing the turn.go test ./internal/agentgreen;go vetclean.🤖 Generated with Claude Code
Note
Medium Risk
Agent changes affect turn success/failure when definitions use output contracts at the tool cap; process env allowlisting slightly expands what managed children inherit but deliberately excludes proxy/auth Go variables.
Overview
Agent: When a turn hits the tool-call cap, the tools-disabled answer from
finalAnswernow goes throughev.CheckFinalthe same way a normal no-tools reply does. Logic is split intocappedAnswer(one forced final completion) andfinalAnswer(check, optional one retry with ephemeral correction notice, fail on second miss). Turns withoutCheckFinalare unchanged.Process / docs: Managed host children snapshot and inherit a fixed set of Go build vars (
GOCACHE,GOMODCACHE,GOPATH,GOROOT,GOTOOLCHAIN,GOFLAGS) at process-manager startup so offline preloaded toolchains/caches work; credential-bearingGO*settings likeGOPROXYstay out of the allowlist.docs/concurrency.mddocuments this; tests cover env snapshotting,ChildEnvironmentoverrides, and offlinego list -m.Reviewed by Cursor Bugbot for commit 92be932. Bugbot is set up for automated code reviews on this repo. Configure here.