Skip to content

feat(env): manage env state centrally - #73

Open
jx-qiu wants to merge 25 commits into
RLinf:mainfrom
jx-qiu:feature/env-state-refactor
Open

feat(env): manage env state centrally#73
jx-qiu wants to merge 25 commits into
RLinf:mainfrom
jx-qiu:feature/env-state-refactor

Conversation

@jx-qiu

@jx-qiu jx-qiu commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

This pull request updates the documentation to reflect recent changes in how environment state, tool registration, and artifact management are handled in the codebase. The main focus is on the transition from manual tool registration and file management to an automated, EnvState-centric workflow. Documentation in both English and Chinese is revised for clarity and accuracy, and references to legacy interfaces and files are replaced with the new conventions.

Major documentation and interface updates:

General workflow and tool registration:

  • Updated instructions for adding scripted primitives: tool registration is now automatic based on TOOLS_SPEC and @readonly. No need to manually call add_tools anymore! [1] [2] [3] [4]
  • Clarified that tool return values should be small dicts, and large observations must be saved via EnvState.save; images and geometry are exposed through dedicated tools, not raw paths. [1] [2]

State management and artifact handling:

  • Revised descriptions of per-step state dumps: now handled by EnvState.record_step and EnvState.save, with explicit artifact tracking. Artifacts are referenced by logical base names, not manual paths. [1] [2]
  • Updated conventions to emphasize that all environment observations are owned and managed by EnvState, and that callers must not construct storage paths directly. [1] [2]

Tool interface and naming consistency:

  • Standardized on view_env_state instead of view_driver_state throughout the documentation and interface references. [1] [2] [3] [4] [5] [6]

Quickstart and calibration documentation:

  • Updated quickstart guides to explain the new artifact naming, storage, and retrieval conventions, including the use of view_env_state(step=-1) for inspecting the latest state. [1] [2]
  • Improved calibration guide instructions to use view_env_state({"step": 0}) for initial state and clarified that direct file or BDDL access is not supported. [1] [2]

Code cleanup:

  • Removed the unused video_path parameter from get_toolkit in robots/libero/__init__.py.

Copilot AI lite review requested due to automatic review settings August 6, 2026 08:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes environment step recording and artifact management around a new EnvState/StepRecord model, and updates the LIBERO runtime + documentation to use the new view_env_state workflow instead of legacy file-path/state-dump conventions.

Changes:

  • Introduces EnvState (manifest + artifact IO) and @updatestate to automate post-tool state capture/publishing.
  • Updates LIBERO tools/toolkit and dashboard to consume step records/artifacts (and standardizes on view_env_state naming).
  • Refreshes English/Chinese docs and guides to match the new artifact naming + retrieval contract.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/codex_proxy/litellm_callbacks.py Updates doc/example namespace map to use view_env_state.
rpent/utils/sam3_client.py Changes SAM3 client API to accept image bytes/arrays instead of paths.
rpent/tools/toolkit.py Adds @updatestate marker and state-capture/publish flow for stateful tools.
rpent/tools/state.py Adds new EnvState + StepRecord implementation (manifest + artifact storage).
rpent/tools/common.py Adds shared backprojection/centroid helpers used by tools.
rpent/planner/api_loop.py Updates planner helper text to reference view_env_state.
rpent/dashboard/state.py Adds StepRecordEvent handling and loads frames/action videos via EnvState.
rpent/dashboard/server.py Switches video endpoints to return in-memory bytes responses.
rpent/dashboard/events.py Introduces StepRecordEvent for step publication to dashboard.
rpent/context/prompts/prompt.py Updates prompt guidance from view_driver_state to view_env_state.
rpent/cli/main.py Removes legacy video_path wiring into toolkit creation.
rpent/cli/dashboard.py Removes legacy video_path wiring into toolkit creation (dashboard mode).
robots/libero/tools.py Migrates LIBERO tool implementations to EnvState artifacts + view_env_state.
robots/libero/toolkit.py Registers tools via TOOLS_SPEC + @updatestate; uses EnvState for recording.
robots/libero/prompts/user.py Updates user prompt to instruct view_env_state and embedded images.
robots/libero/prompts/system.py Rewrites system guidance around EnvState artifacts + view_env_state.
robots/libero/guides/strict_hybrid_guide.md Replaces legacy file-path protocol with EnvState-centric runtime contract.
robots/libero/guides/pro_hybrid_guide.md Updates PRO guide to the new view_env_state/EnvState workflow.
robots/libero/guides/env_calibration.md Updates calibration doc to use structured tools + view_env_state access.
robots/libero/init.py Removes video_path parameter from get_toolkit.
docs/source-zh/rst_source/usage/libero.rst Chinese docs: rename view_driver_stateview_env_state + defaults.
docs/source-zh/rst_source/quickstart.rst Chinese quickstart: clarifies states.json is EnvState manifest; avoid parsing.
docs/source-zh/rst_source/development/interfaces.rst Chinese dev docs: references view_env_state.
docs/source-zh/rst_source/development/add_robot.rst Chinese dev docs: documents EnvState.record_step/save conventions.
docs/source-zh/rst_source/development/add_primitive.rst Chinese dev docs: documents @updatestate + automatic tool registration.
docs/source-en/rst_source/usage/libero.rst English docs: rename view_driver_stateview_env_state + defaults.
docs/source-en/rst_source/quickstart.rst English quickstart: clarifies states.json is internal EnvState manifest.
docs/source-en/rst_source/development/interfaces.rst English dev docs: references view_env_state.
docs/source-en/rst_source/development/add_robot.rst English dev docs: documents EnvState.record_step/save conventions.
docs/source-en/rst_source/development/add_primitive.rst English dev docs: documents @updatestate + automatic tool registration.
Suppressed comments (1)

robots/libero/tools.py:793

  • write_recipe_from_states always returns recipe_name even if EnvState.save(...) fails (it returns None on error). That can lead callers to believe a recipe was exported when it wasn't. Check the save result and raise (or otherwise report) on failure.
    state.save(
        recipe_name,
        [command for _, command in command_events],
        step=None,
    )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread robots/libero/tools.py Outdated
Comment thread rpent/dashboard/server.py Outdated
@jx-qiu
jx-qiu requested review from qurakchin and wilburx813 August 6, 2026 08:20
@jx-qiu jx-qiu changed the title feature: manage env state centrally feat(env): manage env state centrally Aug 6, 2026
Comment thread rpent/tools/toolkit.py
Comment thread robots/libero/tools.py
except Exception as e:
logger.warning("wrist high-res dump failed: %s", e)

for old_step in range(max(0, int(step_idx) - 4)):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we keep the previous retention policy for high-res artifacts here? Without cleanup, the two 1024×1024 world maps alone add 12 MB per step, which may become significant for long or batched rollouts.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For libero, each step produces ~17 MiB of on-disk artifacts. I will see if there are opportunities for better lossless compression.

Comment thread rpent/tools/toolkit.py Outdated
Comment thread rpent/tools/state.py
Comment thread rpent/tools/state.py Outdated
Comment on lines +161 to +163
for path in self._output_dir.iterdir():
if path.is_file() and path.suffix.lower() != ".log":
path.unlink()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reset every file expect log seems unsafe, the user may accidentally pass a important directory

Comment thread rpent/tools/state.py
record.artifacts.add(name)
else:
self._run_artifacts.add(name)
self._write_manifest()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we write manifest once per step instead of rewriting it after every artifact save?

@wilburx813

Copy link
Copy Markdown
Collaborator

btw, seems rpent-memory needs update too.

jx-qiu added 5 commits August 7, 2026 08:49
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
@jx-qiu

jx-qiu commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

btw, seems rpent-memory needs update too.

Do you mean the markdown files under resources/libero/memory?

jx-qiu added 4 commits August 7, 2026 09:01
…_FRAME_ARTIFACTS

Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
@wilburx813

Copy link
Copy Markdown
Collaborator

btw, seems rpent-memory needs update too.

Do you mean the markdown files under resources/libero/memory?

Yes, some files under resources/libero/memory still reference something like view_driver_state

jx-qiu added 6 commits August 7, 2026 09:08
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
jx-qiu added 6 commits August 7, 2026 09:10
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
…runcated

Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
@jx-qiu
jx-qiu force-pushed the feature/env-state-refactor branch from c807f04 to ef9d576 Compare August 7, 2026 09:26
jx-qiu added 4 commits August 7, 2026 09:40
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
Signed-off-by: Jiaxing Qiu <jx.qiu@outlook.com>
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.

4 participants