Skip to content

fix: wire permission_response WS frames to the interactive-agent-layer - #472

Merged
jlunder00 merged 1 commit into
devfrom
feature/bot-permission-response-link
Jul 4, 2026
Merged

fix: wire permission_response WS frames to the interactive-agent-layer#472
jlunder00 merged 1 commit into
devfrom
feature/bot-permission-response-link

Conversation

@jlunder00

Copy link
Copy Markdown
Owner

Summary

  • The keystone fix for the permission approve/deny loop (brief 1d). 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 dropping permission_response frames 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 real PermissionRespondRequest schema ({"approve": bool}) in interactive_agent_layer/server.py.
  • api/routes/bot.py::_respond_to_permission maps 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).
  • Restructured the mid-session race into a loop that re-arms recv_task after each frame, so multiple mid-session frames (e.g. two permission_responses, or a stop after one) are all consumed within a single turn — not just the first.

Test plan

  • New: tests/interactive_agent_layer/test_client.py — 3 tests for LayerClient.respond_to_permission (approve, deny, 404-raises) against a real ASGI-backed layer app.
  • New: 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), missing request_id dropped without crashing, unrelated frame types still dropped+warned (regression guard).
  • Full existing suite (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.
  • Full repo suite: 992 passed, 740 skipped (DB-dependent), 0 failed.

🤖 Generated with Claude Code

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.
@jlunder00
jlunder00 merged commit cb3ce8c into dev Jul 4, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant