loop: make multiplechoice tool calls end the turn

Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s8d507faf9c095824sk
diff --git a/loop/agent.go b/loop/agent.go
index 05179eb..be5c8a2 100644
--- a/loop/agent.go
+++ b/loop/agent.go
@@ -286,7 +286,7 @@
 	SendMessage(message llm.Message) (*llm.Response, error)
 	SendUserTextMessage(s string, otherContents ...llm.Content) (*llm.Response, error)
 	GetID() string
-	ToolResultContents(ctx context.Context, resp *llm.Response) ([]llm.Content, error)
+	ToolResultContents(ctx context.Context, resp *llm.Response) ([]llm.Content, bool, error)
 	ToolResultCancelContents(resp *llm.Response) ([]llm.Content, error)
 	CancelToolUse(toolUseID string, cause error) error
 	SubConvoWithHistory() *conversation.Convo
@@ -1339,6 +1339,7 @@
 func (a *Agent) handleToolExecution(ctx context.Context, resp *llm.Response) (bool, *llm.Response) {
 	var results []llm.Content
 	cancelled := false
+	toolEndsTurn := false
 
 	// Transition to checking for cancellation state
 	a.stateMachine.Transition(ctx, StateCheckingForCancellation, "Checking if user requested cancellation")
@@ -1365,7 +1366,7 @@
 
 		// Execute the tools
 		var err error
-		results, err = a.convo.ToolResultContents(ctx, resp)
+		results, toolEndsTurn, err = a.convo.ToolResultContents(ctx, resp)
 		if ctx.Err() != nil { // e.g. the user canceled the operation
 			cancelled = true
 			a.stateMachine.Transition(ctx, StateCancelled, "Operation cancelled during tool execution")
@@ -1387,7 +1388,8 @@
 	}
 
 	// Continue the conversation with tool results and any user messages
-	return a.continueTurnWithToolResults(ctx, results, autoqualityMessages, cancelled)
+	shouldContinue, resp := a.continueTurnWithToolResults(ctx, results, autoqualityMessages, cancelled)
+	return shouldContinue && !toolEndsTurn, resp
 }
 
 // processGitChanges checks for new git commits and runs autoformatters if needed