Skip to content

feat(workplace_assistant): serve the typed resources sessions API - #5486

Open
yaoyu-33 wants to merge 34 commits into
mainfrom
yuya/gymint-231-workplace-assistant-sessions
Open

yaoyu-33 wants to merge 34 commits into
mainfrom
yuya/gymint-231-workplace-assistant-sessions

Conversation

@yaoyu-33

@yaoyu-33 yaoyu-33 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Serve typed workplace sessions and delegate common seed, verification cleanup, close and retirement to the shared lifecycle merged in #5709. Preserve table construction/mutations and checkpoint behavior, using public identity restoration APIs instead of base-private dictionaries.

The shared lifecycle in #5709 and MCP support in #5708 are merged into main. The child diff contains only this environment and its related documentation/configuration; shared implementation is reviewed once in the dependency. No separate issue is needed for this focused migration of an existing resources server.

  • Validate full typed task data while retaining permissive cookie rows. Matching typed retries preserve mutations; conflicting identity and malformed HTTP/MCP envelopes are rejected.
  • Restore checkpoint tables and identities with atomic batch prevalidation. Keep old flat snapshots and adoption of unbound restored state; first cookie use claims the state so another episode cannot take it over.
  • Verification releases tables and active identity while retaining bounded request-scoring evidence. Offline gym eval reverify ++force=true of workplace rows, which main rescored by replay, is now masked (REVERIFY_MODE = UNSUPPORTED; the guard already refused the non-forced form as UNKNOWN). A tool call without a live session is now 404 failure_kind: session_lost (main: 400). This migration does not reconstruct workplace databases offline.

Request-scored: retains an empty marker (retain(None)) because the request already carries the answer and grading data.

Validation on a1186a92e2bcf924fc1447ec2e5cf5cd26d4364d, Python 3.13.14, with this checkout first on PYTHONPATH and NEMO_GYM_EXTRA_ROOTS pointing to it:

Real-model smoke on preceding migration revision 618012d86bb37efa3e3388fee5426833aa4d2520 (shared core 4e92d4891) used nvidia/nemotron-3.5-lightning-30b-a3b, Python 3.13.14 and the stock workplace task through real Gym HTTP applications. Typed and cookie paths each completed three model calls, scored 1.0 and released all workplace tables and identity state; lifecycle checks passed. The cookie run recovered from provider 429 responses within the existing bounded retry policy. Loaded source hashes matched that revision. Checkpoint restore/adoption and MCP validation are covered by regressions; these two rollouts do not claim model-driven checkpoint recovery or benchmark parity. Retry and cleanup paths at this head are covered by unit tests only.

These targeted checks do not replace the repository CI matrix or approval of the current head.

Main refresh validation

Merged main at acb67734c into this branch, retaining main's MCP annotation resolution and seed-validation regressions. The diff against main contains only this environment and its related documentation/configuration. No new environment behavior was added by this refresh.

On workstation ws (Python 3.13.14), this environment's complete test directory passed: 78 passed. The nine environment suites passed 904 tests in total. Shared lifecycle, MCP seed/exposure, and process-supervisor tests passed 213 tests. Tests ran in a combined validation checkout with the merged core and the exact environment sources from these nine heads, with the checkout first on PYTHONPATH and NEMO_GYM_EXTRA_ROOTS. Prior real-model smoke evidence above remains historical; no fresh model rollout was run for this merge-only update. New merge commits are DCO signed off.

pre-commit run --all-files passed on the combined checkout, including Ruff, formatting, guardwords, config flags, environment table generation, and import layering. The generated README row matches the row already included in #5485. git diff --check passed for each refreshed branch.

CI timing fix

Cherry-picked the already-merged test-only fix from #5883 after CI repeatedly timed out in mini-SWE runner startup and also hit Harbor’s short successful-path deadline. Production timeouts and behavior are unchanged.

Validation of 2f79a0a082f561fb892ebef2194216936bed577b on workstation ws, Python 3.13.14, with source imports resolving to the isolated validation checkout:

  • Both changed test files: 112 passed (python -m pytest -o addopts='' -o log_cli=false --import-mode=importlib -q --tb=short environment_servers/harbor/tests/test_multi_turn.py responses_api_agents/miniswe_sandboxed_agent/tests/test_app.py).
  • Full pre-commit run --all-files: passed; private guardwords catalog unavailable, so that scan was skipped. git diff --check passed; the two validated files match the pushed commit by SHA-256. Commit includes DCO sign-off.
  • Model rollout: N/A for this test-only upstream fix. Fresh repository CI requested on the new head.

An Environment Server such as single_agent_turn seeds each resources
server with a typed ResourcesSeedSessionRequest and releases it with
/close_session. workplace_assistant accepted only an Agent's /run seed
and returned an untyped response, so it could not be fronted by
single_agent_turn_legacy.

- seed_session accepts the typed body next to the /run body. Typed
  sessions are keyed by resources_session_id: a repeated seed keeps
  the tables the tool calls changed, a seed bound to another episode
  or a closed session gets 409, and task_data that is not a task gets
  422.
- close_resources_session releases the tables by resources_session_id
  (no cookie needed), is idempotent, and fences late seeds with
  ResourcesSessionFence.
- verify keeps a typed session's tables for its close; a /run session
  is still released at verify. A verify for a session the server no
  longer holds returns a masked lost-session sample, and a tool call
  for one gets 404 (was 400).
- retire_session_state shares the release helper.

Refs GYMINT-231.

Signed-off-by: yaoyu-33 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yaoyu-33 yaoyu-33 added feature New capabilities, enhancements, or enablement work area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers labels Nov 3, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

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.

@yaoyu-33

yaoyu-33 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 932a186

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

… path

List the typed seed first, as the path new configs use, and describe the
Agent /run seed as the path kept so the legacy_agent configs run unchanged
until they switch.

Signed-off-by: yaoyu-33 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yaoyu-33

yaoyu-33 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 4810f54

@yaoyu-33
yaoyu-33 marked this pull request as ready for review November 3, 2026 18:33
@yaoyu-33 yaoyu-33 added the needs-review PR is ready for code review and waiting on a reviewer label Nov 3, 2026
yaoyu-33 and others added 3 commits November 3, 2026 11:05
…ng it

The seed recorded the session's episode and task before get_tools built its tables. get_tools reads CSVs from disk and can fail (EMFILE under load); the seed then answered 500 but kept the binding, so the caller's retry took the repeated-seed path and returned 200 for a session with no tables, whose tool calls all got 404 and whose verify was masked.

The tables are now built first. Adds a test where get_tools fails once (fails on the previous code), makes the 422 test check that no binding is left, and moves the conformance import to nemo_gym.server_runtime.testing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 3, 2026 20:01
…ng it

Verify releases a /run session's tables, and the HTTP client sends a verify again when its connection drops, even after the server answered. The resend found no tables and came back masked, where main scored it. The score reads only the request, so verify now remembers the /run sessions it released for session_close_retry_window_seconds and scores a resend. A /run verify with no seed, and any verify of a closed typed session, is still masked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

yaoyu-33 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test fac079f

yaoyu-33 and others added 2 commits November 4, 2026 12:50
The /run seed guard refused any body sharing a key with ResourcesSeedSessionRequest, so a dataset row with a scalar task_id got 422 on every seed. Treat a body as a malformed typed seed only when it names resources_session_id or carries typed episode_id and task_id objects, the rule #5480 settled on.

Also import check_resources_session_contract from nemo_gym.server_runtime, which main's public-API test requires, and state verify's no-await invariant next to its retry bookkeeping.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

yaoyu-33 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 77a7ab4

yaoyu-33 and others added 3 commits November 5, 2026 23:08
…ment the hook contract

- A cancellation that arrives while a failed initialization is being cleaned up now propagates instead of
  being swallowed by the cleanup guard.
- A cookie reseed that released the preceding run moves its finished receipt into the retry window, so a
  failed replacement no longer leaves a pending-cleanup record with nothing to release.
- Document that a disconnect leaves a verification release pending, that the release hook runs under the
  session lock, that state is per worker with session routing keeping a session on its owner, and the
  override rules for servers that keep their own seed and close.
- Rename the example server's private episode table so it no longer shares a name with the base's.
- Add regressions for the receipt deadline guard, worker ownership wiring, cookie seed races and fences,
  typed seed takeover, restore refusals and a cancelled close waiting on verification.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
…ose wording

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

yaoyu-33 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test a1186a9

…ADME

The README now describes only the typed Environment Server path. The cookie
seed still works unchanged; the PR description records that compatibility.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

yaoyu-33 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 5688115

Base automatically changed from yuya/shared-resources-lifecycle to main November 8, 2026 06:36
@yaoyu-33

yaoyu-33 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 6859199

…5883)

test: give Harbor and mini-SWE timing checks more headroom

Signed-off-by: svcnemo-autobot <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
@yaoyu-33

Copy link
Copy Markdown
Contributor Author

/ok to test 2f79a0a

This branch was previously deployed

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

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants