Skip to content

fix(memory): accept time_window_days alias in query_global#2350

Merged
graycyrus merged 2 commits into
tinyhumansai:mainfrom
Liohtml:fix/memory-tree-schema-mismatch
May 21, 2026
Merged

fix(memory): accept time_window_days alias in query_global#2350
graycyrus merged 2 commits into
tinyhumansai:mainfrom
Liohtml:fix/memory-tree-schema-mismatch

Conversation

@Liohtml
Copy link
Copy Markdown
Contributor

@Liohtml Liohtml commented May 20, 2026

Summary

Fixes a schema mismatch between the consolidated memory_tree tool and the standalone query_global sub-tool. The consolidated schema advertises time_window_days (consistent with query_source/query_topic), but QueryGlobalRequest only accepted window_days — causing LLMs that follow the consolidated schema to fail with missing field window_days.

Fix

One-line change: add #[serde(alias = "time_window_days")] to QueryGlobalRequest.window_days so both field names deserialize correctly.

Changes

File What
src/openhuman/memory/tree/retrieval/rpc.rs Serde alias + unit test

Test plan

  • cargo fmt --all -- --check — clean
  • cargo test -p openhuman "query_global" — 2/2 pass (1 new)
  • New test pins both window_days and time_window_days deserialization paths

Credit to @DeadlySilent for the well-documented bug report (#2252) with exact file paths and reproduction steps.

Closes #2252

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Query API now accepts either time_window_days or the legacy window_days field in request JSON, improving compatibility with existing integrations.
  • Tests

    • Added unit tests verifying requests deserialize correctly when using either field name.

Review Change Stack

The consolidated memory_tree tool schema advertises `time_window_days`
(consistent with query_source/query_topic), but QueryGlobalRequest
only accepted `window_days`. LLMs following the consolidated schema
fail with "missing field window_days" even when a lookback value was
supplied as time_window_days.

Add #[serde(alias = "time_window_days")] so both field names
deserialize correctly. Adds a unit test pinning both paths.

Closes tinyhumansai#2252

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Liohtml Liohtml requested a review from a team May 20, 2026 13:29
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 27d17cda-367e-48bd-bf69-574fa9b82da7

📥 Commits

Reviewing files that changed from the base of the PR and between dcc40c9 and 5ac8a1c.

📒 Files selected for processing (1)
  • src/openhuman/memory/tree/retrieval/rpc.rs
💤 Files with no reviewable changes (1)
  • src/openhuman/memory/tree/retrieval/rpc.rs

📝 Walkthrough

Walkthrough

QueryGlobalRequest's time_window_days field gains a serde alias to accept the legacy window_days JSON key; docs and unit tests are updated to validate deserialization from both field names.

Changes

Field deserialization alias

Layer / File(s) Summary
Serde alias and tests
src/openhuman/memory/tree/retrieval/rpc.rs
QueryGlobalRequest.time_window_days adds #[serde(alias = "window_days")]. Documentation is expanded and the unit test now verifies deserialization from both {"window_days": ...} and {"time_window_days": ...}.

🎯 2 (Simple) | ⏱️ ~10 minutes

  • tinyhumansai/openhuman#2255: Also modifies src/openhuman/memory/tree/retrieval/rpc.rs to accept the alternate JSON key via serde alias and updates tests.
  • tinyhumansai/openhuman#2219: Related edits around QueryGlobalRequest field mapping between window_days and time_window_days.
  • tinyhumansai/openhuman#2273: Addresses the same mismatch by translating the field in the dispatcher rather than adding a serde alias.

Suggested labels: rust-core, working

Suggested reviewers:

  • senamakel

"I hopped through code with a tiny squeak,
Two names for one field — now both will speak,
A little alias, tests snug and bright,
Backend and schema sleep well tonight. 🐇"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a serde alias to accept time_window_days in the QueryGlobalRequest struct.
Linked Issues check ✅ Passed The PR fully implements the suggested fix from issue #2252 by adding #[serde(alias = "time_window_days")] to QueryGlobalRequest.window_days, restoring schema compatibility and preserving backward compatibility.
Out of Scope Changes check ✅ Passed All changes directly address the linked issue #2252: the serde alias addition and unit test expansion are scoped to fixing the schema mismatch without introducing unrelated modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 20, 2026
@coderabbitai coderabbitai Bot added rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. working A PR that is being worked on by the team. labels May 21, 2026
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.

Looks good, nice work!

@graycyrus graycyrus merged commit a20f75b into tinyhumansai:main May 21, 2026
31 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. working A PR that is being worked on by the team.

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

2 participants