fix(openviking): structured turn sync — guard empty tool_id, reuse env_var_enabled (salvage #48894) - #48924
Merged
kshitijk4poor merged 7 commits intoJun 19, 2026
Conversation
…_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).
19 tasks
_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.
…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
enabled auto-merge
June 19, 2026 08:38
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)
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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; identicalgit patch-idto the originalc0511026).d7cd0bc0+5a856bdf— @ehz0ah's follow-up attribution/text-flattening fixes and thescripts/release.pycontributor 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:
fix— emptytool_idpoisoned the batch skip set + reuseenv_var_enabled. In_messages_to_openviking_batch, a recall-tool result's id was added toskipped_tool_idseven when empty. An emptytool_call_idis reachable in the canonical transcript (agent/agent_runtime_helpers.pydefaults it to""), so a""in the skip set would silently drop any other tool result that also lacked an id. Moved the recall-skipaddinside the existingif tool_id:guard, with a regression test (mutation-checked). Also swapped the open-coded_sync_trace_enabled()truthy-env check forutils.env_var_enabled(byte-identical semantics).refactor— derive_OPENVIKING_RECALL_TOOL_NAMESfrom 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.refactor— reuse the pre-scannedtool_inputfor 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.refactor— name thetool_statusconstants 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)
git patch-idmatch).release.pyattribution (eurekaxun@163.com → huangxun375-stack) matches Integrate OpenViking structured turn sync #37251's author._commit_sessionposting{"keep_recent_count": 0}is not a behavior change — the prior bare post sent{}, and OpenViking's documented default forkeep_recent_countis0._message_text(assistant_content)[:4000]cannot drop content —flatten_message_textis the identity onstr.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 defensivegetattris required.Type of Change
How to Test
Result locally: 153 passed (152 from #48894 + 1 new H3 regression test).
ruff checkon the touched files: clean. The H3 regression test is mutation-checked on the final stack (fails on pre-fix code, passes after).Credit
tool_idguard,env_var_enabledreuse, and the three cleanups: this PR.Supersedes #48894, #37251, #34763.