Skip to content

feat: cloud-native runner + pod-native SWE-bench sandbox (run evals in Kubernetes) - #238

Open
almogtavor wants to merge 15 commits into
Exgentic:mainfrom
almogtavor:feature/kubernetes-runner
Open

feat: cloud-native runner + pod-native SWE-bench sandbox (run evals in Kubernetes)#238
almogtavor wants to merge 15 commits into
Exgentic:mainfrom
almogtavor:feature/kubernetes-runner

Conversation

@almogtavor

@almogtavor almogtavor commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What

First-class support for running exgentic evaluations inside a Kubernetes cluster, so the eval lifecycle no longer has to live on a laptop driving a remote endpoint over port-forward. vLLM (or any model endpoint) becomes just another in-cluster Service. Two small, orthogonal pieces - neither needs privileged:

1. KubernetesRunner (runner="kubernetes")

A cloud-native sibling of DockerRunner. with_runner(cls, runner="kubernetes", ...) creates a ConfigMap + Pod + ClusterIP Service running exgentic serve, waits for /health, and returns the same ObjectProxy over the same HTTPTransport - nothing in the programming model changes; the object just lives in a Pod.

  • Manifests are applied with kubectl apply as JSON, so it adds no dependency (no PyYAML, no kubernetes client).
  • Reachable over in-cluster DNS (<svc>.<ns>.svc.cluster.local) when the orchestrator runs in-cluster, or kubectl port-forward from a laptop (port_forward=True).
  • Registered like the other runners: dispatch branch, RunnerName, settings (EXGENTIC_KUBERNETES_*), runner_mixin. Per-instance teardown and imagePullSecrets included.
  • Deliberately thin: no container-runtime concerns live in the runner.

2. Pod-native SWE-bench sandbox (SWEBENCH_SANDBOX=kubernetes)

A docker-free, non-privileged backend for SWE-bench. Each task's environment becomes its own Pod, built from the SWE-bench instance image:

  • KubernetesEnvironment mirrors minisweagent's DockerEnvironment (docker exec -> kubectl exec), so the agent loop is unchanged - the only contract is execute(command, cwd) -> {"output", "returncode"}.
  • Grading runs SWE-bench's own eval script (make_test_spec(...).eval_script) inside the same Pod and parses with SWE-bench's own get_eval_report - same tests, same parser, just kubectl exec instead of the docker harness.
  • The instance image runs as root under the anyuid SCC: no privileged, no DinD, no docker socket. Each per-task Session is its own Pod (clean isolation, natural parallelism).

Why

Running a large batch of SWE-bench experiments, I needed the orchestrator + agents to run in-cluster rather than on a laptop: VPN / port-forward drops were surfacing as model-server 5xx and killing long runs. This keeps the whole run in the cluster.

Testing

  • KubernetesRunner round-trip validated live on OpenShift: manifest -> exgentic serve -> /health -> transport call -> cleanup (trivial Calculator, with imagePullSecrets pull and per-instance teardown).
  • Pod-native SWE-bench sandbox is under live validation on the same cluster (gemma served in-cluster); will update with results.

Out of scope (follow-up)

A generalized non-privileged Pod sandbox backend for arbitrary docker_socket=True benchmarks (beyond SWE-bench).

…bench)

Adds runner="kubernetes": launches `exgentic serve` as a ConfigMap+Pod+Service
(kubectl apply, JSON manifests, no PyYAML/k8s-client dep) and returns the same
ObjectProxy over HTTPTransport as DockerRunner. Reach the service via in-cluster
DNS or a kubectl port-forward (port_forward=True) when driving from a laptop.

SWE-bench / docker_socket=True benchmarks get an in-pod container runtime so the
existing sibling-container + run_evaluation code runs unchanged: rootless podman
(sandbox="podman", default) or a privileged docker:dind sidecar (sandbox="dind").

Registered in with_runner() + both RunnerName Literals; runner_mixin maps the
docker host-bind output volume to a shared PVC via new EXGENTIC_KUBERNETES_* settings.
…etesRunner (superseded by pod-native SWE-bench sandbox)
… grading so the session score records resolved
Three changes so the slower middleware (span/full-recompute) modes get a fair,
fully-graded run instead of being cut off:
- pod TTL decoupled from the per-command timeout (SWEBENCH_POD_TTL, default 4h):
  the task pod must outlive the whole session so end-of-session grade_in_pod can
  still kubectl-exec in. Previously the pod slept for one command timeout and
  expired mid-session, silently leaving capped tasks ungraded.
- litellm request timeout 180 -> 600 (EXGENTIC_LITELLM_TIMEOUT): a cold span/
  full-recompute deploy's first call (warmup prefill) ran past 180s and failed
  with 'Model not accessible: TimeoutError()' at step 0.
- max_interactions 200 -> 1000 so a 500-step run is bounded by the step cap.
gemma-4 and reasoning models can collapse into re-issuing the identical tool
call indefinitely (vLLM #40080); sampler penalties only partially help. Track
the (name, arguments) signature per turn and, after 3 identical calls in a row,
append a nudge to the next tool result so the model gets different feedback and
takes a new action. Self-resets after nudging; a different call resets the count.
A bash-only agent has to edit source via heredocs/sed, which weaker models
(gemma-4) get wrong - so they default to re-running the reproduction forever
instead of editing. Add the standard SWE-bench editor seam (view, create,
str_replace) to the benchmark action registry so any agent (tool_calling
included) gets reliable, patch-captured edits. All routed through the existing
sandbox via base64 to avoid shell-quoting fragility; str_replace enforces a
unique match and errors clearly otherwise.
When the identical (name, arguments) tool call repeats _max_repeated_tool_calls
times in a row, react() refuses to execute it: inject a synthetic blocked tool
result and re-query the model in-place so it must choose a different action.
After _max_hard_block_retries unproductive re-queries the session ends. Replaces
the soft nudge, which gemma-4 ignored (vLLM #40080).
SWE-bench instance images own /testbed (repo + .git) as root. The kube_sandbox
pod set no runAsUser, so OpenShift assigned a random uid that could not write the
root-owned source AND tripped git's dubious-ownership guard -> generate_patch
(git add -A && git diff) returned empty and correct fixes were silently scored 0.
Force runAsUser=0 (exgentic-task SA has anyuid) + add safe.directory '*' belt.
Old SWE-bench repos (astropy) rebuild editable via setuptools.dep_util, removed in
setuptools>=70. When the grading env has a too-new setuptools the rebuild + conftest
import fail silently and pytest collects nothing -> every FAIL_TO_PASS marked failed
even when the fix is correct (astropy-12907's correct fix was scored 0). Prepend a
guard to /eval.sh: activate testbed, set PIP_CONSTRAINT, and pip install setuptools<70
only when dep_util is missing (no-op otherwise). Verified: 6/6 test_separable pass.
…ponses

The hard-block only catches repeated identical tool calls. When the model
degenerates into text-only responses (no tool call) - each answered with
'Sending a message is not allowed' - it loops forever. Cap consecutive
no-action responses (_max_consecutive_messages=5) and end the session.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant