feat(scripts): generalize collect_trajectories.py to all task envs#25
Open
SourasishBasu wants to merge 1 commit into
Open
feat(scripts): generalize collect_trajectories.py to all task envs#25SourasishBasu wants to merge 1 commit into
SourasishBasu wants to merge 1 commit into
Conversation
Adds task profiles (postgres / notebook / type-checker / libexpat) so the trajectory collector can be pointed at any env via --task. Postgres defaults are preserved bit-for-bit (image, episode/message timeouts, container prefix, base port) so the existing PG flow is unaffected. New CLI flags: --task, --runtime (auto-detects docker/podman), --image, --base-port, --container-prefix. Also patches openenv-core's WebSocket client at runtime to disable the keepalive ping. The agent can run a single turn for >10 minutes without yielding back to the WS event loop, which starves pong replies and kills the connection mid-episode (1011 keepalive ping timeout). Patch is guarded by an assertion so it fails loudly if openenv-core's layout changes — TODO to remove once ping_interval/ping_timeout kwargs are exposed upstream. Verified end-to-end across all four reward shapes; trajectories at artifacts/trajectories-2026-04-26.zip locally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
TASK_PROFILESsoscripts/collect_trajectories.pycan target any of the four envs (postgres,notebook,dependent-type-checker,libexpat-to-x86asm) via--task. Postgres defaults are preserved verbatim — the existing PG flow is unaffected.--task,--runtime(auto-detectsdocker/podman),--image,--base-port,--container-prefix. All optional with backward-compatible defaults.openenv.core.env_client.ws_connectto injectping_interval=None. Without this, long single-turn agent bursts (>20s of WS silence) trip thewebsocketslibrary's keepalive and kill the episode mid-flight with1011 keepalive ping timeout. Guarded by anassert hasattr(...)so it fails loudly if upstream layout changes.TODO: remove onceopenenv-coreexposesping_interval/ping_timeoutkwargs and we bump the pin inpyproject.toml..gitignore: addsartifacts/so trajectory outputs stay local.Test runs
All four reward shapes verified end-to-end on 2026-04-26. Trajectories archived locally at
artifacts/trajectories-2026-04-26.zip(285 KB) — happy to share on request.pi_session.jsonlnotebookreward_jsondependent-type-checkerreward_json_scorelibexpat-to-x86asmreward_json_scorepostgresratioNotebook verification (
reward_json, server-computed)3 turns, 254 tool calls, 33 min wall.
plan_score = 0.667, S1=0.840, S2=0.000 (agent burned both attempts), S3=0.8150.25·0.667 + 0.60·(0.84+0+0.815)/3 + 0.10·1.0 + 0.05·1.0 = 0.6477≈ server's 0.6476 ✓Session timeoutwarnings without losing the WS — the keepalive monkey-patch is doing its job.Type-checker verification (
reward_json_score, offline backfill)2 episodes, both reached
phase=EXECUTINGthen offline-backfilled by_compute_reward_offline()._reward_backfilled: trueflag set on both. Demonstrates the script correctly distinguishes server-computed vs. backfilled rewards.Libexpat verification (
reward_json_score, offline backfill)1 episode, single subtask
impl-libexpatscored 0.21, plan_score 0.43, reward 0.3843 — formula reproduces.Caveats
🤖 Generated with Claude Code