Fixed the Agent continuation issue#379
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses an AI Agent “continuation” flow where, after a finish decision (e.g., via “Add more details”), the agent should act on the newly provided instruction rather than the original input.
Changes:
- Override
userMessagewith thecontinueanswer stored on an injectedaskdecision when present.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| for _, field := range mappedDecision.Fields { | ||
| if field.Key == "continue" && len(field.Answer) > 0 { | ||
| log.Printf("[DEBUG][%s] AI Agent continuation: overriding userMessage with 'continue' answer: %s", execution.ExecutionId, field.Answer) |
There was a problem hiding this comment.
This debug log prints the full user-provided continuation text (field.Answer) into server logs. That can leak sensitive data and can also create log spam/injection (newlines). Prefer logging only metadata (e.g., presence/length) or truncating + sanitizing before logging, and consider gating behind the existing debug flag.
| log.Printf("[DEBUG][%s] AI Agent continuation: overriding userMessage with 'continue' answer: %s", execution.ExecutionId, field.Answer) | |
| if debug { | |
| log.Printf("[DEBUG][%s] AI Agent continuation: overriding userMessage with 'continue' answer (length=%d)", execution.ExecutionId, len(field.Answer)) | |
| } |
| for _, mappedDecision := range mappedResult.Decisions { | ||
| if mappedDecision.Action != "ask" { | ||
| continue | ||
| } | ||
| for _, field := range mappedDecision.Fields { | ||
| if field.Key == "continue" && len(field.Answer) > 0 { | ||
| log.Printf("[DEBUG][%s] AI Agent continuation: overriding userMessage with 'continue' answer: %s", execution.ExecutionId, field.Answer) | ||
| userMessage = field.Answer | ||
| break | ||
| } | ||
| } |
There was a problem hiding this comment.
After finding a non-empty continue answer you only break the inner fields loop, so userMessage can be overwritten again by later ask decisions (and which one wins depends on slice order). If the intent is to use a specific continuation (e.g., the most recent by I), make that deterministic by selecting the best match once and breaking out of the outer loop (or iterating from the end).
| for _, mappedDecision := range mappedResult.Decisions { | |
| if mappedDecision.Action != "ask" { | |
| continue | |
| } | |
| for _, field := range mappedDecision.Fields { | |
| if field.Key == "continue" && len(field.Answer) > 0 { | |
| log.Printf("[DEBUG][%s] AI Agent continuation: overriding userMessage with 'continue' answer: %s", execution.ExecutionId, field.Answer) | |
| userMessage = field.Answer | |
| break | |
| } | |
| } | |
| // Iterate from the end so we deterministically pick the most recent continuation. | |
| for i := len(mappedResult.Decisions) - 1; i >= 0; i-- { | |
| mappedDecision := mappedResult.Decisions[i] | |
| if mappedDecision.Action != "ask" { | |
| continue | |
| } | |
| foundContinuation := false | |
| for _, field := range mappedDecision.Fields { | |
| if field.Key == "continue" && len(field.Answer) > 0 { | |
| log.Printf("[DEBUG][%s] AI Agent continuation: overriding userMessage with 'continue' answer: %s", execution.ExecutionId, field.Answer) | |
| userMessage = field.Answer | |
| foundContinuation = true | |
| break | |
| } | |
| } | |
| if foundContinuation { | |
| break | |
| } |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if debug { | ||
| log.Printf("[DEBUG][%s] AI Agent continuation: overriding userMessage with 'continue' answer (length=%d)", execution.ExecutionId, len(field.Answer)) | ||
| } | ||
| userMessage = field.Answer |
There was a problem hiding this comment.
Isn't this a problem?
I'm thinking: how do we deal with original goals vs new goals? If you type something new, should it overwrite the original goal completely?
Or should it just help direction-change?
Just curious if that's what we're doing here 🤔
No description provided.