Skip to content

feat: Gymnasium style base environment#1072

Merged
cmunley1 merged 18 commits intomainfrom
cmunley1/gymnasium-base
Apr 23, 2026
Merged

feat: Gymnasium style base environment#1072
cmunley1 merged 18 commits intomainfrom
cmunley1/gymnasium-base

Conversation

@cmunley1
Copy link
Copy Markdown
Contributor

@cmunley1 cmunley1 commented Apr 15, 2026

#1030

Gymnasium-style step()/reset() API implemented as a base resources server, with a simple compatible agent to drive the agent-environment interaction in this context, and an example blackjack resources server extending the base class.

resources_servers/base_gymnasium/ has GymnasiumServer base class. Meant to be subclassed, implement step() and optionally reset(), use with gymnasium_agent. Reset is used to init state or provide an additional initial message. Step handles verification, multistep logic, and stopping logic.

The base class handles /reset and /step endpoints, session IDs, and the HTTP layer.

class MyEnv(GymnasiumServer):
    async def step(self, action, metadata, session_id=None):
        return observation, reward, terminated, truncated, info

responses_api_agents/gymnasium_agent/ drives the loop: calls /reset, then alternates between model calls and /step until terminated or truncated. Handles token ids, usage, cookies

Examples

  • blackjack_env - multi-step game, <action> tags, stateful

Removed multi-turn examples for follow up PR.

Docs

docs/resources-server/gymnasium-api.md covers usage and examples.

Impact on existing environments

Nothing existing changed. example_gymnasium + gymnasium_agent is a simpler way to write environments. It hides the HTTP endpoints, session management, and request/response types. Users just implement step(). Existing resources servers + agents path still works as before.

Signed-off-by: cmunley1 <cmunley@nvidia.com>
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Apr 15, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Signed-off-by: cmunley1 <cmunley@nvidia.com>
Signed-off-by: cmunley1 <cmunley@nvidia.com>
## Summary
- Align `docs/resources-server/gymnasium-api.md` with the existing docs
style guide patterns

## Changes
- Add back navigation button and `---` horizontal rule separators
between sections (matches all other doc pages)
- Add cross-references to related docs (`{doc}` links to single-step
tutorial, multi-step tutorial, LLM-as-judge)
- Add `:::{tip}` directive pointing readers to the standard
`SimpleResourcesServer` tutorials
- Fix `_extract_text` → `extract_text` to match the actual export from
`resources_servers.base_gymnasium`
- Fix typo: "initial the environment" → "initialize the environment"
- Fix hyphenation: "non agentic" → "non-agentic"
- Fix double dash `--` → em-dash `—` in Examples section
- Add GitHub source link for blackjack example (matches other doc pages)
- Fix typo "Gymansium" → "Gymnasium" in `gymnasium_agent/README.md`

## Test plan
- [ ] Verify doc builds without broken references (`{doc}` and `{ref}`
links)
- [ ] Visual check that section separators and back button render
correctly

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Lawrence Lane <llane@nvidia.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread resources_servers/base_gymnasium/__init__.py
cmunley1 added 14 commits April 17, 2026 00:25
Signed-off-by: cmunley1 <cmunley@nvidia.com>
Signed-off-by: cmunley1 <cmunley@nvidia.com>
Signed-off-by: cmunley1 <cmunley@nvidia.com>
…arse stricter, validate max steps, more tests

Signed-off-by: cmunley1 <cmunley@nvidia.com>
Signed-off-by: cmunley1 <cmunley@nvidia.com>
Signed-off-by: cmunley1 <cmunley@nvidia.com>
Signed-off-by: cmunley1 <cmunley@nvidia.com>
Signed-off-by: cmunley1 <cmunley@nvidia.com>
Signed-off-by: cmunley1 <cmunley@nvidia.com>
Signed-off-by: cmunley1 <cmunley@nvidia.com>
Signed-off-by: cmunley1 <cmunley@nvidia.com>
Signed-off-by: cmunley1 <cmunley@nvidia.com>

# Conflicts:
#	README.md
Signed-off-by: cmunley1 <cmunley@nvidia.com>
@cmunley1 cmunley1 merged commit 0232cf6 into main Apr 23, 2026
6 checks passed
@cmunley1 cmunley1 deleted the cmunley1/gymnasium-base branch April 23, 2026 19:14
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.

2 participants