{{ message }}
Repository navigation
fix: require real delegation before the primary agent reports a successful subtask - #458
Open
lalith0407 wants to merge 1 commit into
Open
lalith0407 wants to merge 1 commit into
lalith0407 wants to merge 1 commit into
Conversation
…ssful subtask The primary agent's done barrier only validated that success was set, so it could report fabricated command output with no delegation and the result was stored and shown to the user as real. Add checkDoneEvidence: on a successful done with no AgentToolType call in the subtask, return a soft BarrierDeclinedError that is fed back to the model and keeps the chain running, so it delegates and retries. A failure result is accepted (escape hatch), a repeat is accepted after one rejection (well under the repeating-tool-call abort threshold), tool-call lookup errors fail open, and a cancelled context is propagated. One reinforcing line in primary_agent.tmpl.
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.

Description of the Change
Problem
The primary agent's
donebarrier handler only validates thatsuccessis setbefore storing the subtask result. It never checks whether any work was actually
delegated or executed, so the model can call
done{success:true, result:"<made-up command output>"}with zero delegations and the fabricated result is stored andreported to the user. This was seen on a simple "print the hostname" flow that
reported a hostname with no
termlogsentry (nothing ran). Reproduced at ~2/5on a clean OpenAI stack.
Solution
Add a lightweight evidence check to the primary agent's
donepath:Done.Validate(),checkDoneEvidencelooks up the subtask's tool callsvia the existing
GetSubtaskToolcallsquery. Ifsuccess:truebut nodelegation (
AgentToolType: coder/maintenance/pentester/search/memorist/advice)happened in this subtask, the handler returns a new
*tools.BarrierDeclinedError.performer.gofeeds the reason back to the model asthe tool response and keeps the chain running (it is not routed through
argument-correction retries), so the agent can delegate and try again — no flow
failure.
success:false(failure/blocked, or "cannot verify / no execution needed") result is always
accepted; and after one rejection a repeated success is accepted with a warning
(kept well under the existing repeating-tool-call abort threshold so it can
never deadlock a subtask).
done; a cancelled context is propagated as an error, not a rejection.
primary_agent.tmpl.Scoped to the primary agent only; specialist barriers are untouched.
Closes #457
Type of Change
Areas Affected
Testing and Verification
Test Configuration
Test Steps
cd backend && go test ./pkg/providers/ -run TestDone_ -v"print the hostname of this machine" flows (OpenAI).
Test Results
backend/pkg/providers/done_evidence_test.go) cover: successwith nothing delegated → rejected; success after a delegation → accepted; any
specialist counts; failure result → accepted; rejection cap → accepted with a
warning; a delegation in another subtask does not count; lookup error →
fail-open; cancelled context → error not rejection; and a declined barrier keeps
the chain running without an argument-fix retry. All pass; they fail on the
unpatched handler.
go vetclean;gofmtclean.fabricated hostname with no delegation. One then delegated and returned the
real termlog-verified hostname; the other honestly reported failure. 0/5
phantoms shipped vs 2/5 unpatched; 4/5 produced real hostnames.
Security Considerations
Reduces silent fabrication of results, improving the trustworthiness of flow
reports. No new dependencies or permissions.
Performance Impact
One extra indexed DB read (
GetSubtaskToolcalls) perdoneon the primaryagent. Negligible.
Documentation Updates
Checklist
Code Quality
go fmtandgo vet(for Go code)Security
Compatibility
Additional Notes
The rejection cap is intentionally tight (accept on the 2nd attempt) to stay
within the existing repeating-tool-call abort threshold. Happy to make the cap or
the message configurable if preferred.
HUMAN:
While testing PentAGI locally with simple "print the hostname" flows, I noticed that some flows reported a hostname even though nothing had run: the command log for that subtask was empty. The primary agent can't run commands itself, and its done step never checks whether it delegated anything, so a made-up result went straight into the report. I added a check that sends that kind of success back to the agent once, with the reason, so it can delegate and try again. Reporting failure is always accepted, so a subtask can't get stuck. In my runs this cut fabricated results from 2 in 5 flows to 0 in 5. I kept the check strict on purpose, but I'm happy to make the cap configurable, or to add an explicit "nothing needed to run" flag instead of relying on success:false.