Skip to content

Add reset schema publication to /schema endpoint - #1270

Merged
burtenshaw merged 9 commits into
openenv:mainfrom
scosman:scosman/reset_schema
Oct 26, 2026
Merged

burtenshaw merged 9 commits into
openenv:mainfrom
scosman:scosman/reset_schema

Conversation

@scosman

@scosman scosman commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

There's no way for a client to see the reset() schema, while action/observation/state all expose their scheme via /schema. By also exposing reset schema following existing conventions, clients can build much nicer UIs (see example screenshot below), and agents know what to send.

Fixes: #1215

This PR adds a reset_cls parameter to the HTTP server and app factories, so an environment can declare its reset parameters as a ResetRequest subclass. /schema publishes that schema under a new reset key, following the existing state_cls/action_cls/observation_cls pattern. The schema is a hint only: reset requests are not validated against it.

Type of Change

  • New feature
  • Documentation

Alignment Checklist

  • 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

Changes

  • types.py: SchemaResponse.reset: Optional[Dict[str, Any]] = None.
  • http_server.py: reset_cls: Type[ResetRequest] = ResetRequest as the last kwarg on HTTPEnvServer.__init__, create_app, create_fastapi_app, threaded like state_cls and stored as HTTPEnvServer.reset_cls. /schema returns reset=self.reset_cls.model_json_schema(); route description, OpenAPI example and tag text updated.
  • web_interface.py: create_web_interface_app takes and forwards reset_cls.
  • Unchanged: /reset body model, WebSocket reset, signature filtering, openenv validate.
  • Docs: short example in docs/source/guides/task-api.md; CLI template docstring line.

Test Plan

tests/core/test_reset_schema.py (new):

  • declared reset_cls fields published on /schema, with ENABLE_WEB_INTERFACE on and off
  • inherited seed / episode_id present; action/observation/state schemas unaffected
  • POST /reset with a wrong-typed declared field plus an undeclared key returns 200 and both reach reset() (no validation)
  • omitting reset_cls publishes the base ResetRequest schema
PYTHONPATH=src:envs uv run pytest tests/core/test_reset_schema.py -v

Example

Here's an example UI build using reset schema:

656889865-01c0f4bf-e57c-4852-89b2-d2a8b591dabb

Note

Low Risk
Additive API and schema metadata only; reset request handling and validation are unchanged, with tests covering backward-compatible SchemaResponse serialization.

Overview
Environments can now advertise reset parameters on GET /schema the same way action, observation, and state schemas work today. App factories and HTTPEnvServer take an optional keyword-only reset_cls (ResetRequest subclass, default ResetRequest); /schema adds a reset JSON Schema from that class. SchemaResponse gains an optional reset field that is omitted from serialized output when unset, so older three-field payloads stay valid.

This is discovery only: HTTP /reset and WebSocket reset still use the base ResetRequest body and existing reset() signature filtering—nothing is validated against reset_cls. Docs (task-api.md, RFC 002 amendment) describe declaring subclasses (e.g. split / index for task selection); new tests lock in publication, defaults, and non-validation behavior.

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

Environments can now declare their custom reset() parameters as a
ResetRequest subclass and pass it as `reset_cls`. GET /schema publishes
that model's JSON schema under a new `reset` key, alongside action,
observation and state (proposal openenv#1215). It mirrors the state_cls
plumbing from openenv#1174.

- SchemaResponse gains `reset: Optional[Dict[str, Any]]` (default None,
  so it can still describe responses from older servers).
- `reset_cls: Type[ResetRequest] = ResetRequest` is added as the last
  keyword parameter of HTTPEnvServer.__init__, create_app,
  create_fastapi_app and create_web_interface_app, threaded exactly as
  state_cls is, and stored as HTTPEnvServer.reset_cls. Without it,
  /schema publishes the base ResetRequest schema.
- The /schema route description, OpenAPI example, the "Schema" tag and
  the app's feature list mention reset parameters.
- Hint only: /reset and the WebSocket reset message still parse with
  ResetRequest and filter keys against reset()'s signature. reset_cls
  never produces a 422 or an error frame.
- openenv validate is unchanged; it does not require the new key, so
  servers on older openenv releases still pass.
- Task API guide: short example of a ResetRequest subclass passed as
  reset_cls. CLI env template docstring lists state/reset schemas.
- tests/core/test_reset_schema.py covers publication with and without
  the web interface, inherited seed/episode_id fields, unaffected
  action/observation/state schemas, the base-schema fallback, and that
  /reset bodies are not validated against reset_cls.

No deviations from the spec.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vd6SA9aV1SAmUBCewkcVsZ
@scosman

scosman commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

will resolve conflicts if maintainers want this PR, but some 👍 👎 would be good.

@burtenshaw burtenshaw mentioned this pull request Oct 5, 2026
7 of 14 tasks
@scosman

scosman commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@burtenshaw is this something you'd want to to take? I can resolve conflicts but not sure if you want it or not.

@burtenshaw

burtenshaw commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Resolved main conflicts, preserving mode and reset-observation wiring. Added WebSocket non-validation regression and RFC 002 amendment for the new core parameter. 888 core tests pass; changed-file lint passes. Required CI is outstanding.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c3a4d35. Configure here.

Comment thread src/openenv/core/env_server/types.py Resolved
@burtenshaw
burtenshaw merged commit 7266265 into openenv:main Oct 26, 2026
12 checks passed
@cursor cursor Bot mentioned this pull request Oct 28, 2026
3 of 8 tasks
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.

Add reset() schema to /schema

2 participants