The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(acp): refuse a non-string edit policy as invalid_params
Tekniume4ebadedc087
diff --git a/hermes_state_mutations.py b/hermes_state_mutations.pyindex 53853bd887a..120cc5b19f9 100644--- a/hermes_state_mutations.py+++ b/hermes_state_mutations.py@@ -32,7 +32,8 @@ def validate_action(operation, payload):if operation == 'editor_mcp' and set(payload) == {'mcp_servers'} and _valid_editor_fingerprint(payload):return# An ACP session's edit approval policy (gateway/session_mutation_policy.py prepare_edit_policy).- if operation == 'edit_policy' and set(payload) == {'policy'} and payload['policy'] in {'ask', 'workspace_session', 'session'}:+ if (operation == 'edit_policy' and set(payload) == {'policy'} and isinstance(payload['policy'], str)+ and payload['policy'] in {'ask', 'workspace_session', 'session'}):returnif operation == 'compress' and _valid_compress_payload(payload):returndiff --git a/tests/gateway/test_session_edit_policy.py b/tests/gateway/test_session_edit_policy.pyindex 2600152dd19..af41328576b 100644--- a/tests/gateway/test_session_edit_policy.py+++ b/tests/gateway/test_session_edit_policy.py@@ -66,8 +66,10 @@ async def test_edit_policy_is_a_durable_session_setting_every_viewer_reads(tmp_passert policy_for_source(first.runner, live.source).edit_approval_policy == 'workspace_session'assert (await _info(other, sid))['edit_approval_policy'] == 'workspace_session'- bad = await editor.dispatch(_mutation(db, sid, 'm2', {'policy': 'yolo'}))- assert bad['error']['data']['reason'] == 'invalid_params', bad+ # An unknown or non-string policy is refused as a bad request, never an internal error.+ for value in ['yolo', [], {}]:+ bad = await editor.dispatch(_mutation(db, sid, 'm2', {'policy': value}))+ assert bad['error']['data']['reason'] == 'invalid_params', bad# Only an ACP session has an editor edit policy; any other surface's edits never ask an editor.refused = await editor.dispatch(_mutation(db, gui, 'm3', {'policy': 'session'}))assert refused['error']['data']['reason'] == 'invalid_params', refused