refactor(agent): unwire eager 7-day memory-tree digest from turn loop (#3170)#3171
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
💤 Files with no reviewable changes (4)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughRemoves the unconditional eager 7-day memory-tree digest injection from the agent turn loop: deletes session prefetch tracking, removes the prefetch block from ChangesMemory-tree eager prefetch removal
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/openhuman/agent/tree_loader.rs (1)
14-48: 💤 Low valueConsider clarifying that the behavior descriptions are historical.
The NOTE section correctly explains this module is unwired, but the subsequent documentation uses present tense ("The orchestrator answers...", "We pre-load...") which could confuse readers who miss the transition at line 12-13. Similarly, constants like
DEFAULT_WINDOW_DAYSandREFRESH_INTERVALare documented as if actively used.For clearer documentation:
- Rewrite lines 14-20 in past tense, or add explicit "Historically," / "Previously," markers
- Update constant doc-comments (lines 38-48) to note they're retained for future re-wiring
- Optionally add a brief note to the
loadfunction doc (line 79) referencing the module-level NOTEThis would help future maintainers quickly understand the module's current status without needing to carefully parse the NOTE transition.
🤖 Prompt for 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. In `@src/openhuman/agent/tree_loader.rs` around lines 14 - 48, Update the module and constant docs to make the historical status explicit: revise the top-level doc lines that currently read in present tense ("The orchestrator answers...", "We pre-load...") to past-tense or prepend "Historically,"/ "Previously," to indicate the module was once wired; update the `DEFAULT_WINDOW_DAYS` and `REFRESH_INTERVAL` doc-comments to note these constants are retained for potential future re-wiring rather than actively used; and add a one-sentence pointer in `TreeContextLoader::load`'s doc comment referencing the module-level NOTE about being unwired so callers see the status without parsing the full header.
🤖 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.
Nitpick comments:
In `@src/openhuman/agent/tree_loader.rs`:
- Around line 14-48: Update the module and constant docs to make the historical
status explicit: revise the top-level doc lines that currently read in present
tense ("The orchestrator answers...", "We pre-load...") to past-tense or prepend
"Historically,"/ "Previously," to indicate the module was once wired; update the
`DEFAULT_WINDOW_DAYS` and `REFRESH_INTERVAL` doc-comments to note these
constants are retained for potential future re-wiring rather than actively used;
and add a one-sentence pointer in `TreeContextLoader::load`'s doc comment
referencing the module-level NOTE about being unwired so callers see the status
without parsing the full header.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fbaf0783-9160-44ea-abe2-eee2e8ebc6d3
📒 Files selected for processing (5)
src/openhuman/agent/harness/session/builder.rssrc/openhuman/agent/harness/session/turn.rssrc/openhuman/agent/harness/session/turn_tests.rssrc/openhuman/agent/harness/session/types.rssrc/openhuman/agent/tree_loader.rs
💤 Files with no reviewable changes (4)
- src/openhuman/agent/harness/session/types.rs
- src/openhuman/agent/harness/session/builder.rs
- src/openhuman/agent/harness/session/turn.rs
- src/openhuman/agent/harness/session/turn_tests.rs
|
@coderabbitai addressed the nitpick in 88b6da9: rewrote the module-level behavior description in past tense, noted that |
|
Tip For best results, initiate chat on the files or code changes.
|
…tinyhumansai#3170) The orchestrator turn loop unconditionally injected a "last 7 days" memory-tree digest onto the user message on the first turn and every 30 min thereafter. This is now redundant with the on-demand memory-tree retrieval tools (smart multi-strategy walk, tinyhumansai#3077), and — unlike those tools — it ignored the memory-tree on/off toggle, which only gates the ingestion scheduler (scheduler_gate.mode), not this read path. So even with the tree disabled, every session still force-fed the 7-day digest to the model. Remove the eager prefetch from the turn loop and drop the per-session last_tree_prefetch_at bookkeeping. The tree_loader module is retained (still covered by tests/inference_agent_raw_coverage_e2e.rs) so an opt-in eager digest can be re-wired behind a proper read-side gate later; its docstring now records that it is currently unwired. On-demand memory retrieval is unaffected — only the unconditional auto-injection is removed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…nyhumansai#3170) Address CodeRabbit review: rewrite the module-level behavior description in past tense, note that DEFAULT_WINDOW_DAYS / REFRESH_INTERVAL are retained for a future re-wiring rather than actively used, and point TreeContextLoader::load at the module-level "unwired" NOTE. Doc-only; no behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
88b6da9 to
ace3c91
Compare
…tinyhumansai#3170) (tinyhumansai#3171) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
last_tree_prefetch_atbookkeeping (field, initializer, two test work-arounds).tree_loadermodule (still exercised by an e2e test) so an opt-in eager digest can be re-wired behind a proper read-side gate later; its docstring now records that it is currently unwired.Problem
The agent turn loop (
src/openhuman/agent/harness/session/turn.rs) calledtree_loader::TreeContextLoader::loadon a 30-min cadence and prepended a[Memory tree — last 7 days]digest to the turn context. Two issues:memory_tree_set_enabled) only flipsscheduler_gate.mode(Auto/Off) — i.e. it pauses ingestion workers. The read/prefetch path inturn.rshad no gate check, so even with the tree toggled off, every session still injected the 7-day digest into the prompt.Solution
turn.rs; the turn context is now just thememory_loader.load_context(...)result.last_tree_prefetch_atfrom the session state (types.rs) and builder (builder.rs).last_tree_prefetch_atto suppress the prefetch — the tests now pass deterministically because the path no longer exists.tree_loader.rs(its public surface is still covered bytests/inference_agent_raw_coverage_e2e.rs); docstring updated to note it is unwired pending a future read-side gate.On-demand memory retrieval is unaffected — only the unconditional auto-injection is removed.
Submission Checklist
turn_runs_full_tool_cycle_with_context_and_hooks,turn_uses_cached_transcript_prefix_on_first_iteration) were simplified and pass without their prefetch-suppression hack.docs/TEST-COVERAGE-MATRIX.mdreferences the eager digest.## Related— N/A: no matrix feature IDs affected.Closes #NNN.Impact
Related
scheduler_gate.mode.AI Authored PR Metadata
Linear Issue
Commit & Branch
Validation Run
pnpm --filter openhuman-app format:check— N/A: no frontend changes.pnpm typecheck— N/A: no TS changes.cargo test --lib tree_loader(5 ok),turn_runs_full_tool_cycle_with_context_and_hooks+turn_uses_cached_transcript_prefix_on_first_iteration(2 ok).cargo fmt --checkclean;cargo check --testsclean (warnings pre-existing, unrelated).Behavior Changes
Parity Contract
tree_loadermodule retained for future re-wiring.memory_loader.load_contextremains the context source.Duplicate / Superseded PR Handling
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation
Tests