fix(openai): bound native shell output#507
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 109b6ca105
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| elif ( | ||
| isinstance(requested_limit, bool) | ||
| or not isinstance(requested_limit, int) | ||
| or requested_limit < MIN_SHELL_OUTPUT_LENGTH |
There was a problem hiding this comment.
Honor valid small shell output limits
When OpenAI supplies a positive max_output_length below 28 (for example, 10), this rejects the entire shell call instead of executing it. The pinned OpenAI Action contract defines this value simply as the maximum characters returned per command and imposes no marker-sized minimum, so these are valid provider-generated limits; moreover, the resulting error text itself exceeds the requested limit. Accept small nonnegative limits and truncate the marker as necessary rather than failing the command.
AGENTS.md reference: AGENTS.md:L134-L135
Useful? React with 👍 / 👎.
Summary
max_output_lengthfor each commandRoot cause
The native OpenAI shell adapter returned
max_output_lengthas metadata but copied the complete command result into display content and structured stdout/stderr. No execution-boundary truncation occurred, so noisy output could exceed the Responses API field limit and terminate the rollout before grading.Validation
uv run --no-sync pytest -q hud/agents/openai/tools/tests hud/agents/tests/test_provider_native_tools.py hud/agents/tests/test_openai_agent.py hud/agents/tests/test_tool_agent.py(68 passed)Linear: HUD-2204
Note
Medium Risk
Changes agent tool execution and result shaping on a critical path; behavior is well-tested but affects all native OpenAI shell calls.
Overview
OpenAI native shell now honors
max_output_lengthinstead of echoing full command output while only storing the limit as metadata—fixing rollouts that blew past Responses API text limits on noisy commands.Execution parses and validates
max_output_length(integer ≥ minimum, capped at 10 MiB); bad values return an error without running commands. Each command runs viaconn.runwith separate stdout/stderr, then_bound_outputtrims combined length per command using a truncation marker while keeping head/tail. Structuredoutputand MCP text content both use the same bounded streams (one text block per command).Tests cover huge stderr truncation, per-command limits, invalid limits, and default/ceiling effective limits; the fake SSH client now supports stderr.
Reviewed by Cursor Bugbot for commit 109b6ca. Bugbot is set up for automated code reviews on this repo. Configure here.