update: memoryシステム周りのプロンプトの整理
This commit is contained in:
+13
-3
@@ -1549,7 +1549,11 @@ impl<C: LlmClient, St: Store> Pod<C, St> {
|
||||
.unwrap_or(manifest::defaults::MEMORY_EXTRACT_WORKER_MAX_INPUT_TOKENS);
|
||||
|
||||
let client = self.build_extractor_client(memory_cfg)?;
|
||||
let mut extract_worker = Worker::new(client).system_prompt(extract::EXTRACT_SYSTEM_PROMPT);
|
||||
let extract_system_prompt = self
|
||||
.prompts
|
||||
.memory_extract_system()
|
||||
.map_err(PodError::PromptCatalog)?;
|
||||
let mut extract_worker = Worker::new(client).system_prompt(extract_system_prompt);
|
||||
extract_worker.set_cache_key(Some(self.session_id.to_string()));
|
||||
|
||||
// Cumulative input-token meter + interceptor (mirror of
|
||||
@@ -1742,8 +1746,14 @@ impl<C: LlmClient, St: Store> Pod<C, St> {
|
||||
return Err(e);
|
||||
}
|
||||
};
|
||||
let mut worker =
|
||||
Worker::new(client).system_prompt(consolidate::CONSOLIDATION_SYSTEM_PROMPT);
|
||||
let consolidation_system_prompt = match self.prompts.memory_consolidation_system() {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
lock.release_only();
|
||||
return Err(PodError::PromptCatalog(e));
|
||||
}
|
||||
};
|
||||
let mut worker = Worker::new(client).system_prompt(consolidation_system_prompt);
|
||||
worker.set_cache_key(Some(self.session_id.to_string()));
|
||||
|
||||
// Memory tools are self-contained — they bypass ScopedFs and write
|
||||
|
||||
@@ -61,6 +61,10 @@ const INTERNAL_TOML: &str = include_str!("../../../../resources/prompts/internal
|
||||
pub enum PodPrompt {
|
||||
/// System prompt of the compaction (summary) Worker.
|
||||
CompactSystem,
|
||||
/// System prompt of the memory Phase 1 (extract) Worker.
|
||||
MemoryExtractSystem,
|
||||
/// System prompt of the memory Phase 2 (consolidation + tidy) Worker.
|
||||
MemoryConsolidationSystem,
|
||||
/// Wrapper around an incoming `Method::Notify` message injected into
|
||||
/// the next LLM request context as a transient system message.
|
||||
NotifyWrapper,
|
||||
@@ -89,6 +93,8 @@ impl PodPrompt {
|
||||
pub fn key(self) -> &'static str {
|
||||
match self {
|
||||
Self::CompactSystem => "compact_system",
|
||||
Self::MemoryExtractSystem => "memory_extract_system",
|
||||
Self::MemoryConsolidationSystem => "memory_consolidation_system",
|
||||
Self::NotifyWrapper => "notify_wrapper",
|
||||
Self::InterruptToolResultSummary => "interrupt_tool_result_summary",
|
||||
Self::InterruptSystemNote => "interrupt_system_note",
|
||||
@@ -104,6 +110,8 @@ impl PodPrompt {
|
||||
/// `INTERNAL_KEYS` (generated by `build.rs`).
|
||||
pub const ALL: &'static [PodPrompt] = &[
|
||||
PodPrompt::CompactSystem,
|
||||
PodPrompt::MemoryExtractSystem,
|
||||
PodPrompt::MemoryConsolidationSystem,
|
||||
PodPrompt::NotifyWrapper,
|
||||
PodPrompt::InterruptToolResultSummary,
|
||||
PodPrompt::InterruptSystemNote,
|
||||
@@ -115,6 +123,8 @@ impl PodPrompt {
|
||||
|
||||
pub const KEYS: &'static [&'static str] = &[
|
||||
"compact_system",
|
||||
"memory_extract_system",
|
||||
"memory_consolidation_system",
|
||||
"notify_wrapper",
|
||||
"interrupt_tool_result_summary",
|
||||
"interrupt_system_note",
|
||||
@@ -301,6 +311,16 @@ impl PromptCatalog {
|
||||
self.render(PodPrompt::CompactSystem, Value::UNDEFINED)
|
||||
}
|
||||
|
||||
/// Render `PodPrompt::MemoryExtractSystem` (no inputs).
|
||||
pub fn memory_extract_system(&self) -> Result<String, CatalogError> {
|
||||
self.render(PodPrompt::MemoryExtractSystem, Value::UNDEFINED)
|
||||
}
|
||||
|
||||
/// Render `PodPrompt::MemoryConsolidationSystem` (no inputs).
|
||||
pub fn memory_consolidation_system(&self) -> Result<String, CatalogError> {
|
||||
self.render(PodPrompt::MemoryConsolidationSystem, Value::UNDEFINED)
|
||||
}
|
||||
|
||||
/// Render `PodPrompt::NotifyWrapper` with `{{ message }}`.
|
||||
pub fn notify_wrapper(&self, message: &str) -> Result<String, CatalogError> {
|
||||
self.render(PodPrompt::NotifyWrapper, single("message", message))
|
||||
|
||||
Reference in New Issue
Block a user