hermes: normalize image edit references
All checks were successful
Tests / Declarative: Post Actions passed: 246

This commit is contained in:
jenkins 2026-08-12 01:33:33 -03:00
parent edcb2935e4
commit 216f567e0f
3 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -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:<path>``.
# 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

View File

@ -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"]