Abilities: gate pre-execute with approval decision filter, surface from loop#234
Merged
chubes4 merged 2 commits intoMay 28, 2026
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
Two coupled pieces of #94 in one PR: the
wp_pre_execute_abilitybridge handler that mints pending actions and returnsapproval_requiredenvelopes, and themediate_tool_callsbranch that recognizes those envelopes and surfacesstatus: approval_requiredfrom the loop.Refs #94. Stacks on the lifecycle bridge added in #199.
Bridge handler
Adds
gate_pre_executeas a second handler onWP_Agent_Ability_Lifecycle_Bridge. Hosts opt into per-call approval by hookingagents_api_ability_pre_execute_decisionand returning either aWP_Agent_Pending_Actionor an array shapeWP_Agent_Pending_Action::from_array()accepts. The bridge handles the boilerplate: sentinel pass-through so stacked consumers coexist, minting (when needed) throughfrom_array(), best-effort staging through thewp_agent_pending_action_storefilter, and returning the canonicalapproval_requiredenvelope.Loop recognition
mediate_tool_callsnow detects when an ability call returned anapproval_requiredenvelope, captures it, appends it to the transcript in place of the tool_result, emits anapproval_requiredevent with the action_id, and halts mediation for the turn. The outerrun()loop surfacesstatus: 'approval_required'andcompleted: falseon the final result, mirroring howbudget_exceededandstalledare surfaced today.Changes
src/Abilities/class-wp-agent-ability-lifecycle-bridge.php: newFILTER_PRE_EXECUTE_DECISIONandFILTER_PENDING_ACTION_STOREconsts, secondadd_filterinregister(), newgate_pre_executestatic method.src/Runtime/class-wp-agent-conversation-loop.php: approval detection insidemediate_tool_calls, newapproval_requiredreturn key, per-turn pickup inrun(), status block on the final result.tests/pre-execute-approval-smoke.php: new smoke covering sentinel pass-through, null decision = pass-through, pending-action decision = mint+stage+envelope, the coexistence guarantee (second consumer bails on a non-sentinel$pre), and loop-level recognition.composer.json: registers the new smoke.docs/runtime-and-tools.md: new "Ability lifecycle bridge" section + a paragraph in "Budgets, events, and failure behavior" for the new loop status.Testing
php tests/pre-execute-approval-smoke.php— 14 assertions, all pass.php tests/ability-lifecycle-bridge-smoke.php— 12 assertions, all pass (existing, unchanged behavior).php tests/conversation-loop-tool-execution-smoke.php— all pass (unchanged).composer test— full suite green.git diff --check— clean.php -lon all modified files — clean.AI assistance