ファイル参照を与えた際に自動的に読ませる実装
This commit is contained in:
@@ -17,12 +17,18 @@ use crate::tool::{Tool, ToolCall, ToolMeta, ToolResult};
|
||||
// =============================================================================
|
||||
|
||||
/// Action after prompt submission.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum PromptAction {
|
||||
/// Proceed normally.
|
||||
Continue,
|
||||
/// Cancel with a reason.
|
||||
Cancel(String),
|
||||
/// Proceed, and append these items to history right after the user
|
||||
/// message. Mirrors [`TurnEndAction::ContinueWithMessages`] for the
|
||||
/// submit edge: lets the upper layer attach resolver-produced
|
||||
/// system messages (e.g. `@<path>` file content) so they sit
|
||||
/// adjacent to the user message that referenced them.
|
||||
ContinueWith(Vec<Item>),
|
||||
}
|
||||
|
||||
/// Action before an LLM request.
|
||||
|
||||
@@ -1338,16 +1338,20 @@ impl<C: LlmClient> Worker<C, Locked> {
|
||||
self.reset_interruption_state();
|
||||
// Interceptor: on_prompt_submit
|
||||
let mut user_item = Item::user_message(user_input);
|
||||
match self.interceptor.on_prompt_submit(&mut user_item).await {
|
||||
let extras = match self.interceptor.on_prompt_submit(&mut user_item).await {
|
||||
PromptAction::Cancel(reason) => {
|
||||
self.last_run_interrupted = true;
|
||||
return self
|
||||
.finalize_interruption(Err(WorkerError::Aborted(reason)))
|
||||
.await;
|
||||
}
|
||||
PromptAction::Continue => {}
|
||||
}
|
||||
PromptAction::Continue => Vec::new(),
|
||||
PromptAction::ContinueWith(items) => items,
|
||||
};
|
||||
self.history.push(user_item);
|
||||
if !extras.is_empty() {
|
||||
self.history.extend(extras);
|
||||
}
|
||||
let result = self.run_turn_loop().await;
|
||||
self.finalize_interruption(result).await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user