Skip to content

fix(memory): require semantic valid_at timestamp - #18462

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
yzl0ng:fix/memory-semantic-valid-at-prompt
Aug 19, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
yzl0ng:fix/memory-semantic-valid-at-prompt

Conversation

@yzl0ng

@yzl0ng yzl0ng commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • require a valid_at timestamp in the semantic-memory output schema
  • tell the extraction model to use conversation time when a fact has no date of its own
  • add a regression test for the assembled semantic prompt

This addresses the deterministic prompt inconsistency reported in #18415. The invalid-timestamp fallback is intentionally left unchanged because selecting its replacement policy requires a separate design decision.

Testing

  • uvx --from pytest --with pytest-asyncio pytest --noconftest -q test/unit_test/memory/utils/test_prompt_util.py
  • verified the regression test fails before the fix and passes after it
  • uvx ruff check test/unit_test/memory/utils/test_prompt_util.py
  • uvx ruff format --check memory/utils/prompt_util.py test/unit_test/memory/utils/test_prompt_util.py
  • python -m py_compile memory/utils/prompt_util.py test/unit_test/memory/utils/test_prompt_util.py

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🌈 python Pull requests that update Python code 🐞 bug Something isn't working, pull request that fix bug. 🧪 test Pull requests that update test cases. labels Aug 18, 2026
@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0358c163-e5a2-4c5c-9361-9dab1bf361a8

📥 Commits

Reviewing files that changed from the base of the PR and between f1e6b22 and 4fa3a24.

📒 Files selected for processing (2)
  • memory/utils/prompt_util.py
  • test/unit_test/memory/utils/test_prompt_util.py

Included review availability: Your plan includes up to 10 reviews per rolling hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The semantic prompt now directs undated facts to use the conversation time for valid_at. A unit test verifies the required timestamp guidance and rejects the previous generic format.

Changes

Semantic timestamp guidance

Layer / File(s) Summary
Prompt guidance and validation
memory/utils/prompt_util.py, test/unit_test/memory/utils/test_prompt_util.py
The semantic template uses conversation time for undated facts. The unit test checks the new guidance and excludes the previous format.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 4fa3a

This PR makes the semantic-memory timestamp requirement explicit and adds focused regression coverage; no actionable merge-blocking risk remains beyond normal checks and review.

Poem

I’m a rabbit with a prompt to tune,
Valid times now follow the moon.
Undated facts know when to be,
Conversation time sets them free.
Tests hop in and guard the decree.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: requiring a semantic-memory valid_at timestamp.
Description check ✅ Passed The description includes a complete Summary section that explains the change, context, scope, and testing details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@Lynn-Inf Lynn-Inf left a comment

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.

No need to enforce valid_at default in templates — it's already defined in prompt_util.py#L48. Also, good to see the or empty removed on line 80 — thanks!

@Lynn-Inf Lynn-Inf added the ci Continue Integration label Aug 19, 2026
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (f1e6b22) to head (4fa3a24).
⚠️ Report is 27 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #18462   +/-   ##
=======================================
  Coverage   90.65%   90.65%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          650      650           
  Misses         39       39           
  Partials       28       28           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

JinHai-CN pushed a commit that referenced this pull request Aug 19, 2026
## Summary

- allow ISO 8601 normalization callers to provide an explicit fallback
while preserving the existing default behavior
- use the extraction conversation time when `valid_at` is missing or
invalid
- clear an invalid optional `invalid_at` instead of writing an
unparseable value
- include the rejected timestamp value in the error log

This addresses the timestamp write-through portion of #18415. It is
intentionally separate from #18462, which fixes the semantic output
prompt.

Co-authored-by: Loong <[email protected]>
@JinHai-CN
JinHai-CN merged commit a6b5e98 into infiniflow:main Aug 19, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration 🌈 python Pull requests that update Python code size:XS This PR changes 0-9 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants