Repository navigation
DRAFT: feat(terminal): proactive literal-arg warning in tool description - #3619
Closed
juanmichelini wants to merge 2 commits into
Closed
juanmichelini wants to merge 2 commits into
juanmichelini wants to merge 2 commits into
Conversation
…l description The SDK-5 guard (#3582) catches Python/JSON literals `command` arguments *after* the model has already emitted them, and replies with an in-band hint. That fixed Critic 1 Acceptance (20% → 100%) on the Nemotron 550B SWE-Bench Verified run `27224350936`, but trajectory analysis showed the three expensive instances each hit the guard 31–61 times. The hint is in-band, so it lands as just another turn's-worth of text in a 200-turn conversation — it doesn't change the model's prior. This PR moves the guidance *upstream* into the tool description itself, so the warning is visible on every turn before the model composes a command. Same wording on both Unix and Windows variants. Numbers from `27224350936`: - 3 expensive instances: 31 + 32 + 61 = 124 SDK-5 hits total - At ~$0.03/turn (Nemotron, no caching, ~150-turn context): ~$3.70 of pure waste across the 5-instance batch - Expected SDK-7 + SDK-5 combined behaviour: model sees warning up-front, drops literal-emit attempts from ~40 → ~2 per instance. Test coverage: `tests/tools/terminal/test_descriptions.py` pins - presence of the warning text on both variants - mention of both recovery paths (`file_editor`, heredoc) - ordering — warning must appear before `### Command Execution` - 3 KB budget per description so it cannot silently bloat Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
Contributor
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Contributor
Collaborator
Author
|
Tested and costs got higher, closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
The SDK-5 guard (#3582) rejects Python/JSON literals passed to the
terminaltool'scommandfield after the model has already emitted them. That fixed Critic 1 Acceptance (20% → 100%) on Nemotron 550B SWE-Bench Verified — but didn't reduce per-instance cost. This PR moves the guidance upstream into the tool description so the model sees it on every turn, before it ever composes a malformed command.Why this is needed (data)
Trajectory analysis of the SDK-5 follow-up run
27224350936:scikit-learn-13439-likedjango-12155-likeThe three "expensive" instances each triggered SDK-5's guard 31–61 times. The agent recovered every time (which is why acceptance is 100%), but it never learned — Nemotron emitted the same malformed pattern 5-10 turns later, over and over. The hint is in-band, so it lands as one paragraph in a 200-turn conversation. Attention weight on a single retrospective message ≈ zero.
At ~$0.03/turn (no prompt caching), the 124 wasted recovery turns across the three expensive instances cost roughly $3.70 out of the $19.23 batch — about 20% of total spend.
What
Add a
_LITERAL_ARG_GUIDANCEblock at the top of bothUNIX_TOOL_DESCRIPTIONandWINDOWS_TOOL_DESCRIPTION. It:commandmust be a shell command, not a Python/JSON literal.file_editor+ script, or inline heredoc).Total added size: ~700 bytes per description. Test pins this to
< 3 KB totalso future additions can't silently bloat what the model re-pays for on every uncached turn.Tests
tests/tools/terminal/test_descriptions.py— 4 tests:Python,JSON,shell command) present on both Unix and Windows.file_editor, heredoc) mentioned.### Command Execution. Attention research shows position matters in long contexts; this prevents accidental re-ordering from burying the warning.Risk
Stacks with
file_editorview dedupe — the other big waste bucket in run27224350936(schema.pyviewed 19×,_iterative.pyviewed 34×).Verify locally
uv run pytest tests/tools/terminal/test_descriptions.py -v # 4 passedTo see the rendered text the model will receive:
uv run python -c "from openhands.tools.terminal.descriptions import UNIX_TOOL_DESCRIPTION; print(UNIX_TOOL_DESCRIPTION)"This PR was created by an AI agent (OpenHands) on behalf of the user investigating cost on the Nemotron 550B SWE-Bench Verified eval. Companion analysis: same run cost $19.23 across 5 resolved instances; cheap instances (no SDK-5 hits) cost $0.11–$0.20 each, expensive instances (31–61 hits each) cost $5.67–$6.84.
@juanmichelini can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22-slimgolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:d8b470f-pythonRun
All tags pushed for this build
About Multi-Architecture Support
d8b470f-python) is a multi-arch manifest supporting both amd64 and arm64d8b470f-python-amd64) are also available if needed