Skip to content

fix(carla_env): keep reset scenario_config overrides to one episode - #1742

Open
Aafimalek wants to merge 1 commit into
openenv:mainfrom
Aafimalek:fix/carla-scenario-config-reset
Open

Aafimalek wants to merge 1 commit into
openenv:mainfrom
Aafimalek:fix/carla-scenario-config-reset

Conversation

@Aafimalek

@Aafimalek Aafimalek commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

reset(scenario_config={...}) wrote the overrides into the shared scenario config, so they persisted into later plain resets. After reset(scenario_config={"max_steps": 2}) and then reset(), scenario.config.max_steps was still 2.

The env now keeps a _base_scenario, and each reset() deep-copies it and applies the overrides to the copy. Overrides from the constructor and scenario switches persist as before. Scenarios hold only their config and small per-episode fields, no simulator handles, so the copy is cheap.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • New environment
  • Refactoring

Alignment Checklist

Before submitting, verify:

  • I have read .claude/docs/PRINCIPLES.md and this PR aligns with our principles
  • I have checked .claude/docs/INVARIANTS.md and no invariants are violated
  • I have run /pre-submit-pr (or bash .claude/hooks/lint.sh and tests) and addressed all issues

RFC Status

  • Not required (bug fix, docs, minor refactoring)
  • RFC exists: #___
  • RFC needed (will create before merge)

Test Plan

  • New test_reset_scenario_config_applies_to_one_episode in tests/envs/test_carla_environment.py (mock mode). On main: 1 failed, 62 passed. With the fix: 63 passed (WSL, Python 3.12).
  • bash .claude/hooks/lint.sh passes.
  • Not run: the full test suite, and real CARLA mode.

Claude Code Review

Alignment review by Opus 5.5, in the format of .claude/skills/alignment-review/SKILL.md.

Automated Checks

  • Lint: PASS, bash .claude/hooks/lint.sh
  • Debug code: CLEAN

Tier 1: Fixes Required

None.

Tier 2: Alignment Discussion

None. The reset() docstring now says overrides apply to that episode only.


Note

Low Risk
Localized reset/scenario lifecycle change in the CARLA mock environment with a regression test; no auth or infra impact.

Overview
Fixes a bug where reset(scenario_config={...}) mutated the shared scenario object, so overrides such as max_steps stuck around on later plain reset() calls.

CarlaEnvironment now keeps a _base_scenario (from the constructor or when the scenario name changes) and deep-copies it on every reset(), applying scenario_config only to that episode’s copy. The reset() docstring now states that overrides are per-episode.

Adds test_reset_scenario_config_applies_to_one_episode to assert overrides apply for one reset and revert afterward.

Reviewed by Cursor Bugbot for commit c8d4fcf. Bugbot is set up for automated code reviews on this repo. Configure here.

reset(scenario_config=...) wrote into the shared scenario config, so the
overrides persisted into later plain resets. Apply them to a copy of the
base scenario on every reset.

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