Skip to content

fix(memory): accept time_window_days global alias#2255

Merged
senamakel merged 2 commits into
tinyhumansai:mainfrom
DeadlySilent:fix/memory-tree-window-alias
May 20, 2026
Merged

fix(memory): accept time_window_days global alias#2255
senamakel merged 2 commits into
tinyhumansai:mainfrom
DeadlySilent:fix/memory-tree-window-alias

Conversation

@DeadlySilent
Copy link
Copy Markdown
Contributor

@DeadlySilent DeadlySilent commented May 19, 2026

Summary

  • Allows QueryGlobalRequest to deserialize time_window_days as an alias for window_days.
  • Updates the consolidated memory_tree tool schema to expose the canonical window_days field for query_global while preserving the existing time_window_days compatibility path.
  • Adds regression tests for the alias and consolidated schema exposure.

Problem

The consolidated memory_tree tool advertised time_window_days for query_global, but the backend deserialized query_global arguments into:

QueryGlobalRequest { window_days: u32 }

So calls shaped like this failed with missing field 'window_days':

{
  "mode": "query_global",
  "time_window_days": 7
}

Solution

Accept time_window_days as a serde alias for window_days:

#[serde(alias = "time_window_days")]
pub window_days: u32,

and make the consolidated schema explicit about window_days for query_global.

Submission Checklist

  • Tests added or updated (happy path + failure / edge case): alias deserialization test and consolidated schema exposure test added.
  • N/A: Diff coverage >= 80% — local coverage tooling could not be run in this environment; changed behavior is covered by focused unit tests in source.
  • N/A: Coverage matrix updated — bug fix to existing tool schema/deserialization behavior; no feature row added/removed/renamed.
  • N/A: All affected feature IDs from the matrix are listed — no matrix feature row changed.
  • No new external network dependencies introduced.
  • N/A: Manual smoke checklist updated — internal memory tool schema/deserialization fix.
  • Linked issue closed via Closes #2252.

Impact

  • Runtime/platform impact: Rust core memory tree request deserialization and tool schema only.
  • Compatibility impact: back-compatible; existing callers using window_days continue to work, and consolidated tool callers using time_window_days now work too.
  • Security impact: none; no new capability or external access.

Related

Closes #2252


AI Authored PR Metadata

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: fix/memory-tree-window-alias
  • Commit SHA: c3350ae

Validation Run

  • pnpm --filter openhuman-app format:check — N/A: Rust-only change.
  • pnpm typecheck — N/A: Rust-only change.
  • Focused tests: attempted cargo test --manifest-path Cargo.toml memory_tree --lib; blocked locally, see below.
  • Rust fmt/check: attempted cargo fmt --check; blocked locally, see below.
  • Tauri fmt/check: N/A: no app/src-tauri changes.

Validation Blocked

  • command: cargo fmt --check

  • error: error: no such command: fmt

  • impact: Local environment has Rust 1.75 without rustfmt installed; formatting should be verified by CI.

  • command: cargo test --manifest-path Cargo.toml memory_tree --lib

  • error: failed to parse lock file ... Cargo.lock; lock file version 4 requires -Znext-lockfile-bump

  • impact: Local cargo is 1.75 and cannot read the repository's lockfile format; CI/newer cargo should run the focused tests.

Behavior Changes

  • Intended behavior change: memory_tree global queries accept both window_days and the consolidated-schema alias time_window_days.
  • User-visible effect: LLM/tool calls using the advertised consolidated field no longer fail with missing window_days.

Parity Contract

  • Legacy behavior preserved: existing window_days callers continue to deserialize identically.
  • Guard/fallback/dispatch parity checks: only request deserialization/schema metadata changed; query execution remains unchanged.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none known.
  • Canonical PR: this PR.
  • Resolution: N/A.

Summary by CodeRabbit

  • Improvements
    • Memory query endpoints now accept an alternate parameter name ("time_window_days") in requests for compatibility with existing clients.
    • The memory tool’s parameter schema now exposes both "window_days" and "time_window_days" so interfaces can supply either field.

Review Change Stack

@DeadlySilent DeadlySilent requested a review from a team May 19, 2026 21:50
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

📝 Walkthrough

Walkthrough

This PR makes QueryGlobalRequest.window_days accept time_window_days via a serde alias and updates the consolidated MemoryTree tool schema to expose both window_days and time_window_days; tests verify both deserialization and schema presence.

Changes

Memory Tree Global Query Field Compatibility

Layer / File(s) Summary
QueryGlobalRequest deserialization alias
src/openhuman/memory/tree/retrieval/rpc.rs
QueryGlobalRequest.window_days gains #[serde(alias = "time_window_days")]. A unit test verifies time_window_days JSON deserializes into window_days.
Tool schema and documentation update
src/openhuman/tools/impl/memory/tree/mod.rs
MemoryTreeTool.parameters_schema() now documents both time_window_days and window_days (with a compatibility note for query_global), and a schema unit test asserts both fields are present.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

"I nibble on a schema, neat and small,
Two names at once — no error at all.
time_window_days and window_days agree,
The rabbit hops on, schema-smile for me! 🐇"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a serde alias for time_window_days to the window_days field in QueryGlobalRequest.
Linked Issues check ✅ Passed The PR fully addresses issue #2252 by implementing the serde alias approach and updating the consolidated schema to expose both window_days and time_window_days fields.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the schema/deserialization mismatch described in issue #2252; no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/openhuman/tools/impl/memory/tree/mod.rs`:
- Around line 176-182: The test memory_tree_schema_exposes_global_window_days
has a rustfmt violation in the chained call that constructs properties from
schema; split the chained calls on separate lines to satisfy rustfmt (break
after schema) so each method (.get, .and_then, .unwrap) appears on its own
indented line, updating the let properties = ... expression in that test
(referencing MemoryTreeTool.parameters_schema and the local variable properties)
to the multiline style.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 45bbaee2-c2f9-42c4-af59-67365c2acfb5

📥 Commits

Reviewing files that changed from the base of the PR and between 6a83409 and 6c49274.

📒 Files selected for processing (2)
  • src/openhuman/memory/tree/retrieval/rpc.rs
  • src/openhuman/tools/impl/memory/tree/mod.rs

Comment thread src/openhuman/tools/impl/memory/tree/mod.rs
Copy link
Copy Markdown
Contributor

@M3gA-Mind M3gA-Mind left a comment

Choose a reason for hiding this comment

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

Clean, targeted fix for a real bug. The serde alias approach is the right call — back-compat, minimal churn, and the consolidated schema descriptions are now accurate. CodeRabbit's formatting nit was addressed in the latest commit.

File Change
memory/tree/retrieval/rpc.rs #[serde(alias = "time_window_days")] on QueryGlobalRequest.window_days + alias regression test
tools/impl/memory/tree/mod.rs Schema now exposes both window_days and time_window_days; time_window_days description updated to clarify mode scope

One minor thing to be aware of (not blocking):

#[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.

Copy link
Copy Markdown
Contributor

@graycyrus graycyrus left a comment

Choose a reason for hiding this comment

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

Clean bug fix — looks good.

Summary: Adds #[serde(alias = "time_window_days")] to QueryGlobalRequest.window_days so the consolidated memory_tree schema's advertised field actually works for query_global. Schema updated to expose both fields with clear per-mode descriptions. Two focused regression tests cover the alias deserialization and schema exposure.

File What changed
rpc.rs serde alias on window_days + alias deserialization test
tree/mod.rs schema exposes window_days for query_global + schema test

Backwards-compatible, well-tested, and directly addresses #2252. All CI green. No issues from my side — moving to approval queue.

Copy link
Copy Markdown
Member

@senamakel senamakel left a comment

Choose a reason for hiding this comment

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

Looks good, nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: consolidated memory_tree query_global schema advertises time_window_days but backend requires window_days

4 participants