Skip to content

Fixed the Agent continuation issue#379

Merged
frikky merged 2 commits intoShuffle:mainfrom
satti-hari-krishna-reddy:agent-contin
Apr 23, 2026
Merged

Fixed the Agent continuation issue#379
frikky merged 2 commits intoShuffle:mainfrom
satti-hari-krishna-reddy:agent-contin

Conversation

@satti-hari-krishna-reddy
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 userMessage with the continue answer stored on an injected ask decision when present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ai.go Outdated
}
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)
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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))
}

Copilot uses AI. Check for mistakes.
Comment thread ai.go Outdated
Comment on lines +7468 to +7478
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
}
}
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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
}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread ai.go
if debug {
log.Printf("[DEBUG][%s] AI Agent continuation: overriding userMessage with 'continue' answer (length=%d)", execution.ExecutionId, len(field.Answer))
}
userMessage = field.Answer
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🤔

@frikky frikky merged commit fe6c34d into Shuffle:main Apr 23, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants