Skip to content

fix(openviking): structured turn sync — guard empty tool_id, reuse env_var_enabled (salvage #48894) - #48924

Merged
kshitijk4poor merged 7 commits into
NousResearch:mainfrom
kshitijk4poor:salvage-48894-structured-sync
Jun 19, 2026
Merged

fix(openviking): structured turn sync — guard empty tool_id, reuse env_var_enabled (salvage #48894)#48924
kshitijk4poor merged 7 commits into
NousResearch:mainfrom
kshitijk4poor:salvage-48894-structured-sync

Conversation

@kshitijk4poor

@kshitijk4poor kshitijk4poor commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Salvage of #48894 (which itself supersedes #34763 and #37251). All upstream authorship is preserved via cherry-pick; this PR adds verified review fixes + cleanups on top.

The base three commits are carried verbatim from #48894:

  • c7b7f92e — the Integrate OpenViking structured turn sync #37251 structured-sync implementation, authored by Eurekaxun (faithful cherry-pick; identical git patch-id to the original c0511026).
  • d7cd0bc0 + 5a856bdf@ehz0ah's follow-up attribution/text-flattening fixes and the scripts/release.py contributor mapping.

On top of those, four follow-up commits from a full review of #48894 — one fix and three behavior-preserving cleanups, one concern each:

  1. fix — empty tool_id poisoned the batch skip set + reuse env_var_enabled. In _messages_to_openviking_batch, a recall-tool result's id was added to skipped_tool_ids even when empty. An empty tool_call_id is reachable in the canonical transcript (agent/agent_runtime_helpers.py defaults it to ""), so a "" in the skip set would silently drop any other tool result that also lacked an id. Moved the recall-skip add inside the existing if tool_id: guard, with a regression test (mutation-checked). Also swapped the open-coded _sync_trace_enabled() truthy-env check for utils.env_var_enabled (byte-identical semantics).
  2. refactor — derive _OPENVIKING_RECALL_TOOL_NAMES from the canonical *_SCHEMA["name"] constants instead of hardcoded literals, so a tool rename can't desync the set. Write tools remain intentionally excluded; set contents unchanged.
  3. refactor — reuse the pre-scanned tool_input for pending tool calls instead of re-parsing the arguments a second time (cache hit for non-empty ids, parse fallback only for the uncached empty-id case so arguments are never dropped). No behavior change.
  4. refactor — name the tool_status constants and inbound alias sets (_TOOL_STATUS_*, _TOOL_STATUS_{ERROR,COMPLETED}_ALIASES) so the canonical wire values and the alias→canonical mapping live in one place. Emitted values unchanged.

Review summary (claims verified against #48894)

One review HIGH was investigated and dropped as a false positive: a proposed "drop the getattr(self, "_agent", _DEFAULT_AGENT) fallback" was reverted — OpenVikingMemoryProvider.__init__ does not set _agent (it's set later during configure), so the defensive getattr is required.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ♻️ Refactor (no behavior change)
  • ✅ Tests (adding or improving test coverage)

How to Test

scripts/run_tests.sh tests/agent/test_message_content.py tests/openviking_plugin/test_openviking.py tests/plugins/memory/test_openviking_provider.py tests/run_agent/test_codex_app_server_integration.py

Result locally: 153 passed (152 from #48894 + 1 new H3 regression test). ruff check on the touched files: clean. The H3 regression test is mutation-checked on the final stack (fails on pre-fix code, passes after).

Credit

Supersedes #48894, #37251, #34763.

Eurekaxun and others added 4 commits June 19, 2026 15:23
…_enabled

Two follow-up fixes on top of the cherry-picked structured-sync work:

- _messages_to_openviking_batch only added a recall tool result's id to
  skipped_tool_ids when the id was non-empty. An empty tool_call_id (which
  the canonical transcript can carry; agent_runtime_helpers defaults it to
  "") poisoned the skip set with "", silently dropping any *other* tool
  result that also lacked an id. Move the recall-skip add inside the
  existing `if tool_id:` guard. Adds a regression test (mutation-checked:
  fails on pre-fix code, passes after).

- _sync_trace_enabled() open-coded the canonical truthy-env check; reuse
  utils.env_var_enabled (byte-identical {1,true,yes,on} semantics).
_OPENVIKING_RECALL_TOOL_NAMES hardcoded the three read-tool names as string
literals, which can silently desync from the *_SCHEMA["name"] constants on a
rename (the same drift the adjacent _CATEGORY_SUBDIR_MAP comment warns about).
Derive the set from SEARCH/READ/BROWSE_SCHEMA["name"] instead. Write tools
(viking_remember / viking_add_resource) remain intentionally excluded. Set
contents are unchanged.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers P3 Low — cosmetic, nice to have labels Jun 19, 2026
…alls

_messages_to_openviking_batch's pre-scan already parses and caches each
tool call's arguments into tool_calls_by_id. The pending-tool-call branch
re-parsed them via _tool_call_input(), a second parse and a second source
of truth. Reuse the cached tool_input when the id was cached (non-empty),
falling back to a parse only for the uncached empty-id case so arguments
are never dropped. No behavior change.
The batch tool_status values ('completed'/'error'/'pending') and the inbound
status alias sets were inline magic strings, duplicated across two checks in
_tool_result_status. Hoist them to module-level constants
(_TOOL_STATUS_* + _TOOL_STATUS_{ERROR,COMPLETED}_ALIASES) so the canonical
wire values and the alias->canonical mapping live in one place. Emitted
values are unchanged.
@kshitijk4poor
kshitijk4poor enabled auto-merge June 19, 2026 08:38
@kshitijk4poor
kshitijk4poor merged commit 527a47f into NousResearch:main Jun 19, 2026
34 checks passed
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…4-structured-sync

fix(openviking): structured turn sync — guard empty tool_id, reuse env_var_enabled (salvage NousResearch#48894)
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
…4-structured-sync

fix(openviking): structured turn sync — guard empty tool_id, reuse env_var_enabled (salvage NousResearch#48894)
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
…4-structured-sync

fix(openviking): structured turn sync — guard empty tool_id, reuse env_var_enabled (salvage NousResearch#48894)
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…4-structured-sync

fix(openviking): structured turn sync — guard empty tool_id, reuse env_var_enabled (salvage NousResearch#48894)
@kshitijk4poor
kshitijk4poor deleted the salvage-48894-structured-sync branch August 5, 2026 07:08
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
…4-structured-sync

fix(openviking): structured turn sync — guard empty tool_id, reuse env_var_enabled (salvage NousResearch#48894)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants