Skip to content

feat(session): add backward-compatible working_memory context field MVP#1553

Open
yeyitech wants to merge 1 commit intovolcengine:mainfrom
yeyitech:feat/rfc1481-working-memory-object
Open

feat(session): add backward-compatible working_memory context field MVP#1553
yeyitech wants to merge 1 commit intovolcengine:mainfrom
yeyitech:feat/rfc1481-working-memory-object

Conversation

@yeyitech
Copy link
Copy Markdown
Contributor

Summary

  • implement the 【RFC】OpenViking工作记忆设计v1 #1481 working memory object MVP as a new backward-compatible working_memory field in get_session_context()
  • populate working_memory.markdown from the latest archive overview plus a compact recent conversation tail
  • keep legacy latest_archive_overview, pre_archive_abstracts, and message payloads unchanged so existing callers continue to work
  • update the OpenClaw example client to prefer working_memory.markdown while falling back to latest_archive_overview

Testing

  • npm test -- --run tests/ut/context-engine-assemble.test.ts tests/ut/context-engine-compact.test.ts
  • manual unit-style verification of Session.get_session_context() / working-memory markdown assembly in Python

Notes

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Codex seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🏅 Score: 92
🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Edge Case Handling

_build_working_memory_markdown returns an empty string when there is no latest archive overview, even if recent conversation tail messages are available. This might omit useful context in sessions without archived summaries.

def _build_working_memory_markdown(
    self,
    latest_archive_overview: str,
    merged_messages: List[Message],
) -> str:
    """Build a compact working-memory markdown block for downstream clients."""
    overview = (latest_archive_overview or "").strip()
    if not overview:
        return ""

    sections = [overview]
    tail_messages = merged_messages[-_WORKING_MEMORY_TAIL_MAX_MESSAGES:]
    if tail_messages:
        sections.append("## Current Conversation Tail")
        sections.extend(self._format_working_memory_message(message) for message in tail_messages)
    return "\n\n".join(section for section in sections if section).strip()

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Include tail messages in working memory even without archive

The current implementation returns an empty working memory markdown if there is no
latest archive overview, even when there are tail messages available. This limits
the utility of the working memory for sessions without archives.

Modify the method to include tail messages even when no archive overview is present,
and only return empty if both overview and tail messages are missing.

openviking/session/session.py [833-848]

 def _build_working_memory_markdown(
     self,
     latest_archive_overview: str,
     merged_messages: List[Message],
 ) -> str:
     """Build a compact working-memory markdown block for downstream clients."""
     overview = (latest_archive_overview or "").strip()
-    if not overview:
-        return ""
-
-    sections = [overview]
+    sections = []
+    if overview:
+        sections.append(overview)
+    
     tail_messages = merged_messages[-_WORKING_MEMORY_TAIL_MAX_MESSAGES:]
     if tail_messages:
         sections.append("## Current Conversation Tail")
         sections.extend(self._format_working_memory_message(message) for message in tail_messages)
+    
     return "\n\n".join(section for section in sections if section).strip()
Suggestion importance[1-10]: 6

__

Why: The suggestion corrects a limitation where working memory markdown was empty even when tail messages existed, as long as there was no archive overview. This improves the utility of the working memory for sessions without archives.

Low

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants