remove redundant msg normalization + align env_response api#1027
Merged
mikasenghaas merged 13 commits intomainfrom Mar 19, 2026
Merged
remove redundant msg normalization + align env_response api#1027mikasenghaas merged 13 commits intomainfrom
env_response api#1027mikasenghaas merged 13 commits intomainfrom
Conversation
eligotts
reviewed
Mar 17, 2026
willccbb
approved these changes
Mar 17, 2026
Member
willccbb
left a comment
There was a problem hiding this comment.
Approving in advance, but let's auto-convert or hard-fail if get_prompt_messages is overridden to return dicts. would prefer auto-convert i think, writing dicts is often the more ergonomic way to do it, but fine either way (could surface a helper fn + mention in docstring?).
env_response api
This reverts commit 8b26a4250a581954a3edbb12268deb4b0ebeeed9.
3b62a82 to
162b0ac
Compare
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.
eligotts
approved these changes
Mar 18, 2026
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.

Description
Reduces calls to
normalize_messagesto minimal set:init_state(this is safe, because not on hot path)get_prompt_messagesorenv_response) we usemaybe_normalize_messageswhich emits a warning before normalizing the message to nudge users towards using the types directly to avoid potential performance bottlenecksenv_responsereturn type fromMessages | strto justMessagesto be consistent with the rest of the API (e.g.get_model_response,rollout, etc just operate onMessagesandstr -> vf.Messagesconversion is an example of (undesired) conversion to custom types) and thus be handled the same way as list of dictsType of Change
Testing
uv run pytestlocally.Checklist
Additional Notes
Note
Medium Risk
Tightens the core
MultiTurnEnv/Environment.get_model_responseAPIs to requireMessagesand introduces conditional normalization, which could break downstream custom envs/providers that still return raw dicts/strings or pass string prompts.Overview
Standardizes environment and model prompting to operate on typed
vf.Messagesonly:env_response()andget_model_response()now take/returnMessages(no morestr), and built-in envs (alphabet_sort,doublecheck,sentence_repeater,GymEnv) were updated to emitvf.UserMessageobjects instead of raw dicts.To cut hot-path Pydantic overhead,
MultiTurnEnvnow usesmaybe_normalize_messages()(new helper) to only normalize when needed and logs a warning once when callers still return raw dicts/strings; supportinglog_once/warning_onceutilities were added, andparse_response_message()now constructsAssistantMessagedirectly instead of round-tripping throughmodel_validate.Written by Cursor Bugbot for commit cd87b2c. This will update automatically on new commits. Configure here.