Skip to content

fix(openenv): keep a raw reply as text for a string action field - #3368

Open
xinxuxin wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
xinxuxin:fix/openenv-string-field-action
Open

xinxuxin wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
xinxuxin:fix/openenv-string-field-action

Conversation

@xinxuxin

@xinxuxin xinxuxin commented Dec 5, 2026 •

Copy link
Copy Markdown

Problem

parse_action (verifiers/v1/tasksets/openenv/taskset.py) says it takes "JSON, fenced JSON, or — for a single-required-field schema such as Wordle's — the raw field value". For a non-object reply, it runs json.loads first and wraps the result in the required field. When that field is a string, as TextArena's message: str is, a reply that happens to be valid JSON is sent with the wrong type. OpenEnv validates the action before stepping, so the step is rejected with Server error: Invalid message (code: VALIDATION_ERROR) and the rollout errors.

Minimal repro on main:

from verifiers.v1.tasksets.openenv.taskset import parse_action
schema = {"properties": {"message": {"type": "string"}}, "required": ["message"]}
parse_action("[7]", schema)    # main: {'message': [7]}      branch: {'message': '[7]'}
parse_action("12345", schema)  # main: {'message': 12345}    branch: {'message': '12345'}
parse_action("true", schema)   # main: {'message': True}     branch: {'message': 'true'}

End to end against a local OpenEnv 0.4.1 server:

  • A correct bracketed guess in TextArena GuessTheNumber-v0 is rejected on main. On this branch it is accepted and wins with reward 1.0.
  • For a code: str action, the bare reply 12345 errors, while {"code": "12345"} scores 1.0.

Fix

  • In parse_action, when the single required field is a plain string (its schema has "type": "string" and only descriptive keys: title, description, default, examples) and the decoded reply is not a str, the fence-stripped reply text is sent instead.
  • These behave as before:
    • JSON object replies;
    • non-string fields, so an integer field still gets 7;
    • JSON-quoted strings;
    • boolean property schemas ({"value": true});
    • constrained string fields (format, pattern, length limits, enum, ...), where a decoded number can be the valid input: timedelta accepts 42, and a coerce_numbers_to_str field with a pattern accepts 1e2 as "100.0".
  • A new tests/unit/tasksets/test_openenv.py (mirroring verifiers/v1/tasksets/openenv/) holds one parametrized test of parse_action. It needs neither the openenv extra nor network.

Not changed, and the same as on main:

  • string fields declared through anyOf, a type list or $ref (Optional[str], string enums);
  • a one-line fence, which still becomes an empty string.

A constraint the schema doesn't show can still reject the raw text. Example: a model-level str_max_length with coerce_numbers_to_str, where main sent 1e+002 as 100.0 and the server coerced it to "100.0". Sending {"field": ...} as an object always takes the decoded value.

One behaviour change beyond the fix: for MCP envs, CallToolAction has one required string field, tool_name. So a bare reply like 123 now reaches the env as an unknown tool, where before it failed validation.

Verification

  • test_parse_action: the four plain-string cases fail on main ({'message': [7]} != {'message': '[7]'}, …) and pass here. The seven unchanged-behaviour cases pass on both.
  • uv run pytest tests/unit -n auto (Python 3.13): 513 passed, 10 skipped (main: 502 passed, 10 skipped).
  • uv run ruff check, uv run ruff format --check and uv run --python 3.13 ty check verifiers are clean.
  • Not run: the integration grid (needs PRIME_API_KEY).

I used an AI coding assistant (Claude Code) to find, fix and test this, including the local OpenEnv server runs; the checks above were run on my machine.

🤖 Generated with Claude Code

Note

Fix parse_action to keep raw reply text for unconstrained string fields

  • In parse_action in taskset.py, when the action schema has exactly one required field and that field is a plain string schema (only type, title, description, default, examples keys), a JSON-decodable non-string reply is now returned as its stripped text instead of the decoded JSON value
  • Adds a module-level set of non-constraining schema keys used to detect plain string fields
  • Adds parameterized tests in test_openenv.py covering plain strings, fenced replies, JSON strings and objects, numeric replies, and boolean field schemas
  • Behavioral Change: replies like "123" for an unconstrained string field now produce {"message": "123"} instead of {"message": 123}; other schema shapes and parsed values are unchanged

Macroscope summarized b182689.

parse_action decoded a non-object reply as JSON before wrapping it in the
single required field, so a reply like 12345, true, null or 1.5 for a field
declared "type": "string" was sent as a number, bool or null, and OpenEnv
rejected the step. For a string field it now sends the reply text as written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant