fix(agent): directive assent notes + retry bump to fix empty responses
The assent system note said 'Do not re-request or call run again for these' — the LLM interpreted this as 'don't call run at all' and produced empty responses (finish_reason=stop, content_len=0) until retries were exhausted, leaving the session stuck in 'executing'. Fix: rewrite both assent notes (pending-approval path and pure-plan-approval path) to be directive about WHAT TO DO NEXT: call update_plan_step(running) then run for each remaining step. The 'don't re-request' guidance is now scoped to 'THOSE SPECIFIC' executions, not all run calls. Also bump maxLLMRetries from 2 to 3 — the empty-response flake on complex multi-turn flows benefits from one more retry.
This commit is contained in:
@@ -22,7 +22,7 @@ import (
|
||||
// decomposed pct_create flow can legitimately need many steps. On exhaustion
|
||||
// the loop now produces a real summary (finalSummary) rather than a dead end.
|
||||
const maxIterations = 40
|
||||
const maxLLMRetries = 2
|
||||
const maxLLMRetries = 3
|
||||
|
||||
// historyWindowSize bounds how many of a session's most recent persisted
|
||||
// messages are replayed into the LLM's context on each turn — see
|
||||
@@ -315,7 +315,7 @@ func (a *agent) chatWith(ctx context.Context, sessionID, message, systemInject s
|
||||
}
|
||||
if len(granted) > 0 {
|
||||
a.openAssentWindow(ctx, sessionID)
|
||||
note := fmt.Sprintf("[System: the operator's message approved pending execution(s) %s via chat assent — they are now running. An assent window is now active for 30 minutes: config_mutation commands will auto-run without re-approval. Do not re-request or call run again for these; check get_execution_status if you need the outcome. CONTINUE executing the full plan — do not stop and wait for 'continue' after each step. Only surface to the operator for destructive actions (need typed confirmation) or if you're genuinely stuck after trying alternatives.]", strings.Join(granted, ", "))
|
||||
note := fmt.Sprintf("[System: the operator approved pending execution(s) %s via chat assent — they are now running. An assent window is now active for 30 minutes: config_mutation commands will auto-run without re-approval. The approved execution(s) are already dispatched — do not re-request THOSE SPECIFIC ones. But you MUST continue executing the REMAINING plan steps: call update_plan_step(seq=N, status=\"running\") then run(...) for each unstarted step. Do not stop and wait for 'continue'. Only surface to the operator for destructive actions (need typed confirmation) or if you're genuinely stuck after trying alternatives.]", strings.Join(granted, ", "))
|
||||
messages = append(messages, openai.SystemMessage(note))
|
||||
}
|
||||
if len(blocked) > 0 {
|
||||
@@ -332,7 +332,7 @@ func (a *agent) chatWith(ctx context.Context, sessionID, message, systemInject s
|
||||
// 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.]"
|
||||
note := "[System: The operator approved your proposed plan. Execute it now — for each step, call update_plan_step(seq=N, status=\"running\") then run(...) for that step's target, then update_plan_step(seq=N, status=\"done\"). The assent window is active: config_mutation commands will auto-run. Do not re-describe the plan or ask for confirmation again. Do not wait for 'continue' — execute all steps in this turn.]"
|
||||
messages = append(messages, openai.SystemMessage(note))
|
||||
a.openAssentWindow(ctx, sessionID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user