Skip to content

fix(agent): restore shell in sandbox-less hosts and stabilize prompt prefix - #742

Closed
delete-cloud wants to merge 4 commits into
mainfrom
fix/eval-shell-and-prefix-cache
Closed

delete-cloud wants to merge 4 commits into
mainfrom
fix/eval-shell-and-prefix-cache

Conversation

@delete-cloud

Copy link
Copy Markdown
Owner

Summary

Fixes two eval-blocking defects found in the 2026-09-17 benchmark run (6/30, 20%):

  • Shell dead in sandbox-less hosts: sandbox_mode=native requires bwrap; eval task containers ship without it, so bash_run failed closed (DeepSWE 0/9, all empty patches). Adds explicit env contract AGENT_SANDBOX_MODE / AGENT_SHELL_ADDITIONAL_ROOTS applied at the pipeline shell-config merge point, so hosts that already provide an isolation boundary (per-trial container + egress allowlist) can select none instead of silently degrading.
  • Prompt-prefix cache broken: volatile grounding (elapsed_seconds, approvals, runtime messages) was inserted before the last user message — position ~1 in headless runs — invalidating the whole prefix every call (7.5% cache hit vs 67–88% baselines). grounding_insert_index now appends at the message tail, keeping the conversation prefix stable.

Changes

  • coding_agent/tools/shell.py: env overrides at final config merge; invalid values still fail via _sandbox_mode().
  • agentkit/context/builder.py: grounding_insert_index() returns len(core_messages); incremental patch_messages bookkeeping (grounding_start/count) stays consistent under tail placement.
  • Tests: updated the two position-pinning tests; added env-override tests; new postmortem PM-0029.

Test plan

  • uv run pytest tests/agentkit/context tests/agentkit/test_incremental_context.py tests/agentkit/runtime tests/tools/test_shell.py — 246 pass
  • Manual smoke: AGENT_SANDBOX_MODE=none AGENT_SHELL_ADDITIONAL_ROOTS=/ + no bwrap → shell executes

Generated with Devin

delete-cloud and others added 4 commits September 18, 2026 00:56
…prefix

Two eval-blocking fixes:

- shell: honor AGENT_SANDBOX_MODE / AGENT_SHELL_ADDITIONAL_ROOTS env
  overrides at the pipeline shell-config merge point. Eval/benchmark
  containers ship no bubblewrap, so sandbox_mode=native failed closed and
  bash_run was dead. The env contract lets hosts that already provide the
  isolation boundary select "none" explicitly instead of degrading silently.

- context: append grounding blocks at the message tail instead of before
  the last user message. Grounding carries per-call volatile fields
  (elapsed_seconds, active approvals, runtime messages); at position ~1 it
  invalidated the whole prompt prefix for provider-side caching (7.5% hit
  rate vs 67-88% baselines). Tail placement keeps the conversation prefix
  stable; grounding remains part of the always-fresh tail.

Model: swe-2-max

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Review feedback (confer/codex): the env override wrote shell_config, but
_resolve_additional_workspace_roots prefers pipeline-level
additional_workspace_roots — including an empty list — so the env contract
was silently shadowed whenever pipeline roots were set. Resolve the env
list at the final precedence point instead so it wins over both config
layers. PM-0029 also records the system-merging-provider limitation
(anthropic/codex_responses hoist volatile grounding into instructions;
openai-compatible paths are unaffected).

Model: swe-2-max

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Review feedback (confer/grok): document that AGENT_SANDBOX_MODE /
AGENT_SHELL_ADDITIONAL_ROOTS are escape hatches for pre-isolated hosts
that disable the jail/path fencing, warn once when they take effect,
and trim grounding-position comments to the invariant (history lives in
PM-0029).

Model: swe-2-max

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Kimi's coding endpoint hard-rejects malformed tool history: a tool
message whose tool_call_id is absent from every assistant tool_calls
entry, or an assistant tool_calls message not immediately followed by
results for each call. Eval trials died on this at ~30 model calls.

Three defects produced those wire shapes:

- SummarizerPlugin.resolve_context_window could open the context window
  inside a tool_call/tool_result group (split at len - keep_recent),
  orphaning results whose calls were folded away. Boundaries now back
  off to the start of the enclosing group.
- tool_call entries and rejection tool_result entries were appended in
  one per-call loop, so an invalid mid-list call interleaved a result
  inside the call group, producing adjacent assistant tool_calls
  messages. All call entries are now appended before any rejection
  results.
- Streamed tool_call ids were captured only on the first delta per
  index. Providers emitting the id later (or never) yielded empty
  tool_call_ids. Ids are now updated on every delta and a stable
  fallback id is synthesized when none arrives.

Adds PM-0030 covering the failure class.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@delete-cloud
delete-cloud deleted the fix/eval-shell-and-prefix-cache branch September 20, 2026 10:56
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