guygrigsby/hermes-empty-text-guard

★ 0Forks 0PythonGitHub ↗Compare

README

empty-text-guard

Hermes plugin that strips empty text blocks from outgoing LLM requests.

Anthropic rejects empty text blocks with 400: messages: text content blocks must be non-empty, and strict OpenAI-compatible shims reject empty assistant content on tool-call turns (hermes-agent#31583). Hermes emits both when it replays a reasoning-only or tool-call-only assistant turn. OpenAI's own endpoints tolerate the payload, so the bug only surfaces on strict upstreams like Anthropic-backed gateways.

The plugin registers an llm_request middleware that rewrites the provider request just before the HTTP call:

  • Responses API (input array): drops empty text blocks and message items left with no content.
  • Chat completions (messages array): coerces empty assistant content to None on tool-call turns, the #31583 fix, for Hermes builds that predate 725c7ba534.

Persisted history is never touched; only the wire payload changes. Middleware is fail-open: if the plugin raises, Hermes logs it and sends the original request.

Install

hermes plugins install guygrigsby/hermes-empty-text-guard
hermes plugins enable empty-text-guard

Update with hermes plugins update empty-text-guard.

Uninstall

hermes plugins disable empty-text-guard
hermes plugins remove empty-text-guard

Tests

python3 -m pytest tests/

When to remove it

Upgrade Hermes past 725c7ba534; the fix there covers the chat-completions transport. If the Responses API gap gets patched upstream too, this plugin has nothing left to do.

Contributors

guygrigsby

Issues