fix(agent): open assent window on 'go ahead' after propose_plan
Some checks failed
ci / build-test (push) Has been cancelled
ci / docker-build (push) Has been cancelled
Desktop App / Build Linux (amd64) (push) Has been cancelled
Desktop App / Attach to Release (push) Has been cancelled

The check len(lastAssistantCalls) == 0 was too restrictive — it only
fired when the assistant had ZERO tool calls. But propose_plan + pre-plan
research are tool calls, so the assent window never opened when the
operator said 'go ahead' after a plan proposal. The agent then tried to
execute config_mutation run calls without the assent window, they queued
for approval, and the turn deadlocked.

Fix: check len(pending) == 0 (no pending APPROVALS) instead of
len(lastAssistantCalls) == 0 (no tool calls at all).
This commit is contained in:
2026-07-15 11:58:57 +02:00
parent 487f9ad358
commit a8f04cc9e3

View File

@@ -322,12 +322,16 @@ func (a *agent) chatWith(ctx context.Context, sessionID, message, systemInject s
note := fmt.Sprintf("[System: execution(s) %s are classified DESTRUCTIVE and were NOT approved by loose assent — you must ask the operator for an explicit typed confirmation before they can run. Once they do confirm, further destructive steps on that SAME target (e.g. finishing a stop-then-destroy sequence) will auto-run for 15 minutes without asking again — but a different target always needs its own confirmation.]", strings.Join(blocked, ", "))
messages = append(messages, openai.SystemMessage(note))
}
} else if assent && len(lastAssistantCalls) == 0 {
// The operator said "proceed"/"go ahead"/"yes" but the preceding
// assistant turn had NO pending approvals — meaning the agent
// proposed a plan in text and asked "shall I?" without calling
// run yet. Inject a system note telling the agent
// the operator approved — go execute the plan now.
} else if assent && len(pending) == 0 {
// The operator said "proceed"/"go ahead"/"yes" but there are no
// pending approvals from the preceding turn — meaning the agent
// proposed a plan (via propose_plan, possibly with pre-plan research
// tool calls) and asked "shall I?" without calling run yet. Inject
// a system note telling the agent the operator approved — go execute
// the plan now. The old check (len(lastAssistantCalls) == 0) was too
// restrictive: it only fired when the assistant had ZERO tool calls,
// but propose_plan + research tools are tool calls. The right check
// is "no pending APPROVALS" (len(pending) == 0), not "no tool calls."
note := "[System: The operator approved your proposed plan. Execute it now — call run to carry out the steps you described. Do not re-describe the plan or ask for confirmation again. The assent window is active: config_mutation commands will auto-run once you create them.]"
messages = append(messages, openai.SystemMessage(note))
a.openAssentWindow(ctx, sessionID)