summaryrefslogtreecommitdiff
path: root/makima/src/server/handlers
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-02 22:13:28 +0000
committersoryu <soryu@soryu.co>2026-01-02 22:13:28 +0000
commitf79c416c58557d2f946aa5332989afdfa8c021cd (patch)
treee64e8fef0bedd6b40d3a2314d39654aa5c073980 /makima/src/server/handlers
parent2fab6904260099d9a011734763e62ebba91cf448 (diff)
downloadsoryu-f79c416c58557d2f946aa5332989afdfa8c021cd.tar.gz
soryu-f79c416c58557d2f946aa5332989afdfa8c021cd.zip
Add defined user input dialogue to LLM edit
Diffstat (limited to 'makima/src/server/handlers')
-rw-r--r--makima/src/server/handlers/chat.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/makima/src/server/handlers/chat.rs b/makima/src/server/handlers/chat.rs
index 158805b..51f17c1 100644
--- a/makima/src/server/handlers/chat.rs
+++ b/makima/src/server/handlers/chat.rs
@@ -15,7 +15,7 @@ use crate::llm::{
claude::{self, ClaudeClient, ClaudeError, ClaudeModel},
execute_tool_call,
groq::{GroqClient, GroqError, Message, ToolCallResponse},
- LlmModel, ToolCall, ToolResult, VersionToolRequest, AVAILABLE_TOOLS,
+ LlmModel, ToolCall, ToolResult, UserQuestion, VersionToolRequest, AVAILABLE_TOOLS,
};
use crate::server::state::{FileUpdateNotification, SharedState};
@@ -66,6 +66,9 @@ pub struct ChatResponse {
pub updated_body: Vec<BodyElement>,
/// Updated summary (if changed)
pub updated_summary: Option<String>,
+ /// Questions pending user answers (pauses conversation)
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub pending_questions: Option<Vec<UserQuestion>>,
}
#[derive(Debug, Serialize, ToSchema)]
@@ -326,6 +329,8 @@ You have access to tools for:
// Track consecutive failures for agentic retry logic
let mut consecutive_failures = 0;
const MAX_CONSECUTIVE_FAILURES: usize = 3;
+ // Track pending user questions (pauses the conversation)
+ let mut pending_questions: Option<Vec<UserQuestion>> = None;
// Multi-turn agentic tool calling loop
for round in 0..MAX_TOOL_ROUNDS {
@@ -508,6 +513,21 @@ You have access to tools for:
);
}
+ // Check for pending user questions (pauses the conversation)
+ if let Some(questions) = execution_result.pending_questions {
+ tracing::info!(
+ question_count = questions.len(),
+ "LLM requesting user input, pausing conversation"
+ );
+ pending_questions = Some(questions);
+ // Track this tool call before breaking
+ all_tool_call_infos.push(ToolCallInfo {
+ name: tool_call.name.clone(),
+ result: execution_result.result,
+ });
+ break; // Exit inner loop
+ }
+
// Build tool result message content with enhanced context for agentic reasoning
let result_content = if let Some(parsed_data) = &execution_result.parsed_data {
// Include parsed data in the result for the LLM to use
@@ -559,6 +579,12 @@ You have access to tools for:
});
}
+ // If user questions are pending, pause the conversation
+ if pending_questions.is_some() {
+ final_response = result.content;
+ break;
+ }
+
// If finish reason indicates completion, exit loop
let finish_lower = result.finish_reason.to_lowercase();
if finish_lower == "stop" || finish_lower == "end_turn" {
@@ -637,6 +663,7 @@ You have access to tools for:
tool_calls: all_tool_call_infos,
updated_body: current_body,
updated_summary: current_summary,
+ pending_questions,
}),
)
.into_response()