hermes - 💡(How to fix) Fix Codex Responses adapter can send invalid function_call.name from replayed history

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

BadRequestError: HTTP 400 Invalid 'input[222].name': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'

Fix Action

Fix / Workaround

A local patch using this approach compiled cleanly and preserved normal names like browser_click and web_search unchanged, while converting examples like some.name with spaces to somenamewithspaces.

Code Example

BadRequestError: HTTP 400
Invalid 'input[222].name': string does not match pattern.
Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'

---

^[a-zA-Z0-9_-]+$

---

Invalid 'input[222].name': string does not match pattern

---

_RESPONSIVE_NAME_RE = re.compile(r"[^A-Za-z0-9_-]")


def _sanitize_responses_name(name: str) -> str:
    return _RESPONSIVE_NAME_RE.sub("", name)
RAW_BUFFERClick to expand / collapse

Bug Description

Long-running Hermes sessions using the openai-codex / Codex Responses adapter can fail with an HTTP 400 from the backend when replayed conversation history contains a function_call.name that does not match the stricter Responses API name pattern.

Observed error:

BadRequestError: HTTP 400
Invalid 'input[222].name': string does not match pattern.
Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'

This blocks GPT-5.5 / Codex-backed Hermes sessions even though the configured tool schemas themselves are valid.

Why this happens

The adapter validates that function_call.name exists, but it only applies .strip() before sending replayed conversation items to the Responses API.

Relevant paths in agent/codex_responses_adapter.py:

  • _chat_messages_to_responses_input(...): emits replayed assistant tool_calls as Responses function_call items
  • _preflight_codex_input_items(...): normalizes pre-built Responses input items
  • _preflight_codex_api_kwargs(...): normalizes Responses tools
  • _responses_tools(...): converts chat-completions tool schemas

The Responses backend requires every emitted name to match:

^[a-zA-Z0-9_-]+$

A name with spaces, dots, or other punctuation in replayed history can therefore trigger a backend 400, even if all current tool definitions are valid.

Expected Behavior

Hermes should sanitize or reject invalid Responses function/tool names before sending the request, so the user gets either:

  1. a valid request, or
  2. a clear local validation error identifying the offending item.

Actual Behavior

The invalid name is sent through to the Codex Responses backend, which rejects the entire request with a 400 such as:

Invalid 'input[222].name': string does not match pattern

Suggested Fix

Add a small sanitizer for Responses names and apply it wherever names are emitted into Responses API payloads:

_RESPONSIVE_NAME_RE = re.compile(r"[^A-Za-z0-9_-]")


def _sanitize_responses_name(name: str) -> str:
    return _RESPONSIVE_NAME_RE.sub("", name)

Then use it for:

  • function call names from chat-history tool calls
  • function call names in preflighted Responses input items
  • tool definition names in Responses tool schemas

A local patch using this approach compiled cleanly and preserved normal names like browser_click and web_search unchanged, while converting examples like some.name with spaces to somenamewithspaces.

Environment

  • Hermes repo: NousResearch/hermes-agent
  • Provider route: openai-codex
  • Transport: Codex Responses adapter
  • Model route affected: GPT-5.5 / Codex-backed Responses API
  • OS: Linux

Related

Possibly related to #11411, but this variant is specifically about non-empty names with invalid characters in replayed Responses input[n].name items.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix Codex Responses adapter can send invalid function_call.name from replayed history