Skip to content

feat(openviking): sync full turn context (tool calls + results) to OpenViking session #34762

@pty819

Description

@pty819

Problem

The OpenVikingMemoryProvider.sync_turn() currently only receives user_content and assistant_content as plain text (truncated to 4000 chars each). This means all tool calls, tool results, and intermediate reasoning from multi-step agent turns are lost in OpenViking's session history.

The infrastructure to pass full conversation context was added in #28065 / commit 5a95fb2e1MemoryProvider.sync_turn() now accepts an optional messages kwarg containing the complete OpenAI-style message list for the completed turn (including tool_calls, tool role messages, etc.). However, no in-tree memory provider currently uses it.

Root Cause

OpenVikingMemoryProvider.sync_turn() at plugins/memory/openviking/__init__.py:568 has the legacy signature:

def sync_turn(self, user_content, assistant_content, *, session_id=""):

Because it doesn't declare a messages parameter, MemoryManager._provider_sync_accepts_messages() returns False, and the rich message context is never delivered.

Impact

  • Tool invocations (function names, arguments) are missing from OpenViking sessions
  • Tool results are not stored — the knowledge extracted via tools is invisible to OpenViking's memory extraction pipeline
  • Only the final assistant text (already truncated to 4K) is persisted, significantly reducing the value of auto-extracted memories from session commits

Proposed Fix

The fix lives entirely in plugins/memory/openviking/__init__.py:

  1. Accept messages: Optional[List[Dict]] in sync_turn() signature — this triggers MemoryManager to deliver the full message list
  2. Track _last_message_count so we only POST the delta of new messages on each turn (avoiding re-sending the entire history every call)
  3. Serialize tool_calls to a compact text form [function_name(args)] for posting to the OpenViking session API
  4. Include role: "tool" messages (tool results) alongside user/assistant messages
  5. Skip system prompts (session-wide state, not conversational turns)
  6. Reset _last_message_count on session switch (on_session_switch) and initialization
  7. Keep legacy fallback when messages is not provided (backward-compatible)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/pluginsPlugin system and bundled pluginstool/memoryMemory tool and memory providerstype/featureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions