Repository navigation
Conversation
This was referenced Oct 29, 2026
pthombre
force-pushed
the
pranav/agent-instance-07-migrate-readers
branch
from
October 29, 2026 02:19
d438941 to
553b2c2
Compare
pthombre
force-pushed
the
pranav/agent-instance-07-migrate-readers
branch
2 times, most recently
from
November 3, 2026 00:03
eb5c726 to
dfe85d5
Compare
pthombre
force-pushed
the
pranav/agent-instance-07-migrate-readers
branch
from
November 3, 2026 14:13
dfe85d5 to
e8ac194
Compare
pthombre
force-pushed
the
pranav/agent-instance-07-migrate-readers
branch
2 times, most recently
from
November 3, 2026 15:22
2306198 to
851461e
Compare
pthombre
force-pushed
the
pranav/agent-instance-07-migrate-readers
branch
from
November 4, 2026 00:50
851461e to
05b8f20
Compare
pthombre
force-pushed
the
pranav/agent-instance-07-migrate-readers
branch
from
November 4, 2026 01:33
05b8f20 to
84d930a
Compare
ananthsub
force-pushed
the
pranav/agent-instance-07-migrate-readers
branch
from
November 4, 2026 06:08
84d930a to
6a6cfee
Compare
pthombre
force-pushed
the
pranav/agent-instance-07-migrate-readers
branch
from
November 16, 2026 18:57
6a6cfee to
22138d5
Compare
pthombre
force-pushed
the
pranav/agent-instance-07-migrate-readers
branch
from
November 16, 2026 20:46
22138d5 to
8a4ccda
Compare
…tion module After this change no code parses or builds the /ng-rollout path by hand; FastAPI route templates still spell out the prefix. Readers moved onto nemo_gym.core.correlation.resolve: the checkpoint policy admission middleware, the Switchyard rollout session middleware, Simple Agent's activation reader, RolloutContextMiddleware (used by resources servers, which now strip the whole prefix), and url_path_for_request, which carries the inbound training tag and agent instance name (an inbound name wins over the session's). Key rule: resolve adopts ROLLOUT_ID_PATTERN, the rule documented for every reader. The model server's capture reader, the trace reader, the checkpoint admission reader and session routing used to accept anything up to the next `/`; a capture key outside the rule is now refused with 400. Builders moved onto rollout_path_prefix: the Harbor and Single Agent Turn environment servers' activation paths. ServerClient: for a model path a caller already prefixed without a name, the name set with agent_instance_context is inserted, so it is never dropped; a path that names an agent instance keeps it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Pranav Prashant Thombre <[email protected]>
…he migrated readers on named paths - correlation: the capture key must match the rollout id rule in full, so a key with a trailing line break is refused again by the resources and Switchyard readers this stack moved onto the shared rule - tests: the checkpoint admission reader on named, tagged and malformed paths, ServerClient keeping the query and trace segment of a path it names, and the Harbor activation path's training tag Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: Pranav Thombre <[email protected]>
pthombre
force-pushed
the
pranav/agent-instance-07-migrate-readers
branch
from
November 17, 2026 09:45
8a4ccda to
b1ff961
Compare
pthombre
marked this pull request as ready for review
November 20, 2026 18:00
svcnvidia-nemo-ci
left a comment
Contributor
There was a problem hiding this comment.
SHIP
I checked all 21 changed files and traced the affected correlation paths across server boundaries. No qualifying issues found.
This was a source-only review. I did not execute tests.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
PR 1 moved the model server's and the trace middleware's readers onto
nemo_gym.correlation. A few readers and builders still parsed or spelled out/ng-rollout/...by hand, each with its own idea of a valid capture key. After this PR no code parses or builds the path by hand; FastAPI route templates still spell out the prefix, since they cannot use the module.Readers moved onto
resolve:_checkpoint/model.py);switchyard_model/app.py);RolloutContextMiddleware, used by resources servers, which now strips the whole prefix;url_path_for_request, which carries the inbound training tag and agent instance name (an inbound name wins over the session's) through a newinbound_correlation(request)helper. A stand-in request without an ASGI scope is read from its URL path, then from arollout_idpath parameter, so agents and their tests that pass such requests keep working.Key rule.
resolveadoptsROLLOUT_ID_PATTERN(now defined incorrelation, re-exported fromrollout_correlation), the rule documented for every reader. The model server's capture reader, the trace reader and the checkpoint admission reader used to accept anything up to the next/; Switchyard and resources servers already applied the pattern. Session routing's seed and close matcher is a route pattern and is left as is. The change is deliberate and tested.Builders moved onto
rollout_path_prefix: the Harbor and Single Agent Turn environment servers' activation paths (nemo_user_sim and SWE-Together moved in PR 5).ServerClient. For a model generation path a caller already prefixed without a name, the name set with
agent_instance_contextis inserted withencode, so a name set in context is never silently dropped; a path that names an agent instance keeps it. PR 4's rule that a caller building its own prefix must pass the name no longer applies.How it works
Where this PR sits in the overall flow; the highlighted part is what this PR changes.
flowchart LR ENV["Environment server<br/>seeds and activates agent sessions"] AG["Agent server<br/>session bound to its agent instance"] RS["Resources server<br/>verify(), judges"] MS["Model server<br/>capture middleware"] CM["nemo_gym.correlation<br/>resolve / encode"] LG[("Capture ledger and token store<br/>rows carry agent_instance, model_ref")] DL["Delivery and manifest<br/>chains and outcomes per agent instance"] RR["Episode result<br/>agent_instances map"] ENV -->|"/ng-rollout/k/ng-agent-instance/user/v1/responses"| AG AG -->|"model calls named user"| MS RS -->|"verify.<id> and judge calls"| MS MS --> CM MS --> LG --> DL --> RR ENV --> RR classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937 class CM thisflowchart LR subgraph Before R1["capture regex"] & R2["trace regex"] & R3["checkpoint regex"] & R4["Switchyard regex"] & R5["RolloutContextMiddleware._PREFIX"] & R6["path_params + substring"] & B1["f'/ng-rollout/...' builders"] end subgraph After C["nemo_gym.correlation<br/>resolve / encode<br/>ROLLOUT_ID_PATTERN"] end Before --> CWhere this sits in the stack
This is one PR in a stack of draft PRs that implements agent instance identity from the Gym capture identity design (draft 2): several agent instances (assistant, judge, simulated user, debaters) can call model servers in one episode, every record says which one made each call, capture computes lineage and outcomes per agent instance, and the trainer chooses which agent instances it trains on. Gym records; trainers select. Single-agent episodes do not change: an agent's own
/runnames no agent instance, and its records differ frommainonly by the newmodel_refcolumn.Each PR is one commit, and its base is the branch of the PR before it, so each diff shows only that PR's change.
pranav/agent-instance-00-capture-key-rename): refactor(capture): name capture keys capture_key on the ledger control surfacepranav/agent-instance-01-correlation-module): feat(core): add a correlation module that reads and builds the rollout pathpranav/agent-instance-02-record-identity): feat(model): record agent instance, agent kind and model server on every capture and model-call recordpranav/agent-instance-03-per-agent-capture): feat(capture): compute lineage, terminal chains and outcomes per agent instance and model serverpranav/agent-instance-04-direct-call-names): feat(core): let callers name an agent instance on model callspranav/agent-instance-05-agent-session-binding): feat(agent): bind agent sessions to an agent instance at seed timepranav/agent-instance-06-per-agent-results): feat(episode): report terminal calls and rewards per agent instancepranav/agent-instance-07-migrate-readers): refactor(core): read and build every rollout path through the correlation module (this PR)The first PR's base is
main@0b8783981. External dependencies: #5083 (session lifecycle names, open) for PR 5. #4969 (rollout prefix hooks for fixed-base-URL clients, open) needs one small change in whichever of #4969 and PRs 1 and 4 lands second:with_rollout_prefixdetects an existing prefix withresolveand takes the name fromagent_instance_context.The NeMo RL follow-up (selecting agent instances to train on, one
RolloutReceiptper selected agent instance, per-agent rewards) is separate; until NeMo RL bumps its Gym pin, none of these PRs affect NeMo RL training runs.Issue
No tracking issue exists; the work follows the Gym capture identity design (draft 2) and its implementation plan.
Validation
Tests ran on Slurm (one node,
rl-gym.nightlycontainer), each branch against a baseline worktree ofmain@0b8783981:python -m pytest -n 32 tests/unit_tests): 33 failed, 12,191 passed, 4 errors. Every one is environmental in this container (docker-compose, OpenSandbox compose, Harbor compose overlay, eval resubmit, reward profile, dataset orchestrator and sandbox supervisor tests, and four exporter modules that fail to import), and the same set fails on every branch of the stack. The docker-compose tests are flaky: one or two of them pass or fail from run to run.requirements.txtorpyproject.toml, asgym env testdoes.pre-commitcould not fetch its hook repositories from the build environment, soruff check --fix,ruff check --select I --fixandruff formatran with ruff 0.9.9 (the hook's pinned version) on every changed file. The guardwords and end-of-file hooks did not run here; CI runs them.Signed-off-byline.path_params;inbound_correlationreads those, and they pass unchanged.test_correlation.py: a capture key outsideROLLOUT_ID_PATTERNraises; resources servers strip a whole named prefix and see its rollout.test_base_responses_api_model.py: accepted explicit ids round-trip through the module; a capture key outside the rule gets 400 from the model server;url_path_for_requestcarries the inbound prefix from the request's scope.test_rollout_correlation.py:ServerClientinserts the context name into a caller-prefixed generation path, keeps a path that already names one, and leaves non-generation and resources-server paths alone.test_agent_session_instances.py: an inbound name wins over the session's when carrying the path; an unnamed inbound path takes the session's name.Rollout evidence
N/A beyond the stack's: every migrated reader and builder gives the same result for every path shape Gym builds; the only behavior changes are the 400 for an invalid capture key and the name inserted into caller-prefixed paths, both covered above.
Compatibility
ROLLOUT_ID_PATTERN(^[A-Za-z0-9][A-Za-z0-9._-]*$) are refused with 400 by every Gym server. Gym never builds such keys;maybe_rollout_id_from_run_bodyalready rejects them.ServerClientadds the context's agent instance name to caller-prefixed model generation paths.🤖 Generated with Claude Code