update: Consolidationの不要なToken上限の削除
This commit is contained in:
@@ -218,9 +218,6 @@ impl MemoryConfig {
|
||||
.extract_worker_max_input_tokens
|
||||
.or(self.extract_worker_max_input_tokens),
|
||||
consolidation_model: upper.consolidation_model.or(self.consolidation_model),
|
||||
consolidation_worker_max_input_tokens: upper
|
||||
.consolidation_worker_max_input_tokens
|
||||
.or(self.consolidation_worker_max_input_tokens),
|
||||
consolidation_threshold_files: upper
|
||||
.consolidation_threshold_files
|
||||
.or(self.consolidation_threshold_files),
|
||||
|
||||
@@ -50,8 +50,3 @@ pub const COMPACT_DEFAULT_REFERENCE_COUNT: usize = 5;
|
||||
/// own LLM calls. Exceeding this aborts the extract run.
|
||||
/// See [`crate::MemoryConfig::extract_worker_max_input_tokens`].
|
||||
pub const MEMORY_EXTRACT_WORKER_MAX_INPUT_TOKENS: u64 = 30_000;
|
||||
|
||||
/// Cumulative input-token cap for the memory Phase 2 (consolidation)
|
||||
/// worker's own LLM calls. Exceeding this aborts the consolidation run.
|
||||
/// See [`crate::MemoryConfig::consolidation_worker_max_input_tokens`].
|
||||
pub const MEMORY_CONSOLIDATION_WORKER_MAX_INPUT_TOKENS: u64 = 80_000;
|
||||
|
||||
@@ -90,11 +90,6 @@ pub struct MemoryConfig {
|
||||
/// Reasoning-class models are recommended.
|
||||
#[serde(default)]
|
||||
pub consolidation_model: Option<ModelManifest>,
|
||||
/// Cumulative input-token cap for the consolidation worker's own
|
||||
/// LLM calls. Exceeding this aborts the consolidation run. `None` ⇒
|
||||
/// [`defaults::MEMORY_CONSOLIDATION_WORKER_MAX_INPUT_TOKENS`].
|
||||
#[serde(default)]
|
||||
pub consolidation_worker_max_input_tokens: Option<u64>,
|
||||
/// Phase 2 trigger: file-count threshold of `_staging/`. Phase 2
|
||||
/// fires when the staging directory has at least this many entries.
|
||||
/// Either threshold reaching its limit fires Phase 2 (logical OR).
|
||||
|
||||
@@ -1735,9 +1735,6 @@ impl<C: LlmClient, St: Store> Pod<C, St> {
|
||||
Err(e) => return Err(PodError::ConsolidationLock(e)),
|
||||
};
|
||||
|
||||
let cap = memory_cfg
|
||||
.consolidation_worker_max_input_tokens
|
||||
.unwrap_or(manifest::defaults::MEMORY_CONSOLIDATION_WORKER_MAX_INPUT_TOKENS);
|
||||
let client = match self.build_consolidator_client(memory_cfg) {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
@@ -1749,20 +1746,6 @@ impl<C: LlmClient, St: Store> Pod<C, St> {
|
||||
Worker::new(client).system_prompt(consolidate::CONSOLIDATION_SYSTEM_PROMPT);
|
||||
worker.set_cache_key(Some(self.session_id.to_string()));
|
||||
|
||||
let input_so_far = Arc::new(std::sync::atomic::AtomicU64::new(0));
|
||||
{
|
||||
let acc = input_so_far.clone();
|
||||
worker.on_usage(move |event| {
|
||||
if let Some(tokens) = event.input_tokens {
|
||||
acc.fetch_add(tokens, Ordering::Relaxed);
|
||||
}
|
||||
});
|
||||
}
|
||||
worker.set_interceptor(MemoryConsolidationWorkerInterceptor {
|
||||
input_so_far: input_so_far.clone(),
|
||||
max_input_tokens: cap,
|
||||
});
|
||||
|
||||
// Memory tools are self-contained — they bypass ScopedFs and write
|
||||
// directly under the workspace via WorkspaceLayout. Resident
|
||||
// knowledge injection (`Pod::set_resident_knowledge_injection`) is
|
||||
@@ -1843,30 +1826,6 @@ enum ConsolidateDecision {
|
||||
Completed,
|
||||
}
|
||||
|
||||
/// Pre-request interceptor for the Phase 2 consolidation worker. Same
|
||||
/// shape as the extract interceptor; kept separate so the abort message
|
||||
/// names the right subsystem.
|
||||
struct MemoryConsolidationWorkerInterceptor {
|
||||
input_so_far: Arc<std::sync::atomic::AtomicU64>,
|
||||
max_input_tokens: u64,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl llm_worker::interceptor::Interceptor for MemoryConsolidationWorkerInterceptor {
|
||||
async fn pre_llm_request(
|
||||
&self,
|
||||
_context: &mut Vec<Item>,
|
||||
) -> llm_worker::interceptor::PreRequestAction {
|
||||
if self.input_so_far.load(Ordering::Relaxed) > self.max_input_tokens {
|
||||
return llm_worker::interceptor::PreRequestAction::Cancel(format!(
|
||||
"Phase 2 consolidation worker input exceeded {} tokens",
|
||||
self.max_input_tokens
|
||||
));
|
||||
}
|
||||
llm_worker::interceptor::PreRequestAction::Continue
|
||||
}
|
||||
}
|
||||
|
||||
impl<St: Store> Pod<Box<dyn LlmClient>, St> {
|
||||
/// Create a Pod entirely from a validated manifest.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user