Repository navigation
Conversation
An agent session gets its initial model input and its grants, but no task data. Harnesses that build part of their input from the task row, such as gdp_pdf_agent's document manifest, labbench2_vlm_agent's media directory and CritPt's formatting prompt, had no supported way to receive it under single_agent_turn. A task row now carries that data in a reserved agent_context key: small inline values (at most 64 KiB) and artifact references, paths relative to a root the agent configures. SingleAgentTurnTaskInput lifts it out of task_data, so the Resources Server never receives it, and single_agent_turn passes it in AgentSeedSessionRequest.agent_context, omitted when empty. Each agent declares the keys it reads in agent_context_model. The base seed refuses with a terminal 422 a context the agent declares no model for, an undeclared key, a missing required key or a mistyped value, so a task never runs without data it was given. Agents read the typed context with parse_agent_context() and resolve artifacts with resolve_agent_context_artifact(), which refuses paths that leave the root. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
…idation A server's TaskData schema validates the task-owned fields of a row and reports unknown keys. agent_context goes to the agent session, never to the Resources Server, so it joins RESERVED_ROW_KEYS instead of showing up as an unknown task field. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
…tate An agent whose task context lives in its session state, such as a document or media to put in the model request, had to override responses() to reach that state from the episode it creates. Environment validation then infers custom-gym-agent-loop for it, though the agent loop is still Simple Agent's. responses() now creates a session activation's episode through _create_session_episode(state, body, **kwargs), which by default calls _create_episode. A subclass overrides it to use the session's context and leaves responses() and the agent loop alone. The sessionless path is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
…ssions Signed-off-by: yaoyu-33 <[email protected]>
…erifier - Refuse an artifact path with a NUL byte at validation, and turn a path the filesystem cannot look up (name too long, no permission) into a 422 seed refusal instead of a 500; other OS errors stay retryable. - Count the 64 KiB values limit in UTF-8 bytes, not ASCII-escaped JSON. - Treat an empty agent_context as none in the task input and the seed, so the seed and task digest match a row without the key and an agent server that predates the key still accepts the seed. - Skip a task_data container's agent_context in dataset validation, as the task input lifts it out. - single_agent_turn_legacy: answer a row that fails the episode request model with the typed /run's 422. - Re-verification no longer sends a stored agent_context to the Resources Server's /verify. - Docs and helper docstring: a Simple Agent subclass resolves context in _new_session_state (restores rebuild through it) and overrides _create_session_episode, never responses(); configure the real directory as the root; files under a directory artifact are the agent's to confine. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
scicode_agent overrides run(): it builds each sub-step's prompt from the row, calls the model once per sub-step, then sends solutions, step_usage and token_usage_version to /verify as top-level fields. single_agent_turn could not drive it, and its benchmark metrics lived on the agent, which an environment server does not ask. The agent now serves agent sessions. It reads the problem's prompt material from the row's agent_context (problem_id, sub_steps prompt fields, required_dependencies, prefilled_steps_code) and runs the same step loop inside one /v1/responses activation. The loop is shared with run(), so both paths send the model the same requests. The response carries solutions, step_usage and token_usage_version under "scicode"; the session's model calls are returned as agent observations at close. The scicode resources server reads those fields from the response when the request has no top-level solutions, and drops them from the echoed response. It now owns compute_metrics, get_key_metrics and the aggregate_metrics token-suppression override. The agent's /aggregate_metrics forwards to it, so the relay and an environment server report the same metrics. benchmarks/scicode/prepare.py writes agent_context into each row, and the example rows carry it. The new scicode_single_agent_turn.yaml runs the pairing through single_agent_turn_legacy beside scicode.yaml, which keeps the relay. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Contributor
Author
|
/ok to test b90b1ba |
Contributor
… payload An agent session now records each generated sub-step's model call as it completes. Before, a model error at a later sub-step closed the session with no model calls, so the trajectory lost the calls that had been made and captured. /run no longer forwards the row's agent_context to /verify: the payload keeps its shape from before agent_context existed. prepare.py leaves out an agent_context over the 64 KiB limit and says which problem; that row still runs through /run. A retry of the activation through another path than the first one is refused. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Contributor
Author
|
/ok to test 92e3ea4 |
…rity - /verify fails, instead of grading nothing, when the response's `scicode` field carries no solutions dict: only a broken agent sends one, and grading it scored an empty answer and dropped the row's sub-steps from subtask_accuracy. A response without the field grades as before. - Tests: the session parity test now carries the task's sampling settings (a session that dropped them passed before); top-level solutions win over the response field; a seed with a required tool is refused; a replay with other settings is refused without rerunning the loop; a problem with no generated step closes with no invocation; the committed example rows' agent_context parses as the agent's context model. - prepare counts the problems it writes without agent_context. - Docs: the benchmark README says the resources server computes the metrics and that rows carry agent_context; the server README and the session config say the two paths' rewards match whenever verification runs and succeeds, and name the two differences; the lift's docstring says rows keep no solutions, like /run's. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Contributor
Author
|
/ok to test a7bdbb3 |
… sub-steps Every rollout row now keeps the `solutions` it was graded on, so the server's stateless re-verify grades a success row again instead of an empty answer. /verify refuses a request without solutions, and solution keys or step_usage step numbers that are not the row's sub-steps (an agent session whose agent_context disagrees with the row), instead of scoring the model 0. A failed rollout that count_failure_classes_as_zero adds (no response, no token accounting) now leaves token usage incomplete instead of failing /aggregate_metrics with a version mismatch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: yaoyu-33 <[email protected]>
Contributor
Author
|
/ok to test 4bf57ee |
This branch was previously 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
scicode_agentoverridesrun(). For each sub-step it builds a prompt from the row'ssub_steps, calls the model, and accumulates the extracted code. It then sendssolutions,step_usageandtoken_usage_versionto/verifyas top-level fields. Because of that,single_agent_turncould not drive it. Its benchmark metrics also lived on the agent, which an Environment Server never asks for them. This PR moves the loop into the agent's session activation and moves the metrics to the resources server.scicode_agentAGENT_SESSION_AGENT_TYPES.agent_context, using the channel feat(agents): deliver per-task agent context to agent sessions #5703 adds. The material isproblem_id,sub_steps(each step's number, description, background, function header and return line),required_dependenciesand optionalprefilled_steps_code./v1/responsesruns the sub-step loop in a single activation.run()and the session share the same loop, so both send the model the same requests. Context-window handling and per-step usage accounting are unchanged.solutions,step_usageandtoken_usage_versionride underscicode./runemits onmainsince fix(scicode): record trajectory and model calls so rollouts are observed #4468, which fix(scicode): emit policy trajectory for rollout health #4087 also targets./aggregate_metricsnow forwards to the resources server, so the relay path reports what an Environment Server reports.resources_servers/scicode/verify. It readssolutions,step_usageandtoken_usage_versionfrom the response'sscicodefield when the request has no top-levelsolutions, and drops that field from the echoed response. Scoring of a well-formed answer is unchanged.solutionsit was graded on, so the server'sREVERIFY_MODE = statelessholds: a re-verify grades the saved answer again. Before, a success row dropped them and a re-verify graded it 0.solutions(for example a row saved before rows kept them);scicodefield without a solutions dict;step_usagestep numbers that are not the row's sub-steps (an agent session whoseagent_contextdisagrees with the row).compute_metrics,compute_repeat_metrics,get_key_metricsand theaggregate_metricsoverride, all moved verbatim from the agent:subtask_accuracy;step_usage;count_failure_classes_as_zeroadds (no response, no token accounting) now reportstoken_usage_complete: falseand no token totals. Before, it failed/aggregate_metricswith a token accounting version mismatch.step_usage,num_steps_*), neverng_perf, so they follow fix(eval): aggregate execution metrics in the environment server #5455's split: the Environment Server reduces execution metrics, and the resources server keeps benchmark scoring.Data and config
benchmarks/scicode/prepare.pywritesagent_contextinto each row throughscicode_agent_context(row). The committed example rows carry it, and are otherwise byte-identical./rundoes not forward the row'sagent_contextto/verify, so its payload keeps its old shape.resources_servers/scicode/configs/scicode_single_agent_turn.yamlruns the pairing throughsingle_agent_turn_legacy. It sits besidescicode.yaml, which keeps the relay, and uses the same instance names.agent_context, as with the other feat(agents): deliver per-task agent context to agent sessions #5703 consumers.Training trajectory. Like
/run, the response holds the final sub-step's output. Each sub-step's model call is captured under the rollout path and listed in the agent's observations.No public issue tracks this; this description is complete.
Validation
pytest resources_servers/scicode/tests benchmarks/scicode/tests: 149 passed._build_verify_payload, is graded again to the same reward, step results and solutions.solutions, the sub-step check, or the counted-row handling each fails its new tests.tests/test_metrics.pyholds the metric tests moved from the agent, rebuilt on rows shaped as/verifyreturns them.scicodefield equals a verify of the/runbody, and the field leaves the echoed response.preparewrites only the prompt material intoagent_context, and leaves out an oversize one.pytest responses_api_agents/scicode_agent/tests: 53 passed. The added test checks that withskip_verificationthe agent reports no metrics and never calls the resources server.TestAgentSessionsseeds a session through the agent's app and runs one activation under the rollout path. It covers three cases: plain, prefilled first step, and context window exceeded mid-problem. The task carries sampling settings (temperature, top_p, max_output_tokens, model). In each case, the policy gets the same requests as/run's, and the response carries exactly/run'ssolutions,step_usage,token_usage_versionand response. The close returns the generated steps' model-call refs./run's verify payload carries noagent_context.PYTHONPATH.pytest tests/unit_tests/config/test_global_config.py tests/unit_tests/environment/test_environment_validation.py tests/unit_tests/test_session_contract_repo.py tests/unit_tests/data/test_task_data.py: 746 passed, 1 failed.test_agent_without_rs_reference_and_no_schema_is_skipped. It fails the same way on untouchedmainwith this local setup.pytest tests/unit_tests/eval/test_rollout_reverification.py environment_servers/single_agent_turn_legacy/tests/test_app.py: 273 passed.pytest tests/unit_tests -k "scicode or session or agent_context or reverif": 1369 passed, 0 failed. Five modules did not collect because this local venv lacks their dependencies (exporters, speed_bench); none are touched here.gym env validatepasses forscicode.yaml,scicode_single_agent_turn.yamlandbenchmarks/scicode/config.yaml.pre-commit run --files <changed files>passes.app.pyagainst the same mocked servers./runsent byte-identical model requests, cookies, verify payload and result, includingng_trajectory. The review's findings are fixed in the second commit or listed under Compatibility.Rollout evidence
Scripted-model smoke (no real model).
gym env start+gym eval run --no-serveon the 5 committed example problems, once withscicode.yaml(relay) and once withscicode_single_agent_turn.yaml.test_data.h5. Every scored step therefore executed and failed withexit:1(reward 0), on both configs and unmasked.step_usage,step_results,scored_step_ids,step_exits,num_steps_*, response usage and reward. One problem has 11 sub-steps; the others have 1./aggregate_metricsto the resources server, and the session path's Environment Server forwarded it there too. The key metrics were identical:subtask_accuracy0.0,generation_coverage1.0,token_usage_completetrue,mean/output_tokens_per_problem36.agent_context→ one activation → agent close →/verify→/close_session. Each close returned one invocation whose model-call refs were exactly the generated steps' calls (11 for the 11-step problem). No server process was left after teardown./runmasks a failed/verifyasjudge_failed, while the session path reports the Environment Server's standard verification failure.Pending. A real-model smoke with the real
test_data.h5, and model-call capture to check the trajectory join and token capture per sub-step. Commands (policy settings inenv.yaml):gym env start --config resources_servers/scicode/configs/scicode_single_agent_turn.yaml --model-type vllm_model \ ++scicode.resources_servers.scicode.test_data_fpath=/abs/path/to/test_data.h5 gym eval run --no-serve --agent scicode_agent --input resources_servers/scicode/data/example.jsonl \ --output results/scicode_session_smoke.jsonl --num-repeats 1 --temperature 0.0Then repeat with
--config resources_servers/scicode/configs/scicode.yaml(the relay) and compare per-problemstep_results,step_usageand reward.Compatibility and overlaps
Relay configs and benchmark scores. No change to the relay configs. The model requests and grading are unchanged, so benchmark scores should not move.
Where the two paths differ. These come from
single_agent_turn, not this PR; the reward is the same whenever verification runs and succeeds./run, a failed/verifybecomes a maskedjudge_failedrow that can be regraded from its savedsolutions. On the session path it is the Environment Server's verification failure.skip_verification./runignores it and always verifies. The Environment Server honors it.Rows and re-verify. Rows grow by their
solutions. Each solution holds the code of every earlier sub-step, so a row grows with roughly the square of its sub-step count: tens of KB for most problems.record_step_codestays a separate opt-in, which copies the same code into each step record. Re-verifying a SciCode rollout file saved before this change now fails verification for its success rows, because they carry no solutions; before, it silently graded them 0.Verification refusals. A missing or mismatched answer now fails verification instead of scoring 0. On
/runit becomes a maskedjudge_failedrow. On the session path it is the Environment Server's verification failure, which is not terminal, so a dataset whoseagent_contextdisagrees with its rows reruns until the retry budget runs out. No current caller sends such an answer.Reverification metrics. Reverification posts
/aggregate_metricsstraight to the resources server, so it now gets the SciCode metrics (for SciCode and SciCode-Verified) instead of the generic ones.SciCode-Verified data.
benchmarks/scicode_verifiedhas its own prepare script, which does not writeagent_contextyet. That is needed before its session path can run.Direct callers. Anything that called
ScicodeAgent.compute_metrics/get_key_metricsdirectly must call the resources server's instead.Known limits, not changed here:
subtask_accuracydenominator. Its sub-step count depends on the agent's prefilled-step table (step_utils.PREFILLED_STEPS_CODE), which the resources server cannot see. This was already true when the metrics lived on the agent.CI on a7bdbb3. The failures are flakes:
test_process_supervisor.py::test_only_detached_services_survive_harness_group_termination: a/proc/<pid>/statread raced a process exit.test_worker_stop_checkpoints_partial_work_before_hard_cleanup[deadline-True]: passed on rerun.instruction_following.This PR touches none of these files.
Overlapping open PRs. fix(scicode): use a pinned scientific grading environment #4892 and fix(scicode): require sub-step programs to reach their tests before passing #4946 also edit
resources_servers/scicode(grading environment and runner). Whichever merges second rebases its README and test changes.🤖 Generated with Claude Code