Skip to content

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

Open
pty819 wants to merge 1 commit into
NousResearch:mainfrom
pty819:feat/openviking-sync-full-turn-context
Open

feat(openviking): sync full turn context (tool calls + results) to OpenViking session#34763
pty819 wants to merge 1 commit into
NousResearch:mainfrom
pty819:feat/openviking-sync-full-turn-context

Conversation

@pty819

@pty819 pty819 commented May 29, 2026

Copy link
Copy Markdown
Contributor

Closes #34762

Summary

The OpenVikingMemoryProvider.sync_turn() previously only received user_content and assistant_content as plain text (truncated to 4K each), discarding all tool calls, tool results, and intermediate messages from multi-step agent turns.

This PR wires the optional messages kwarg (added in commit 5a95fb2e1 / #28065) to OpenViking's session sync path, so the full turn context is posted to the OpenViking session for memory extraction.

Changes

All changes are in plugins/memory/openviking/__init__.py:

  1. sync_turn(): Added messages: Optional[List[Dict]] parameter — triggers MemoryManager to deliver the full message list
  2. Delta tracking: _last_message_count — only POST new messages since last sync, avoiding re-sending the entire conversation history every turn
  3. Tool call serialization: Tool calls are formatted as [function_name(args)] for the OpenViking session API
  4. Tool results: role: "tool" messages are included alongside user/assistant messages
  5. System prompt skip: System messages are skipped — they're session-wide state, not conversational turns
  6. on_session_switch(): Added to reset _last_message_count when the session changes (/resume, /reset, /branch)
  7. Backward compatibility: Falls back to legacy text-only behavior when messages is not provided

Verification

  • All 30 existing tests pass
  • Backward compatible: providers without messages parameter continue getting the old text-only signature
  • Delta tracking prevents redundant POSTs to OpenViking's session API
  • Thread safety preserved: sync_turn() joins the previous thread before starting a new one

The OpenVikingMemoryProvider.sync_turn() previously only received
user_content and assistant_content as plain text (truncated to 4K
each), discarding all tool calls, tool results, and intermediate
messages from multi-step agent turns.

This commit wires the optional messages kwarg (added in commit
5a95fb2 / NousResearch#28065) to OpenViking's session sync path:

- Accept messages: Optional[List[Dict]] in sync_turn() signature
- Track _last_message_count to POST only the delta of new messages
  on each turn (avoids re-sending entire history every call)
- Serialize tool_calls to compact text form for the session API
- Include role:tool messages (tool results) alongside user/assistant
- Skip system prompts (session-wide state, not conversational turns)
- Reset _last_message_count in initialize() and on_session_switch()
- Keep legacy text-only fallback when messages is not provided

Closes NousResearch#34762
@pty819 pty819 force-pushed the feat/openviking-sync-full-turn-context branch from 584a1cd to 8ac675a Compare May 29, 2026 18:05
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers labels May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants