Skip to content

feat(environment): validate task rows against the routed server's TaskInput - #6448

Open
ananthsub wants to merge 1 commit into
ananthsub/environment-task-input-modulesfrom
ananthsub/env-validate-task-input
Open

ananthsub wants to merge 1 commit into
ananthsub/environment-task-input-modulesfrom
ananthsub/env-validate-task-input

Conversation

@ananthsub

@ananthsub ananthsub commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Stack 4 of 5. #6499 → #6418 → #6447 → this PR → #6449. Needs #6447.

Before and after

Before: gym env validate checks a task row against SingleAgentTurnTaskInput only when its taskset routes to one of two hardcoded servers. Every other server, including swe_together and Harbor, gets only an envelope check, so a bad swe_together row passes.

After: it validates a task row against the TaskInput of the server its taskset routes to, loaded from that server's task input module (#6447).

flowchart LR
    R["Task row"] --> S{"Routed server's task_input.py"}
    S -->|"TaskInput type"| V["Validate MaterializedTask[TaskInput]"]
    S -->|"TaskInput = None, a relay"| X["Refused: a relay takes no task rows"]
    S -->|"no module, or no route"| E["Envelope check, as before"]
    classDef good fill:#dff5e3,stroke:#1e8449,color:#000
    class V,X good
Loading
Task row Before After
swe_together row with task_data missing image and image_digest Passes Fails at task_input.task_data
Task row routed to legacy_agent Passes the envelope check Refused, naming the relay
Single-agent-turn row Checked against SingleAgentTurnTaskInput Unchanged

What changed and why

  • SINGLE_AGENT_TURN_ENVIRONMENT_SERVERS and TaskInputObject are removed. The routed server's contract is looked up once per dataset.
  • A task row with no route, or routed to a server without a task input module, keeps the envelope check. A manifest can be validated without the run config that routes it, so this check does not refuse unrouted rows; collation, which runs with that config, does (fix(data): check collated rows against the server that receives them #6449).
  • The authoring checks, for top-level responses_create_params beside task_input and for prepared prompts, apply where the model requires responses_create_params. That keeps them for single-agent-turn rows and leaves swe_together's placeholder rows and Harbor multi-step rows alone.

Issue

None filed. Part of checking rows against the model of the server that receives them.

Validation

pytest -n 8 tests/unit_tests/environment/test_environment_validation.py
pre-commit run --files <changed files>

New tests check a swe_together row against its model and refuse a task row routed to a relay. The existing tests still cover single-agent-turn rows, the authoring checks, and broken envelopes on any server.

Rollout evidence

N/A. gym env validate only; no server behavior changes.

Compatibility

A manifest with task rows that fail their server's model now fails gym env validate. Those rows fail at dispatch today. SINGLE_AGENT_TURN_ENVIRONMENT_SERVERS and TaskInputObject had no users outside validation.py, in Gym or NeMo RL main.

@ananthsub ananthsub added the area:data Datasets, preparation, task formats, and materialization label Nov 19, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 19, 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.

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP WITH CARE

I found a false rejection for absolute-path manifests whose task contracts import a schema from the same component root. The validation guide also needs to describe the newly imported contracts.

I inspected both changed files and their affected runtime paths. This was static review; I did not execute tests.


Inline comments (escaped v1):

  • nemo_gym/environment/validation.py line 864: RISK: Make the manifest's component root importable before loading its contract

    Failure: From outside /plugin, run gym env validate --manifest /plugin/benchmarks/demo/manifest.yaml. Route a valid materialized row to a custom environment server whose contract imports from resources_servers.plugin_rs.task_data import TaskData as TaskInput, with both components beneath /plugin. For example, let TaskData require question: str and supply {"task_id":{"taskset":"demo","task_id":"1"},"task_input":{"question":"q"}}.

    _with_component_root adds /plugin to file-search roots but not sys.path. This lookup finds the contract, then load_task_input_module executes its ordinary import, which fails because the schema's root is not importable. Validation should accept this valid row. The base implementation accepted it through envelope validation.

    Correction: Could you align imports with the effective component-search roots during validation? One small correction is to add import sys and import the existing _augment_sys_path, then replace _with_component_root's current try/finally with:

    original_sys_path = sys.path[:]
    try:
        _augment_sys_path()
        yield
    finally:
        sys.path[:] = original_sys_path
        if original is None:
            os.environ.pop(NEMO_GYM_EXTRA_ROOTS_ENV_VAR_NAME, None)
        else:
            os.environ[NEMO_GYM_EXTRA_ROOTS_ENV_VAR_NAME] = original

    This makes the selected root importable without leaving the path change behind. Keep the loader's cross-root rejection guard, including for already-imported foreign modules; do not hide a mismatch by accepting the cached model. Keep missing-module envelope fallback and malformed-module errors unchanged.

    Proposed acceptance: Create the uniquely named components above under a temporary manifest root absent from sys.path, change to another directory, and validate the absolute manifest path. The valid row should report one row; removing question should raise EnvironmentValidationError for the required field, not an import failure. Check path and environment restoration on success and failure. Retain the two-row success assertion for both single-agent-turn servers in the existing compatibility test, and the TaskInputModuleError assertion for a genuinely foreign schema in the cross-root test. The patch and checks are suggested, not executed.

  • fern/versions/latest/pages/contribute/environments/new-environment.mdx line 479: NOTE: Suggest documenting the task-contract import exception

    The statement that validation “does not import components” is no longer accurate. For a routed materialized row, the new contract lookup reaches module execution. Contributors relying on this paragraph should know that the task contract loads, even though validation does not start its server.

    Could you replace this paragraph with the following, keeping the distinction that preparation and rollout-driver hooks are parsed without execution?

    It imports routed servers' dependency-light `task_input.py` contracts when validating materialized tasks, but does not import their `app.py` entrypoints, start services, execute preparation code, call a model, run an evaluation, probe model or resources endpoints, or check evaluation-output writability. Runtime pre-run readiness is a separate validation layer. Component versions and capabilities, profile pinning, and `adopted_from` source resolution are deferred from this initial static validation. Scorer behavior and grading quality require the later validation layers.
    

    Static acceptance: the guide should distinguish executed task-input contracts from unexecuted application entrypoints and preparation hooks, matching the inspected lookup. No runtime change or new test is needed.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Nov 19, 2026
@yaoyu-33
yaoyu-33 requested a review from prokotg November 19, 2026 07:07
@ananthsub
ananthsub force-pushed the ananthsub/env-validate-task-input branch from ac754d4 to c49fdee Compare November 19, 2026 18:23
@ananthsub
ananthsub force-pushed the ananthsub/environment-task-input-modules branch from 897a942 to 4dd7f30 Compare November 19, 2026 18:23
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 19, 2026 18:24
@ananthsub

Copy link
Copy Markdown
Contributor Author

Both review points are addressed in c49fdee.

  • Manifest root not importable. _with_component_root now runs _augment_sys_path() and restores sys.path afterwards, as suggested. The loader's cross-root refusal is unchanged. A test puts a resources server's task_data.py and an environment server whose task_input.py imports it under a manifest root that is not on sys.path. It checks that the valid row passes, that a row missing the required field fails on that field rather than on an import, and that sys.path is restored.
  • Guide paragraph. The paragraph now says validation imports routed environment servers' dependency-light task_input.py modules to check materialized task rows, but not their app.py entrypoints or other components.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

@ananthsub
ananthsub force-pushed the ananthsub/env-validate-task-input branch from c49fdee to d76011e Compare November 19, 2026 19:17
@ananthsub
ananthsub force-pushed the ananthsub/environment-task-input-modules branch from 4dd7f30 to 5caad12 Compare November 19, 2026 19:17
@ananthsub
ananthsub force-pushed the ananthsub/env-validate-task-input branch from d76011e to 9e05799 Compare November 19, 2026 22:34
@ananthsub
ananthsub force-pushed the ananthsub/environment-task-input-modules branch from 5caad12 to 569a391 Compare November 19, 2026 22:34
…kInput

gym env validate checked a task row against SingleAgentTurnTaskInput
for two hardcoded servers and only as an envelope for every other
server. It now loads the routed environment server's task input module
and validates MaterializedTask[TaskInput], so swe_together and Harbor
rows are checked against their own models. A task row routed to a
relay is refused. A row with no route, or routed to a server without a
module, keeps the envelope check, because a manifest can be validated
without the run config that routes it. The authoring checks apply
where the model requires responses_create_params, as before for
single-agent-turn rows.

Signed-off-by: Ananth Subramaniam <[email protected]>
@ananthsub
ananthsub force-pushed the ananthsub/environment-task-input-modules branch from 569a391 to 972fa94 Compare November 19, 2026 22:51
@ananthsub
ananthsub force-pushed the ananthsub/env-validate-task-input branch from 9e05799 to 3e8049f Compare November 19, 2026 22:51
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 20, 2026

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

area:data Datasets, preparation, task formats, and materialization feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer risk:mid Autobot PR risk: mid 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.

2 participants