From 216f567e0f61466f018b51888cf8052579cdf1b2 Mon Sep 17 00:00:00 2001 From: jenkins Date: Wed, 12 Aug 2026 01:33:33 -0300 Subject: [PATCH] hermes: normalize image edit references --- services/hermes/chat-statefulset.yaml | 2 +- services/hermes/plugins/image-gen-broker/__init__.py | 5 +++++ testing/tests/test_hermes_chat_quality.py | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/services/hermes/chat-statefulset.yaml b/services/hermes/chat-statefulset.yaml index 1602c0c9d..290cea04c 100644 --- a/services/hermes/chat-statefulset.yaml +++ b/services/hermes/chat-statefulset.yaml @@ -29,7 +29,7 @@ spec: ai.bstein.dev/router-wire-contract: ollama-numeric-keepalive ai.bstein.dev/isolation: one Hermes process and PVC per Keycloak subject ai.bstein.dev/model-policy: uniform automatic policy with per-user overrides - ai.bstein.dev/config-rev: "20260812-keycloak-image-continuation" + ai.bstein.dev/config-rev: "20260812-image-reference-normalization" vault.hashicorp.com/agent-inject: "true" vault.hashicorp.com/role: hermes-chat vault.hashicorp.com/agent-inject-secret-anthropic-token: kv/data/atlas/hermes/agent-tokens diff --git a/services/hermes/plugins/image-gen-broker/__init__.py b/services/hermes/plugins/image-gen-broker/__init__.py index 041f5654b..e8bbc2420 100644 --- a/services/hermes/plugins/image-gen-broker/__init__.py +++ b/services/hermes/plugins/image-gen-broker/__init__.py @@ -151,6 +151,11 @@ def _request( def _local_image_data_url(value: str) -> str: """Convert a private uploaded image to a data URL for broker transport.""" candidate = value.strip() + # Hermes presents generated artifacts to the model as ``MEDIA:``. + # Most models pass only the path back to an edit tool, but accepting the + # marked form makes natural follow-up edits provider-independent. + if candidate.upper().startswith("MEDIA:"): + candidate = candidate[6:].strip() lowered = candidate.lower() if lowered.startswith(("http://", "https://", "data:image/")): return candidate diff --git a/testing/tests/test_hermes_chat_quality.py b/testing/tests/test_hermes_chat_quality.py index a5cc0b592..fe4223d62 100644 --- a/testing/tests/test_hermes_chat_quality.py +++ b/testing/tests/test_hermes_chat_quality.py @@ -379,6 +379,7 @@ def test_chat_image_generation_uses_private_owner_broker(): assert 'name="image_generate_local"' in plugin assert 'name="image_generate_hosted"' in plugin assert "newest MEDIA: path from the conversation" in plugin + assert 'candidate.upper().startswith("MEDIA:")' in plugin assert "override=True" not in plugin agent = _documents(HERMES / "agent-deployment.yaml")[0] @@ -484,7 +485,7 @@ def test_chat_reasoning_uses_switchyard_without_owner_credentials(): statefulset = _documents(HERMES / "chat-statefulset.yaml")[0] assert statefulset["spec"]["template"]["metadata"]["annotations"][ "ai.bstein.dev/config-rev" - ] == "20260812-keycloak-image-continuation" + ] == "20260812-image-reference-normalization" hermes = next( item for item in statefulset["spec"]["template"]["spec"]["containers"]