fix(memory-tree): rename window_days → time_window_days for query_global

query_global RPC and tool used  as the field name, but
DeepSeek (and some other providers) pass the parameter exactly as named
in the JSON schema — which was . This mismatch caused
parse errors on tool calls.

- Rename QueryGlobalRequest::window_days → time_window_days
- Update tool schema, description, and execute() to match
- Update RPC test to use the new field name
This commit is contained in:
Maxen Wong
2026-05-19 21:44:07 +08:00
parent 70fdedcdd4
commit 172f2b31b9
2 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -84,7 +84,7 @@ pub async fn query_source_rpc(
/// Request body for `memory_tree_query_global`.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct QueryGlobalRequest {
pub window_days: u32,
pub time_window_days: u32,
}
/// JSON-RPC handler body for `memory_tree_query_global`.
@@ -92,7 +92,7 @@ pub async fn query_global_rpc(
config: &Config,
req: QueryGlobalRequest,
) -> Result<RpcOutcome<QueryResponse>, String> {
let resp = query_global(config, req.window_days)
let resp = query_global(config, req.time_window_days)
.await
.map_err(|e| format!("query_global: {e}"))?;
let n = resp.hits.len();
@@ -410,7 +410,7 @@ mod tests {
#[tokio::test]
async fn query_global_rpc_returns_response_for_valid_window() {
let (_tmp, cfg) = test_config();
let req = QueryGlobalRequest { window_days: 7 };
let req = QueryGlobalRequest { time_window_days: 7 };
let outcome = query_global_rpc(&cfg, req).await.unwrap();
assert!(outcome.value.hits.is_empty());
assert_eq!(outcome.logs.len(), 1);
@@ -14,7 +14,7 @@ impl Tool for MemoryTreeQueryGlobalTool {
}
fn description(&self) -> &str {
"Return the cross-source global digest for the last `window_days`. \
"Return the cross-source global digest for the last `time_window_days`. \
The 7-day digest is also pre-loaded into the session context at \
start, so only call this for a different window (e.g. 30 days, \
1 day) or to refresh after new ingest."
@@ -24,13 +24,13 @@ impl Tool for MemoryTreeQueryGlobalTool {
json!({
"type": "object",
"properties": {
"window_days": {
"time_window_days": {
"type": "integer",
"minimum": 1,
"description": "Lookback window in days (e.g. 7 for weekly recap)."
}
},
"required": ["window_days"]
"required": ["time_window_days"]
})
}
@@ -41,7 +41,7 @@ impl Tool for MemoryTreeQueryGlobalTool {
let cfg = config_rpc::load_config_with_timeout()
.await
.map_err(|e| anyhow::anyhow!("memory_tree_query_global: load config failed: {e}"))?;
let resp = retrieval::query_global(&cfg, req.window_days).await?;
let resp = retrieval::query_global(&cfg, req.time_window_days).await?;
log::debug!(
"[tool][memory_tree] query_global returning hits={} total={}",
resp.hits.len(),