Skip to content

feat: add SWE Pro resources sessions - #3488

Closed
ananthsub wants to merge 1 commit into
ananthsub/episode-orchestration-06-single-agent-processorfrom
ananthsub/episode-orchestration-07-swe-pro-sessions
Closed

ananthsub wants to merge 1 commit into
ananthsub/episode-orchestration-06-single-agent-processorfrom
ananthsub/episode-orchestration-07-swe-pro-sessions

Conversation

@ananthsub

@ananthsub ananthsub commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds native session support to SWE-bench Pro while preserving its legacy request shapes. The Resources Server owns task sandbox setup, verification, and cleanup.

Single-agent interaction flow

This diagram shows the built-in single-agent use case. Other Environment Server protocols may coordinate different participants and use different request, result, and lifecycle flows.

sequenceDiagram
    participant C as Rollout collector
    participant E as Environment Server
    participant R as Task / Resources Server
    participant A as Agent Server
    participant M as Model Server
    participant S as Task sandbox

    C->>E: POST /run
    E->>R: Seed task session
    R-->>E: Tool access and optional SandboxAccess
    E->>A: Seed agent session
    A->>S: Connect as borrower when supplied
    E->>A: Invoke /v1/responses
    A->>M: Model and capture requests
    A-->>E: Agent response
    E->>A: Close agent session
    E->>R: Verify response
    E->>R: Close task session
    E-->>C: Episode result
Loading

The Environment Server coordinates ordering and the final result. Agent and Task/Resources Servers retain ownership of the state and resources they create.

This is part 9 of 13 in the Environment Server stack. Previous: #3487. Next: #3714.

Validation

  • uv run pytest resources_servers/swebench_pro/tests/test_app.py -q

Rollouts

See the final PR for end-to-end rollout evidence.

Compatibility and benchmark impact

Legacy SWE-bench Pro callers remain supported.

Repeated native verification

A native verify now fails when its task sandbox has already been consumed instead of evaluating an empty patch and returning a normal-looking reward. The regression test performs one successful native verification and confirms that the second request fails.

@copy-pr-bot

copy-pr-bot Bot commented Sep 17, 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.

@ananthsub
ananthsub added this pull request to stack #3493 September 17, 2026 16:31
@ananthsub ananthsub changed the title ananthsub/episode orchestration 07 swe pro sessions feat: add SWE Pro resources sessions Sep 17, 2026
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-07-swe-pro-sessions branch 3 times, most recently from 1cce5b4 to d6eb57c Compare September 18, 2026 00:55
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-07-swe-pro-sessions branch from d6eb57c to 3dee913 Compare September 18, 2026 01:06
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-07-swe-pro-sessions branch from 3dee913 to d1d9fd7 Compare September 18, 2026 01:32
@ananthsub
ananthsub marked this pull request as ready for review September 18, 2026 19:45
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team September 18, 2026 19:46
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-07-swe-pro-sessions branch from d1d9fd7 to 63d20d5 Compare September 18, 2026 20:44
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-07-swe-pro-sessions branch from 9d3bf88 to 0e7a924 Compare September 18, 2026 22:37
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-07-swe-pro-sessions branch from 0e7a924 to 8e9421b Compare September 18, 2026 22:42
@yaoyu-33 yaoyu-33 added area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Sep 18, 2026
@ananthsub
ananthsub force-pushed the ananthsub/episode-orchestration-07-swe-pro-sessions branch from 8e9421b to 055a802 Compare September 19, 2026 01:02

@marta-sd marta-sd 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.

LGTM, added some minor clarifying questions


def setup_webserver(self) -> FastAPI:
app = super().setup_webserver()
app.post("/close_session")(self.close_session)

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.

Shouldn't we add it to the base class with abstract self.close_session?

print(
f"Failed to setup anti-cheating for {body.instance_id}. Return code: {result.return_code}\n"
f"Stdout:\n{result.stdout}\nStderr:\n{result.stderr}"
await previous.stop()

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.

To make sure I understand correctly: we're removing the try-except block to capture the failures on the env server side?

await self.normalize_sandbox_environment(sandbox, body.instance_id)
self._session_id_to_pristine_untracked[session_id] = await self.pristine_untracked_files(sandbox)
if result.return_code != 0:
print(

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.

And here we keep the old behavior - print and move on if this fails?

) -> SWEBenchProSeedSessionResponse:
self,
request: Request,
body: SWEBenchProSeedSessionRequest | ResourcesSeedSessionRequest,

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.

Should be deprecate the SWEBenchProSeedSessionRequest + SWEBenchProSeedSessionResponse path?

Comment thread resources_servers/swebench_pro/app.py Outdated
async def verify(
self,
request: Request,
body: SWEBenchProVerifyRequest | ResponsesResourcesVerifyRequest,

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.

Same here: should we deprecate SWEBenchProVerifyRequest?

Comment thread resources_servers/swebench_pro/app.py Outdated
raise ValueError("resources_session_id does not match the session cookie")
identity = self._session_id_to_identity.get(session_id)
if identity is None:
raise ValueError(f"Unknown resources session: {session_id}")

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.

Closing the same session twice returns 200 then 500 (Unknown resources session). If a close succeeds but its response is lost, the transport retry turns an otherwise successful episode into a cleanup failure. Could repeated closes for the same episode succeed while retaining identity checks?

Comment thread resources_servers/swebench_pro/app.py Outdated
await sandbox.stop()
raise

self._session_id_to_task[session_id] = task

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.

This also retains task data for legacy seed calls, but legacy /verify never removes it and legacy callers do not call /close_session. I reproduced a successful seed/verify leaving the full task cached after the sandbox was released, so memory grows with completed sessions. Could we store this only for native sessions?

Signed-off-by: Ananth Subramaniam <[email protected]>
@ananthsub

Copy link
Copy Markdown
Contributor Author

Closing to recreate the remaining Environment Server work as one correctly ordered GitHub Stack. Branch commits are preserved; a replacement PR will follow.

This branch was previously deployed

1 inactive deployment
public — 02b85d2d Deployed Sep 28, 2026 by copy-pr-bot[bot] via release / finalize / notify #3712
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 complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer 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.

3 participants