fix(hooks): route OpenVikingPostCallHook through the sync path so enriched results aren't discarded - #3164
Open
nankingjing wants to merge 4 commits into
Open
Conversation
The previous integration test run on PR volcengine#3164 was CANCELLED before completion (likely a runner timeout / superseded by newer push). Other checks (plugin-tests, check-deps) are green. Pushing an empty commit to re-trigger the integration suite so the PR has a definitive result before maintainer review.
Contributor
Author
| Self-reviewed: diff is correct, minimal, and well-tested. No issues found. |
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.
Summary
OpenVikingPostCallHook.execute()enrichesread_fileresults for skill files with related experience memories, returning{tool_name, params, result}. Since #2503 flipped the hook tois_sync = False, that return value has been silently discarded: the enrichment never reaches the model.Problem
HookManager.execute_hookshas two paths:is_sync = False):asyncio.gather(...)— results are only inspected for error logging and then dropped;is_sync = True):kwargs = await hook.execute(context, **kwargs)— the return value is threaded back and ultimately consumed by the tool registry viahook_result.get("result").#2503 moved this hook to the async path on the reasoning that "execute() is genuinely async". But both paths await coroutines (the sync path also
awaits), andexecute_hooksawaits the gather before returning anyway — so the async path buys no latency here; it only loses the return value. Result: the appended "Related Experiences" block silently vanished from everyread_fileon a skill file.Fix
is_sync = Truewith a comment documenting the routing contract (sync path = return values threaded back; async path = returns discarded).isinstance(result, str)guard before running the regex. Tool failures reach this hook asExceptioninstances (the registry stores the raised exception as the result), andre.searchraisesTypeErroron non-str input. On the sync path such an exception would now propagate and turn a completed tool call into a failure, so the guard is load-bearing. The previousnot isinstance(result, Exception)check is dropped: astrcan never also be anException(CPython rejects that MI with "multiple bases have instance lay-out conflict"), so it was dead code.Tests
bot/vikingbot/tests/unit/test_hooks_sync_routing.py(8 tests):execute()behavior with the network search stubbed:Exception/dict results pass through untouched, non-read_filetools are ignored, skill markdown gets the experiences appended, and theexperience_loaderskill is skipped.