Skip to content

The agent that grows with you

fix(gateway): allow memory review commands locally

KoNit-K2fa1ae70bf76
diff --git a/gateway/session_commands.py b/gateway/session_commands.py
index 1910265a006..25b6bb9fb86 100644
--- a/gateway/session_commands.py
+++ b/gateway/session_commands.py
@@ -73,10 +73,11 @@ _READ_ARGUMENTS = {
# The write forms of a command whose reads are above: the messaging handler's own review verbs,
-# applied for this session's profile (`/skills approve|reject` the staged queue, `/skills approval`
-# its config.yaml switch, as main's CLI wrote it).
+# applied for this session's profile (`/memory` and `/skills` approve|reject their staged queues;
+# `approval` updates their config.yaml switch, as main's CLI wrote it).
_CONTROL_ARGUMENTS = {
'skills': lambda arg: _first_token(arg) in {'approve', 'apply', 'reject', 'deny', 'drop', 'approval', 'mode'},
+ 'memory': lambda arg: _first_token(arg) in {'approve', 'apply', 'reject', 'deny', 'drop', 'approval', 'mode'},
}
diff --git a/tests/gateway/test_session_read_commands.py b/tests/gateway/test_session_read_commands.py
index fcf2432fba3..7a57a5b6ed2 100644
--- a/tests/gateway/test_session_read_commands.py
+++ b/tests/gateway/test_session_read_commands.py
@@ -14,6 +14,17 @@ import pytest
from tests.gateway.fixtures.local_recovery_probe import Model, child_env, daemon, rpc, websocket
+def test_memory_review_verbs_are_local_session_controls():
+ from gateway.session_commands import command_verdict
+
+ assert command_verdict('memory', '') == 'read'
+ assert command_verdict('memory', 'pending') == 'read'
+ for args in ('approve entry-1', 'apply entry-1', 'reject all', 'deny entry-1', 'drop entry-1',
+ 'approval on', 'mode off'):
+ assert command_verdict('memory', args) == 'control'
+ assert command_verdict('memory', 'search user') == 'refused'
+
+
@pytest.mark.platforms("linux")
def test_local_session_reads_report_this_session_and_refuse_their_write_forms(tmp_path):
root = Path(__file__).resolve().parents[2]
@@ -55,7 +66,8 @@ def test_local_session_reads_report_this_session_and_refuse_their_write_forms(tm
for command in ('usage', 'insights', 'profile', 'topup', 'diff', 'memory', 'kanban list',
'suggestions', 'bundles', 'usage reset', 'memory approval on', 'kanban create x',
'suggestions catalog', 'agents', 'sessions', 'platform',
- 'toolsets', 'platforms', 'skills pending', 'skills reject nope', 'skills install x'):
+ 'toolsets', 'platforms', 'skills pending', 'skills reject nope', 'skills install x',
+ 'memory reject nope'):
try:
reply = await rpc(ws, 'slash.exec', session_id=sid, command=command)
except TimeoutError:
@@ -92,6 +104,7 @@ def test_local_session_reads_report_this_session_and_refuse_their_write_forms(tm
assert 'No pending' in out['skills pending'] or 'pending' in out['skills pending'].lower(), out['skills pending']
assert out['skills reject nope'] != 'unsupported_command', out['skills reject nope']
assert out['skills install x'] == 'unsupported_command', out['skills install x']
+ assert out['memory reject nope'] != 'unsupported_command', out['memory reject nope']
# Write forms, messaging-model state and gateway-wide views stay refused (the per-session settings
# run: tests/gateway/test_session_setting_commands.py).
for command in ('usage reset', 'memory approval on', 'kanban create x', 'suggestions catalog',