ファイル参照を与えた際に自動的に読ませる実装

This commit is contained in:
2026-04-30 21:58:10 +09:00
parent bc81dc1513
commit d7bc7ab3dd
12 changed files with 399 additions and 36 deletions
+7 -1
View File
@@ -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.
+7 -3
View File
@@ -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
}