fix: wire permission_response WS frames to the interactive-agent-layer - #472
Merged
Conversation
bot_chat's mid-session race only ever inspected the first non-stop client
frame per turn, logged a warning, and fell through to just awaiting the
session — silently dropping permission_response (and any subsequent
frame). That drop is why the permission approve/deny loop never reached
the layer end-to-end.
- Add LayerClient.respond_to_permission(request_id, approve), matching
PermissionRespondRequest (interactive_agent_layer/server.py).
- Add api/routes/bot.py::_respond_to_permission, mapping the frontend's
decision ("approve"/"deny") to the layer's boolean approve field;
failures are logged and swallowed (the gate's own permission timeout
is the backstop).
- Restructure the mid-session race into a loop that re-arms recv_task
after each frame, so multiple permission_response frames (or a stop
after one) are all consumed within a single turn instead of only the
first.
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
bot_chat's mid-session race only ever inspected the first non-stop client frame per turn (logged a warning, then fell through to just awaiting the session) — silently droppingpermission_responseframes entirely. This is why the approve/deny loop never reached the layer end-to-end.LayerClient.respond_to_permission(request_id, approve)— POSTs to/permission/{request_id}/respond, matching the realPermissionRespondRequestschema ({"approve": bool}) ininteractive_agent_layer/server.py.api/routes/bot.py::_respond_to_permissionmaps the frontend'sdecision("approve"/"deny") to the layer's booleanapprovefield; failures are logged and swallowed (the gate's own permission timeout is the backstop).recv_taskafter each frame, so multiple mid-session frames (e.g. twopermission_responses, or astopafter one) are all consumed within a single turn — not just the first.Test plan
tests/interactive_agent_layer/test_client.py— 3 tests forLayerClient.respond_to_permission(approve, deny, 404-raises) against a real ASGI-backed layer app.tests/api/test_bot_ws_permission_response.py— 6 integration tests: single approve round trip, deny→approve=False mapping, TWO permission_responses consumed in one turn, layer POST failure logged+swallowed (session still completes), missingrequest_iddropped without crashing, unrelated frame types still dropped+warned (regression guard).test_bot_ws.py,test_ws_event_types.py,test_agent_dispatch_ws.py,tests/interactive_agent_layer/) green — stop-cancels-session and disconnect-cancels-session behavior unaffected.🤖 Generated with Claude Code