Skip to content

feat(vikingbot): self-evolving agent memory with experience injection#2007

Merged
yeshion23333 merged 2 commits into
volcengine:mainfrom
yangxinxin-7:feat/agent-memory-self-evolve
May 13, 2026
Merged

feat(vikingbot): self-evolving agent memory with experience injection#2007
yeshion23333 merged 2 commits into
volcengine:mainfrom
yangxinxin-7:feat/agent-memory-self-evolve

Conversation

@yangxinxin-7
Copy link
Copy Markdown
Collaborator

@yangxinxin-7 yangxinxin-7 commented May 13, 2026

Summary

  • Fix agent memory URI: use openviking_config.agent_id instead of workspace_id, preventing namespace mismatch when agent_id is unconfigured in ov.conf
  • Disable agent memory in auto recall: experience memories are not searched during auto recall — only user memory is; experience injection is now done proactively at the right call sites
  • Inject experience memory on skill load: via PostCallHook on read_file, experience context is prepended when a skill file is loaded
  • Inject experience memory on subagent spawn: relevant experiences are injected into subagent task prompts before dispatch
  • Inject experience memory before write-related tool calls: before write_file / edit_file, the LLM response is rolled back and re-called with experience context; guarded by a write_exp_injected flag so it only fires once per message
  • Gate all injection features via config: agent_memory_enabled and exp_write_tools fields added to OpenVikingConfig

Implementation discussed with @huangruiteng.

🤖 Generated with Claude Code

@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: 80
🧪 No relevant tests
🔒 No security concerns identified
✅ No TODO sections
🔀 Multiple PR themes

Sub-PR theme: Fix agent memory URI and disable auto recall

Relevant files:

  • bot/vikingbot/config/schema.py
  • bot/vikingbot/openviking_mount/ov_server.py

Sub-PR theme: Add experience memory injection for skills and subagents

Relevant files:

  • bot/vikingbot/agent/memory.py
  • bot/vikingbot/agent/subagent.py
  • bot/vikingbot/hooks/builtins/openviking_hooks.py

Sub-PR theme: Add experience memory injection before write tools

Relevant files:

  • bot/vikingbot/agent/loop.py

⚡ Recommended focus areas for review

Possible AttributeError

_search_skill_experiences assumes exp is a dict and calls exp.get(), but doesn't handle the case where exp is an object. This would raise an AttributeError if search_experiences returns objects instead of dicts.

uri = exp.get("uri", "")
score = exp.get("score", 0)
if score < 0.3:
    continue

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Support both dict and object experience items

Handle both dict and object types for exp (same as in memory.py). This prevents
AttributeError if exp is an object instead of a dict, which matches the pattern used
elsewhere in the codebase.

bot/vikingbot/hooks/builtins/openviking_hooks.py [110-115]

 for exp in experiences:
-    uri = exp.get("uri", "")
-    score = exp.get("score", 0)
+    uri = exp.get("uri", "") if isinstance(exp, dict) else getattr(exp, "uri", "")
+    score = exp.get("score", 0) if isinstance(exp, dict) else getattr(exp, "score", 0)
     if score < 0.3:
         continue
     content = await ov_client.read_content(uri, level="read")
Suggestion importance[1-10]: 5

__

Why: This improves robustness by handling both dict and object types for exp items, consistent with the pattern used in memory.py, preventing potential AttributeErrors.

Low

Copy link
Copy Markdown
Collaborator

@yeshion23333 yeshion23333 left a comment

Choose a reason for hiding this comment

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

I found two blocking issues and a few follow-up suggestions. The main concerns are workspace-scoped OpenViking routing regressing to a global singleton in hooks, and skill memory retrieval being replaced by experience search instead of being augmented.

Comment thread bot/vikingbot/hooks/builtins/openviking_hooks.py Outdated
Comment thread bot/vikingbot/hooks/builtins/openviking_hooks.py
Comment thread bot/vikingbot/agent/subagent.py
Comment thread bot/vikingbot/agent/loop.py
Comment thread bot/vikingbot/config/schema.py
@yangxinxin-7 yangxinxin-7 force-pushed the feat/agent-memory-self-evolve branch from 6669d95 to 34b5500 Compare May 13, 2026 06:30
Rebase onto upstream/main (commit 6312e1e). Conflicts resolved by keeping
upstream namespace-aware logic while preserving our experience memory changes:
- loop.py: inject experience memory before write tool calls (write_file, edit_file)
- subagent.py: prepend relevant experience memory to subagent task prompt
- memory.py: add get_viking_experience_context() for semantic experience search
- hooks.py: replace exact skill lookup with semantic experience search
- ov_server.py: add search_experiences(); search_memory returns agent_memory=[]
- schema.py: add exp_write_tools config; remove agent_memory_enabled gate

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yangxinxin-7 yangxinxin-7 force-pushed the feat/agent-memory-self-evolve branch from 34b5500 to 5afa227 Compare May 13, 2026 06:42
…bility

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yeshion23333 yeshion23333 merged commit dcac266 into volcengine:main May 13, 2026
4 of 5 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project May 13, 2026
ZaynJarvis pushed a commit that referenced this pull request May 13, 2026
…#2007)

* feat(bot): agent experience memory self-evolve injection

Rebase onto upstream/main (commit 6312e1e). Conflicts resolved by keeping
upstream namespace-aware logic while preserving our experience memory changes:
- loop.py: inject experience memory before write tool calls (write_file, edit_file)
- subagent.py: prepend relevant experience memory to subagent task prompt
- memory.py: add get_viking_experience_context() for semantic experience search
- hooks.py: replace exact skill lookup with semantic experience search
- ov_server.py: add search_experiences(); search_memory returns agent_memory=[]
- schema.py: add exp_write_tools config; remove agent_memory_enabled gate

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(bot): add [SKILL_EXP] log to skill experience search for observability

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
MaojiaSheng pushed a commit that referenced this pull request May 19, 2026
#2007) (#2014)

* docs(bot): document ov_server.api_key_type field (#1994)

* docs(bot): document ov_server.api_key_type and exp_write_tools (#1994 + #2007)

* docs(bot): tighten api_key_type wording + flag exp_write_tools gate (codex feedback)

* docs(bot): tighten api_key_type wording + flag exp_write_tools gate (codex feedback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants