fix: preserve normalized pending mediation requests - #522
Merged
Conversation
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
agents_api_pre_tool_call_decisionRoot cause
pre_tool_mediation_decision()normalized the option mediator's pending decision before applyingagents_api_pre_tool_call_decision, then normalized the filter result again. On that second pass,normalize_pre_tool_mediation_decision()treated the already-normalizeddecision['result']tool-result envelope as though it were the pending request itself. Because the actual request was nested underresult.runtime_tool_request, request normalization could not see the host-providedrequest_idand generated a replacement hash ID.The pending branch now recognizes an already-normalized tool-result envelope, unwraps its canonical
runtime_tool_request, and retains the envelope's runtime, metadata, and error fields. Existing compatibility is preserved: explicit top-levelruntime_tool_requestremains first priority, therequestalias remains second, and legacy raw requests supplied throughresultcontinue to normalize as before.Verification
php tests/conversation-loop-tool-execution-smoke.php(123 assertions passed)php -l src/Runtime/class-wp-agent-conversation-loop.php(no syntax errors)php -l tests/conversation-loop-tool-execution-smoke.php(no syntax errors)composer phpstan(no errors)git diff --check(clean)Fixes #521