Skip to content

feat: define core episode types - #3483

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/episode-orchestration-02-wire-contracts
Sep 22, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/episode-orchestration-02-wire-contracts

Conversation

@ananthsub

@ananthsub ananthsub commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds only the shared episode identity and envelope in nemo_gym/episode_types.py: EpisodeId, minimal TaskId, MaterializedTask, base request/response, and handled failure.

TaskId contains only taskset and task_id. Taskset names use the <environment>:<taskset> convention when a run blends tasksets.

Single-agent interaction flow

This diagram shows the built-in single-agent use case. Other Environment Server protocols may coordinate different participants and use different request, result, and lifecycle flows.

sequenceDiagram
    participant C as Rollout collector
    participant E as Environment Server
    participant R as Task / Resources Server
    participant A as Agent Server
    participant M as Model Server
    participant S as Task sandbox

    C->>E: POST /run
    E->>R: Seed task session
    R-->>E: Tool access and optional SandboxAccess
    E->>A: Seed agent session
    A->>S: Connect as borrower when supplied
    E->>A: Invoke /v1/responses
    A->>M: Model and capture requests
    A-->>E: Agent response
    E->>A: Close agent session
    E->>R: Verify response
    E->>R: Close task session
    E-->>C: Episode result
Loading

The Environment Server coordinates ordering and the final result. Agent and Task/Resources Servers retain ownership of the state and resources they create.

This is part 2 of 14 in the Environment Server stack. Previous: #3482. Next: #3484.

Validation

  • uv run pytest tests/unit_tests/test_episode_types.py -q

Rollouts

See the final PR for end-to-end rollout evidence.

Compatibility and benchmark impact

No agent, resources, tool, or sandbox lifecycle contract is included.

@copy-pr-bot

copy-pr-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@ananthsub
ananthsub added this pull request to stack #3493 September 17, 2026 16:31
@ananthsub ananthsub changed the title ananthsub/episode orchestration 02 wire contracts feat: define episode wire contracts Sep 17, 2026
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-02-wire-contracts branch from f7e6000 to 72b2e94 Compare September 17, 2026 20:17
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-02-wire-contracts branch from 72b2e94 to 2181e7e Compare September 17, 2026 20:28
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-02-wire-contracts branch 2 times, most recently from 39ad4b9 to ff913f0 Compare September 18, 2026 01:06
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-02-wire-contracts branch from ff913f0 to 1618e0e Compare September 18, 2026 01:32
@ananthsub
ananthsub marked this pull request as ready for review September 18, 2026 19:45
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team September 18, 2026 19:46
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-02-wire-contracts branch from 1618e0e to e5ede3f Compare September 18, 2026 20:44
@yaoyu-33 yaoyu-33 added complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Sep 18, 2026
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-02-wire-contracts branch from 9bfb0f1 to 4a52642 Compare September 19, 2026 01:02
yaoyu-33
yaoyu-33 previously approved these changes Sep 19, 2026

@yaoyu-33 yaoyu-33 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.

LGTM for the shared task and episode contracts. The reviewed source and tests are unchanged in the updated head.

@yaoyu-33 yaoyu-33 added ready-to-merge PR is approved, current, and waiting for final CI or merge and removed needs-review PR is ready for code review and waiting on a reviewer labels Sep 19, 2026
ffrujeri
ffrujeri previously approved these changes Sep 19, 2026
Base automatically changed from ananthsub/episode-orchestration-01-server-type to main September 19, 2026 04:07
@bxyu-nvidia
bxyu-nvidia requested a review from a team as a code owner September 19, 2026 04:07
bxyu-nvidia pushed a commit that referenced this pull request Sep 19, 2026
## What does this PR do?

Registers `environment_servers` as a first-class Gym server type for
configuration, discovery, startup, addressing, status, and telemetry.

## Interaction flow

```mermaid
sequenceDiagram
    participant C as Rollout collector
    participant E as Environment Server
    participant R as Task / Resources Server
    participant A as Agent Server
    participant M as Model Server
    participant S as Task sandbox

    C->>E: POST /run
    E->>R: Seed task session
    R-->>E: Tool access and optional SandboxAccess
    E->>A: Seed agent session
    A->>S: Connect as borrower when supplied
    E->>A: Invoke /v1/responses
    A->>M: Model and capture requests
    A-->>E: Agent response
    E->>A: Close agent session
    E->>R: Verify response
    E->>R: Close task session
    E-->>C: Episode result
```

The Environment Server coordinates ordering and the final result. Agent
and Task/Resources Servers retain ownership of the state and resources
they create.

This is part 1 of 13 in the Environment Server stack. Previous: `main`.
Next: [#3483](#3483).

## Validation

- `uv run pytest tests/unit_tests/test_global_config.py -q`

## Rollouts

See the final PR for end-to-end rollout evidence.

## Compatibility and benchmark impact

Existing Agent Server routing remains available during migration.

Signed-off-by: Ananth Subramaniam <[email protected]>
@ananthsub
ananthsub dismissed stale reviews from ffrujeri and yaoyu-33 September 19, 2026 04:07

The merge-base changed after approval.

@cmunley1

Copy link
Copy Markdown
Contributor

EpisodeId currently only models linear retries (rollout_id + attempt), with no parent/child or branch-path concept. For subagents, multi agent, complex agentic systems that dont look like a harness, in general tree/forest-style, might need lineage in this identity type. retrofitting that once rollout_collection.py, reverification, and metrics all depend on the flat shape will be more expensive than adding it now. Should we add a parent_episode_id/branch-path field (even unused today) before this type gets more callers, and re-derive capture_key's injectivity proof to account for it? also the sandbox owner/borrower contract in #3545 is 1:1 with no fork/multi-borrower consideration

marta-sd
marta-sd previously approved these changes Sep 21, 2026
@ananthsub

ananthsub commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

@cmunley1

EpisodeId currently only models linear retries (rollout_id + attempt), with no parent/child or branch-path concept. For subagents, multi agent, complex agentic systems that dont look like a harness, in general tree/forest-style, might need lineage in this identity type. retrofitting that once rollout_collection.py, reverification, and metrics all depend on the flat shape will be more expensive than adding it now. Should we add a parent_episode_id/branch-path field (even unused today) before this type gets more callers, and re-derive capture_key's injectivity proof to account for it?

EpisodeId identifies the overall Environment Server attempt. multi-agent Environment Server implementations will define their own specific request/result types. This would include multiple agent sessions under the same episode. Each agent run and lineage can be represented separately through its protocol-specific request/result types.

Where we'd need child episode identity is if we supported Environment Servers calling other Environment Servers /run endpoints, which is out of scope for now.

also the sandbox owner/borrower contract in #3545 is 1:1 with no fork/multi-borrower consideration

we can have many:1 sandbox borrower to owner access. multiple agent sessions can receive the same descriptor. we don't have a sandbox fork capability exposed yet, which is separate from this PR.

Comment thread nemo_gym/episode_types.py Resolved

@adil-a adil-a 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.

lgtm, thanks

Signed-off-by: Ananth Subramaniam <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/35733914924

This branch was previously deployed

1 inactive deployment
public — f82ab2fa Deployed Sep 22, 2026 by copy-pr-bot[bot] via release / finalize / notify #3429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Shared APIs, servers, telemetry, health, and registries complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work ready-to-merge PR is approved, current, and waiting for final CI or merge sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants