Skip to content

The agent that grows with you

fix(gateway): keep pre-upgrade credential references valid with the new posture field

kshitijk4poor0e46fbad567f
diff --git a/gateway/session_policy_credentials.py b/gateway/session_policy_credentials.py
index 902e95d00d7..a9947669437 100644
--- a/gateway/session_policy_credentials.py
+++ b/gateway/session_policy_credentials.py
@@ -15,8 +15,11 @@ def policy_identity(policy):
data = asdict(policy)
data.pop('credential_ref')
data.pop('config_secret_ref')
+ # Fields added after release are hashed only when set, so an older session's reference still matches.
if data.get('editor_mcp_json') is None:
data.pop('editor_mcp_json', None)
+ if not data.get('coding_posture'):
+ data.pop('coding_posture', None)
return hashlib.sha256(json.dumps(data, sort_keys=True).encode()).hexdigest()
diff --git a/tests/acp_adapter/test_policy_identity_compat.py b/tests/acp_adapter/test_policy_identity_compat.py
index aabcf9f5923..566b4fc8f08 100644
--- a/tests/acp_adapter/test_policy_identity_compat.py
+++ b/tests/acp_adapter/test_policy_identity_compat.py
@@ -12,5 +12,6 @@ def test_policy_identity_preserves_pre_editor_credential_binding(tmp_path):
legacy.pop('credential_ref')
legacy.pop('config_secret_ref')
legacy.pop('editor_mcp_json')
+ legacy.pop('coding_posture')
expected = hashlib.sha256(json.dumps(legacy, sort_keys=True).encode()).hexdigest()
assert policy_identity(policy) == expected