Skip to content

fix(zai): sanitize blocked Hermes prompt phrase - #48124

Closed
tt-a1i wants to merge 1 commit into
NousResearch:mainfrom
tt-a1i:codex/zai-hermes-agent-prompt-sanitize
Closed

fix(zai): sanitize blocked Hermes prompt phrase#48124
tt-a1i wants to merge 1 commit into
NousResearch:mainfrom
tt-a1i:codex/zai-hermes-agent-prompt-sanitize

Conversation

@tt-a1i

@tt-a1i tt-a1i commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a Z.AI provider-profile message hook that rewrites the exact blocked system/developer prompt phrase Hermes Agent to Hermes framework only in outbound API copies
  • apply provider message preparation to the max-iterations summary path, which calls chat completions directly
  • cover main-request sanitization, non-Z.AI preservation, and summary cached-prompt preservation

Closes #47685

Tests

  • /Users/tushaokun/.hermes/hermes-agent/venv/bin/python -m pytest tests/run_agent/test_run_agent.py -k "zai_sanitizes_hermes_agent or non_zai_preserves_hermes_agent or zai_summary_sanitizes_cached_system_prompt"
  • /Users/tushaokun/.hermes/hermes-agent/venv/bin/python -m pytest tests/run_agent/test_run_agent.py::TestBuildApiKwargs tests/run_agent/test_run_agent.py::TestHandleMaxIterations
  • git diff --check

Note: full ./scripts/run_tests.sh tests/run_agent/test_run_agent.py timed out at the runner's per-file timeout without assertion failures; the targeted classes above pass.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/zai ZAI provider P2 Medium — degraded but workaround exists labels Jun 18, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the careful work on this @tushaokun — the cache-safe outbound-copy design (untouched source messages + _cached_system_prompt, system/developer roles only, deterministic rewrite) was well done and the tests asserting the cache isn't mutated were exactly right.

We're declining the phrase-rewrite approach as a matter of policy, not code quality. If Z.AI's Coding Plan is in fact rejecting the literal string Hermes Agent, masking it in outbound requests would be working around a provider-side restriction we'd rather respect than circumvent. Our stance: treat the 429/1305 as transient capacity overload and back off; if it turns out we're genuinely not permitted to use the Coding Plan with Hermes, the right move is to stop offering it, not to disguise the prompt.

The overload side is being addressed in #52333 (salvaged from #47205, @benbenlijie) — narrow 1305 classifier + adaptive backoff (30→60→90→120s, capped), with long waits surfaced so the TUI doesn't look frozen, and no prompt rewriting.

#52333

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists provider/zai ZAI provider type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Z.AI GLM-5.2 Coding Plan returns 429/code 1305 when system prompt contains exact phrase "Hermes Agent"

3 participants