Skip to content

feat(openai): support Responses text verbosity - #29574

Open
JiehoonKwak wants to merge 1 commit into
NousResearch:mainfrom
JiehoonKwak:codex/text-verbosity
Open

feat(openai): support Responses text verbosity#29574
JiehoonKwak wants to merge 1 commit into
NousResearch:mainfrom
JiehoonKwak:codex/text-verbosity

Conversation

@JiehoonKwak

@JiehoonKwak JiehoonKwak commented May 21, 2026

Copy link
Copy Markdown

Summary

  • add agent.text_verbosity config parsing for OpenAI Responses output verbosity
  • automatically inject text.verbosity only for GPT-5 models on Codex OAuth or the exact api.openai.com host; xAI, GitHub Models, and arbitrary custom endpoints fail closed
  • merge configured verbosity into request_overrides.text without dropping text.format or replacing an explicit verbosity override
  • validate text in the Responses preflight, document the option, and invalidate cached gateway agents when it changes

Context

Closes #20203.

#20258 also proposes this feature. This PR keeps the implementation at the existing agent-to-Responses transport boundary and does not add a generic capability framework or custom-proxy opt-in.

Tests

  • scripts/run_tests.sh tests/agent/transports/test_codex_transport.py tests/run_agent/test_run_agent.py tests/gateway/test_agent_cache.py (581 passed)
  • ruff check on all changed Python files
  • python -m compileall on all changed Python files
  • git diff --check

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/openai OpenAI / Codex Responses API comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery labels May 21, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused config-to-transport implementation; current main still rejects top-level text, so the feature request remains valid.

Problems

  • agent/transports/codex.py:152 sets configured text.verbosity before request_overrides is merged. The existing kwargs.update(request_overrides) immediately afterward replaces the entire text object, dropping verbosity when an override supplies text.format or another text field. Merge the dictionaries after applying overrides instead.
  • agent/transports/codex.py:147 excludes only GitHub and xAI. Current named custom-provider resolution can select codex_responses (hermes_cli/runtime_provider.py:695-697), so this does not establish that the route accepts OpenAI's text field. The issue specifically asks not to send it to unsupported providers.

Suggested changes

  • Merge configured verbosity into an existing request_overrides.text dict and test preservation of text.format.
  • Gate injection on an explicit supported OpenAI GPT/Responses capability, with a custom non-OpenAI Responses regression test.

Automated hermes-sweeper review.

Comment thread agent/transports/codex.py Outdated

verbosity = parse_text_verbosity(text_verbosity)
if verbosity:
kwargs["text"] = {"verbosity": verbosity}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request_overrides is merged immediately after this block, so an override containing text replaces this entire dict and silently drops configured verbosity. Apply overrides first, then copy/merge the existing text dict so fields such as text.format survive alongside text.verbosity.

Comment thread agent/transports/codex.py Outdated
@@ -142,6 +143,14 @@ def build_kwargs(
elif not is_github_responses and not is_xai_responses:
kwargs["include"] = []

text_verbosity = params.get("text_verbosity")
if text_verbosity and not is_github_responses and not is_xai_responses:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an exclusion check rather than a capability check. Named custom providers can opt into codex_responses on current main (hermes_cli/runtime_provider.py:695-697), so non-xAI/non-GitHub routes can still receive this OpenAI-only field. Please gate on a known supported OpenAI GPT/Responses route or capability.

@JiehoonKwak
JiehoonKwak force-pushed the codex/text-verbosity branch from 5d92a18 to 44d3b1b Compare July 13, 2026 10:01
@JiehoonKwak

Copy link
Copy Markdown
Author

Updated the PR on current main in 44d3b1b1b and addressed both review points:

  • request_overrides is applied first, then configured verbosity is nested into text with setdefault. This preserves text.format, keeps an explicit override authoritative, and does not mutate the caller's override dict.
  • Capability is resolved at the agent request boundary from the resolved model and endpoint: GPT-5 family plus either Codex OAuth or exact hostname api.openai.com. The transport receives only that boolean. GPT-5 on a custom endpoint, xAI, GitHub Models, and non-GPT-5 models all fail closed.

The regression coverage includes the nested merge, explicit override precedence, the endpoint/model matrix, and an AIAgent configured as a custom codex_responses provider. Focused suite: 581 passed; changed-file Ruff, compileall, and git diff --check also pass.

@teknium1 teknium1 added sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 13, 2026
@JiehoonKwak
JiehoonKwak force-pushed the codex/text-verbosity branch from 44d3b1b to f0be1ca Compare July 14, 2026 03:56
@JiehoonKwak
JiehoonKwak force-pushed the codex/text-verbosity branch from f0be1ca to 6ef18da Compare July 14, 2026 22:01
@JiehoonKwak
JiehoonKwak force-pushed the codex/text-verbosity branch from 6ef18da to 0dda89f Compare July 17, 2026 11:05
@JiehoonKwak
JiehoonKwak force-pushed the codex/text-verbosity branch from 0dda89f to 72113bf Compare July 19, 2026 05:18
Expose agent.text_verbosity for GPT-5 Responses targets while preserving provider defaults elsewhere. Resolve support at the request boundary so Codex OAuth and the exact api.openai.com host opt in, while custom, xAI, and GitHub targets fail closed.

Merge configured verbosity into request_overrides.text without replacing text.format or an explicit verbosity override. Validate the adapter payload and invalidate gateway cached agents when the config changes.

Context:
- Addresses the nested-merge and provider-capability review on PR NousResearch#29574.
- Keeps provider support narrow instead of adding a generic capability framework or proxy opt-in.
- The local runtime patch remains necessary until an upstream target includes the eventual merge.
@JiehoonKwak
JiehoonKwak force-pushed the codex/text-verbosity branch from 72113bf to 60920fc Compare July 19, 2026 21:25
obuchowski added a commit to obuchowski/hermes-agent that referenced this pull request Jul 22, 2026
Temporary local compatibility patch for OpenAI Responses text.verbosity.

Upstream tracking:
- Issue: NousResearch#20203
- Preferred candidate: NousResearch#63543
- Competing candidate: NousResearch#29574

Remove this commit after upstream merges a first-class agent output/text verbosity setting, then replace HERMES_OPENAI_VERBOSITY=low with the merged YAML config key.
JiehoonKwak added a commit to JiehoonKwak/hermes-agent that referenced this pull request Jul 31, 2026
Expose agent.text_verbosity for GPT-5 Responses targets while preserving provider defaults elsewhere. Resolve support at the request boundary so Codex OAuth and the exact api.openai.com host opt in, while custom, xAI, and GitHub targets fail closed.

Merge configured verbosity into request_overrides.text without replacing text.format or an explicit verbosity override. Validate the adapter payload and invalidate gateway cached agents when the config changes.

Context:
- Addresses the nested-merge and provider-capability review on PR NousResearch#29574.
- Keeps provider support narrow instead of adding a generic capability framework or proxy opt-in.
- The local runtime patch remains necessary until an upstream target includes the eventual merge.
JiehoonKwak added a commit to JiehoonKwak/hermes-agent that referenced this pull request Jul 31, 2026
Expose agent.text_verbosity for GPT-5 Responses targets while preserving provider defaults elsewhere. Resolve support at the request boundary so Codex OAuth and the exact api.openai.com host opt in, while custom, xAI, and GitHub targets fail closed.

Merge configured verbosity into request_overrides.text without replacing text.format or an explicit verbosity override. Validate the adapter payload and invalidate gateway cached agents when the config changes.

Context:
- Addresses the nested-merge and provider-capability review on PR NousResearch#29574.
- Keeps provider support narrow instead of adding a generic capability framework or proxy opt-in.
- The local runtime patch remains necessary until an upstream target includes the eventual merge.
qxxaa added a commit to qxxaa/hermes-agent that referenced this pull request Aug 14, 2026
…th control

Closes NousResearch#20203. Based on NousResearch#29574's init_agent() loading approach, with
added GPT-5+ model guard (vendor prefix handling) and safe dict merge
(preserves text.format from request_overrides).

Add agent.text_verbosity config key that injects text.verbosity into
OpenAI Responses API payloads for GPT-5+ models. Valid values: low,
medium, high, or empty string (default, no injection).

- Config loaded inside init_agent() from _agent_section
- Gateway hot-reload via cache-bust tuple
- GPT-5+ model guard with vendor prefix stripping
- Safe merge into existing text dict (preserves text.format)
- Preflight whitelist + pass-through in codex_responses_adapter
- 22 tests (19 transport + 3 preflight adapter)
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 comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have provider/openai OpenAI / Codex Responses API sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add configuration support for OpenAI Responses API text verbosity

3 participants