Allow environments to declare preserved state columns#1054
Open
hubert-marek wants to merge 9 commits intoPrimeIntellect-ai:mainfrom
Open
Allow environments to declare preserved state columns#1054hubert-marek wants to merge 9 commits intoPrimeIntellect-ai:mainfrom
hubert-marek wants to merge 9 commits intoPrimeIntellect-ai:mainfrom
Conversation
Adds an optional `state_columns` parameter to Environment.__init__ so environments can declare which custom state fields should survive serialization to RolloutOutput. This enables deferred group scoring to access environment-specific fields (e.g. eval results) without hardcoding field names in the orchestrator. Defaults to empty list, fully backwards compatible. Made-with: Cursor
13 tasks
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
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.

Two fixes for deferred group scoring compatibility.
Description
1. Allow environments to declare preserved state columns
When environments write custom fields into
vf.Stateduringpost_rollout(e.g.state["eval_score"]), those fields are dropped duringstate_to_output()serialization unless explicitly requested viastate_columns. Currently, the only way to preserve them is for the orchestrator to hardcode environment-specific field names inREQUIRED_STATE_COLUMNS, which couples the orchestrator to individual environment implementations.This adds an optional
state_columnsparameter toEnvironment.__init__so environments can declare their own required state columns at construction time:The orchestrator (e.g.
prime-rl) can then readenv.state_columnsand include them automatically, without needing to know the field names itself.Defaults to
[].2. Handle serialized messages in tool monitor rubrics
ToolMonitorRubricused attribute access (msg.role) which fails when completion messages are serialized to plain dicts during deferred group scoring. Addednormalize_messages()to convert any serialized dicts back toMessageobjects before processing, using the existingmessage_utilshelper.Fixes:
Type of Change
Testing
uv run pytestlocally.Checklist
Additional Notes
Companion PR: PrimeIntellect-ai/prime-rl#2057
Note
Low Risk
Low risk, backwards-compatible additions:
state_columnsis optional and defaults to empty, and message normalization only broadens accepted input shapes for tool-monitor metrics.Overview
Adds an optional
state_columnsparameter toEnvironmentconstruction and stores it onenv.state_columns, so environments can declare which JSON-serializableStatefields should be preserved intoRolloutOutputwithout orchestrator hardcoding.Fixes deferred/group scoring compatibility for
ToolMonitorRubricby normalizingcompletionmessages (e.g., serialized dicts) before counting tool calls. Documentation and API reference are updated to reflect both changes.Written by Cursor Bugbot for commit bd016db. This will update automatically on new commits. Configure here.