Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/openhuman/memory/tree/retrieval/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ pub async fn query_source_rpc(
/// Request body for `memory_tree_query_global`.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct QueryGlobalRequest {
#[serde(alias = "time_window_days")]
pub window_days: u32,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] If a caller passes both window_days and time_window_days in the same request, serde will return a "duplicate field window_days" error — the alias maps both names to the same slot, so supplying both is treated as a duplicate.

The consolidated schema now exposes both fields without noting they're mutually exclusive for query_global. In practice no LLM/caller should ever send both, and the descriptions make the intent clear, but it's a subtle footgun to keep in mind if you see confusing deserialization errors down the line.

}

Expand Down Expand Up @@ -421,6 +422,16 @@ mod tests {
);
}

#[test]
fn query_global_request_accepts_consolidated_time_window_alias() {
let req: QueryGlobalRequest = serde_json::from_value(serde_json::json!({
"time_window_days": 7
}))
.expect("time_window_days alias should deserialize");

assert_eq!(req.window_days, 7);
}

// ── query_topic_rpc ───────────────────────────────────────────────

#[tokio::test]
Expand Down
17 changes: 16 additions & 1 deletion src/openhuman/tools/impl/memory/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ impl Tool for MemoryTreeTool {
},
"time_window_days": {
"type": "integer",
"description": "query_source/query_global: look-back window in days."
"description": "query_source/query_topic: look-back window in days. query_global also accepts this as a compatibility alias."
},
"window_days": {
"type": "integer",
"description": "query_global: look-back window in days."
},
// drill_down params
"node_id": {
Expand Down Expand Up @@ -169,6 +173,17 @@ mod memory_tree_dispatcher_tests {
assert!(modes.contains(&"fetch_leaves"));
}

#[test]
fn memory_tree_schema_exposes_global_window_days() {
let schema = MemoryTreeTool.parameters_schema();
let properties = schema
.get("properties")
.and_then(|p| p.as_object())
.unwrap();
assert!(properties.contains_key("window_days"));
assert!(properties.contains_key("time_window_days"));
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

#[tokio::test]
async fn memory_tree_unknown_mode_returns_error() {
let result = MemoryTreeTool
Expand Down
Loading