Skip to content

test(platform): check each harness's context window, compaction and tool calling #5417

Open

Description

@yannickmonney

Summary

Pi had two defects, both fixed on main:

  • Context window. Tale staged Pi's model by id alone, so Pi took 128,000 tokens for every gateway model. Pi caps each answer at that window minus its estimate of the conversation, and compacts only near it. A conversation of a larger model past about 124,000 estimated tokens got one-token answers and ended as empty_turn. Fixed by fix(platform): give agents on Pi the model's context window #5416 (squash commit 4368a0fb6).
  • Tool channel. Pi was staged without MCP, so its agents could not reach the workspace tools their instructions named. Fixed by e5a3243c2, which is an ancestor of main.

The other runtimes have not been checked for the same things. This ticket asks for that check across every runtime Tale supports, on three points: the context window each one is given, when it compacts, and whether its tools reach the model. It proposes no fix. Anchors below are from origin/main at 4368a0fb6.

What the repo says today

Nine runtimes, plus the Claude Code (compact prompt) variant (claude-code/harness.yml:19). Paths are configs/platform/system/harnesses/<runtime>/harness.yml.

Runtime Window Tale gives it Compaction Tool channel (capabilities.mcp)
Claude Code Catalog window as CLAUDE_CODE_AUTO_COMPACT_WINDOW, managed only (:158, :204), and only below 200,000 (:208-209). Every session defaults to 1M (:82-83). CLI auto-compaction, retuned by that variable (:188-204) Yes (:38)
Claude Code (compact prompt) Same file (:19); not examined separately Same Yes
Pi Catalog window as contextWindow in the managed models.json (:82, :102). An unknown window leaves the key out, so Pi's own default of 128,000 applies. Pi's own, against the staged window (:90-95) Yes (:42); exposure: direct, no call timeout (:103-124)
OpenClaw Fixed contextWindow: 200000 and maxTokens: 32000 for the managed gateway model, whatever its catalog window (:129-130) Not set here; not examined Yes (:38); 60 s call limit, handled by bridgeCallTimeout (:145-147)
Codex None Codex compacts its own history (:124) Yes (:38), as mcp_servers config pairs (:138-141)
Gemini CLI None resume: false: each later kick is a fresh conversation, because --resume replays tool results (:39-52). In-run compression not examined. Yes (:38)
OpenCode None; managed only (:1) Not set here; not examined Yes (:29); 60 s call limit, bounded by the server's timeout (:130-136)
Qwen Code None Not set here; not examined Yes (:44). No-argument tools fail on Anthropic Messages, so anthropicModels: false (:31-38)
Hermes None Not set here; not examined No (:32): "the exec facts mount none" (:29-31)
Cursor None Not set here; not examined No (:35); direct credentials only (docs/en/platform/agents/harnesses.md:22)

How the window moves, from the code:

  • A harness turn resolves its window in services/platform/backend/core/chat/external_turn_shared.ts:334-391, called from agent_run_host.ts:266 and agent_host.ts:1764. services/platform/lib/harnesses/exec-builder.ts fills ${model.contextWindow} only where a runtime names it (:238, :490-493). Only Claude Code and Pi name it. An unresolved window leaves the harness to size its conversation (external_turn_shared.ts:330-332).
  • services/sandbox-runtime and services/sandbox contain no window or compaction code. A grep for context window, compaction, auto-compact and context_length finds nothing.
  • The user docs describe a window or compaction only for Claude Code and Pi: docs/en/self-hosted/configuration/providers.md:112 and docs/en/platform/admin/governance/policies-and-limits.md:82.

What is already tested

  • Goldens pin each built exec (services/platform/lib/harnesses/fixtures/exec/*.yml). A window is pinned only for Pi (pi.yml:70), for OpenClaw (openclaw.yml, 200000), and for one managed Claude Code case (fixtures/exec/claude-code.yml:252-308).
  • Window values are unit-tested for Pi and Claude Code (exec-builder.test.ts:498, :971). A grep for "compact" across the platform tests, the harness code and the sandbox runtime finds no test that drives a conversation past its window.
  • Tool reach: services/platform/tests/integration/lib/bridge-reach.ts (header :11-15) and the Pi round trip, both added by e5a3243c2. Per that commit's message, each managed runtime gets the bridge tools to its model, Hermes gets none, and Pi calls workspace_status over the bridge. Read for their stated scope; not run for this ticket.

Constraints a check must respect

  • A result holds only for the runtime's pinned CLI version, which the harness comments name (for example qwen-code/harness.yml:36).
  • Use a model whose catalog window is not 32,768, 128,000 or 200,000, so each default stays distinguishable.
  • Read the staged config from the exec facts. A key must never reach a staged file or a log (pi/harness.yml:75-79).
  • Respect each runtime's credential path: OpenCode is managed only, Cursor is direct only.

What was not examined

  • No runtime was run live for this ticket.
  • Each CLI's own default window and compaction threshold at its pin, for Codex, Gemini, Hermes, Cursor, OpenCode, OpenClaw and Qwen Code.
  • Whether OpenClaw's 200,000 drives its compaction or only a request cap.
  • byo credential runs, beyond what the staged config says.
  • Gemini's compression within one run, and the window Codex assumes for a model it does not know.
  • Chat turns, which are not a harness. docs/en/platform/chat/basics.md:125 describes chat's own shortening of old results.

What would settle it

  1. Per runtime, with one model whose catalog window W is known: the window the CLI receives in its staged config is W, or the documented fallback.
  2. Per runtime, one long conversation past its compaction point, against a loopback stand-in model that reports W and logs each request's prompt size (pattern: bridge-reach.ts). Pass: the runtime compacts and keeps answering, with no one-token length answer and no empty_turn.
  3. For runtimes with resume: true: the compacted session resumes and answers.
  4. Per runtime, tool reach. Either the workspace tools are staged and listed to the model (declared, or found by tool search as OpenClaw does), and a call returns the platform's answer; or the runtime declares no channel and its instructions do not name the workspace tools (Hermes, Cursor).
  5. Long calls: a stand-in tool that runs 90 s, on OpenCode and OpenClaw, to see whether their 60 s limit cuts it.
  6. No-argument tool calls succeed on each runtime's wire. Qwen Code on an Anthropic-format model is refused today (anthropicModels: false).
  7. Claude Code (compact prompt): steps 1 and 2 again, since its built-in prompt is shorter.

Options (no preference)

  • Automated. Extend the goldens and the bridge-reach stub so each runtime's window is pinned and each request's prompt size is recorded. Needs the runtime images in CI.
  • Manual. One box per runtime per check in a manual suite under services/platform/tests/manual/, judged in a real round. Covers what a headless run cannot.
  • Policy first. Write down, per runtime, who sizes the window and when it compacts, as providers.md:112 does for Claude Code and Pi. Stage a window only where a runtime's CLI accepts one.
  • Audit first. A read-only pass over each pinned CLI's defaults, recorded in this issue, before any test is chosen.

These can be combined.

Questions for the owner

  1. Is OpenClaw's fixed 200,000 intended for every managed gateway model (openclaw/harness.yml:129), or a placeholder until the catalog window can reach it?
  2. Should a byo credential get the catalog window? Today Claude Code's variable is managed only (claude-code/harness.yml:158), and Pi's models doc is when: [managed] (pi/harness.yml:82).
  3. Are Hermes and Cursor meant to have no tool channel (mcp: false)? Do their instructions name workspace tools? That is the failure Pi had.
  4. Is "the runtime sizes its own conversation" an acceptable answer for Codex, Gemini, Hermes, Cursor, OpenCode and Qwen Code, or should each get a staged window where its CLI accepts one?

Related

Activity

  1. added
    needs discussion
    service: platform
    on Nov 7, 2026
  2. yannickmonney commented on Nov 10, 2026

    @yannickmonney
    ContributorAuthor

    Per-harness test notes

    Facts from origin/main at 4368a0fb6. Paths are under configs/platform/system/harnesses/<runtime>/harness.yml unless shown. The pin is the ARG in services/sandbox-runtime/Dockerfile. Nothing here was run live.

    For each runtime: credential lanes, what is staged for the window and compaction, resume, tool channel, what the tests already pin, and what a live check needs.

    Claude Code (CLAUDE_CODE_VERSION 2.1.285)

    • Lanes: managed and byo (:24-26). The compact-prompt variant runs the same CLI (:19).
    • Window: CLAUDE_CODE_AUTO_COMPACT_WINDOW takes the catalog window only for managed models, and only below 200,000 (:158, :188-209). Otherwise it is empty. The 200,000 gate keeps a Claude model's own 1M window (the [1m] marker) from being cut down to the catalog's 200,000.
    • Compaction: the CLI's own, retuned by that variable. The harness comment gives the arithmetic: an unknown model compacts near 167,000 prompt tokens; with 131,072 staged, near 98,000 (:188-204).
    • Resume: yes. The task host restates the current instructions on each resumed turn (:73-81).
    • Tools: yes, one --mcp-config with --strict-mcp-config (:117-126).
    • Tests: golden services/platform/lib/harnesses/fixtures/exec/claude-code.yml:252-308 (managed case, window 32768); unit exec-builder.test.ts:971-1045. No test runs a conversation past the window.
    • Live check: a managed model whose catalog window W is none of 32,768, 128,000 or 200,000. Confirm the variable equals W, then run past the compaction point against a stand-in. Also confirm the variable is empty at 200,000 and above.

    Codex (CODEX_VERSION 0.160.0)

    • Lanes: managed, byo (OpenAI key), and a ChatGPT subscription provider (:104-119).
    • Window: nothing staged. Codex's own assumption for an unknown model is not examined.
    • Compaction: Codex compacts its own history. The Tale instructions are recorded into the thread again only when it compacts (:121-131), so a resumed turn after compaction is the case to test.
    • Resume: yes, codex exec resume. The task host re-sends the whole current addendum at the start of each resumed turn (:121-131).
    • Tools: yes, mcp_servers.<id> config pairs (:134-141).
    • Tests: golden fixtures/exec/codex.yml. The parser is pinned to 0.160.0 (services/platform/lib/harnesses/parsers/codex-jsonl.ts:302). No window test.
    • Live check: the stand-in logs each prompt's size. Find the compaction point, then check that a resumed turn after compaction still answers.

    Cursor (CURSOR_AGENT_VERSION 2026.10.01-e373342)

    • Lanes: byo only, with CURSOR_API_KEY (:20-24).
    • Endpoint: the CLI has no OpenAI-compatible base-URL override (header :2-3). A loopback stand-in cannot receive its requests, so window and compaction can only be checked live, with a real key.
    • Window and compaction: nothing staged; not examined.
    • Resume: yes, --resume, with no instructions to restate (:52).
    • Tools: none. mcp: false (:35), and the composed instructions are dropped by design (:12-13). The agent sees neither Tale's instructions nor the workspace tools; only the task prompt reaches it.
    • Tests: golden fixtures/exec/cursor.yml. No tool-reach proof: the runtime image test covers managed credentials only.
    • Live check: does the task prompt name workspace tools? If it does, this is the Pi defect's shape (owner question 3).

    Gemini CLI (GEMINI_CLI_VERSION 0.62.0)

    • Lanes: managed, byo, and a Google-account credentials blob (:141-143).
    • Window: nothing staged. Compression within one run is not examined.
    • Resume: off (resume: false, :39-52). The pinned CLI's --resume replays tool results twice (gemini-cli #29365, open), so the first request of a resumed conversation that ran a tool is refused. Each later kick is a fresh conversation. The check is one long single run, not a resumed one.
    • Tools: yes, mcpServers in the staged settings (:121-127). Native web tools are denied on managed runs (:111-117).
    • Live check: one run past the stand-in model's window. Does the CLI compress and keep answering?

    OpenCode (OPENCODE_VERSION 1.18.34)

    • Lanes: managed only (:18-20).
    • Window and compaction: nothing staged; not examined.
    • Resume: yes, -s, with the current instructions (:42).
    • Tools: yes. The comment says OpenCode gives up on an MCP call after 60 s and sends no progress token, and that the server's timeout bounds its calls (:126-136).
    • Live check: a stand-in tool that runs 90 s. The comment predicts the configured timeout lets it finish; a live run confirms it. Image generation depends on this.

    OpenClaw (OPENCLAW_VERSION 2026.9.8)

    • Lanes: managed and byo.
    • Window: managed only. contextWindow: 200000 and maxTokens: 32000 are fixed for the gateway model, whatever its catalog window (:113-130). Byo gets none staged. The goldens pin 200000 in every managed case (fixtures/exec/openclaw.yml). Owner question 1.
    • Compaction: not set here. Whether 200,000 drives compaction or only a request cap is not examined.
    • Resume: yes, --resume, with the current instructions (:50). A resumed session restores only the messages.
    • Tools: yes, mcp.servers (:138-147). OpenClaw finds the workspace tools by tool search, which bridge-reach exercises. Its 60 s limit is handled by bridgeCallTimeout (:145-147).
    • Live check: the stand-in logs prompt size. Does it compact near 200,000 or elsewhere? And a 90 s tool call.

    Pi (PI_CODING_AGENT_VERSION 1.0.1)

    • Lanes: managed and byo. Byo resolves the model against Pi's own registry (:56-62), so its window is Pi's and is not examined.
    • Window: managed only. contextWindow in the staged models.json for tale-gateway, when the catalog knows the window (:82, :96-102). When it does not, the key is left out and Pi's 128,000 applies. Fixed by fix(platform): give agents on Pi the model's context window #5416 (4368a0fb6).
    • Compaction: Pi's own, against the staged window (:90-95).
    • Resume: yes, --resume, with the current instructions (:55).
    • Tools: yes, browser and bridge with exposure: direct and no call timeout (:103-124). Round trip: services/platform/tests/integration/lib/pi-bridge-round-trip.ts (Pi calls workspace_status).
    • Tests: golden fixtures/exec/pi.yml:70 (32768); unit exec-builder.test.ts:498.
    • Live check: the case the ticket started from. A long conversation past about W must give no one-token answer and no empty_turn, and models.json must carry W.

    Qwen Code (QWEN_CODE_VERSION 0.24.7)

    • Lanes: managed and byo (DashScope key, compatible-mode endpoint).
    • Anthropic models: anthropicModels: false (:31-38). No-argument tools fail on Anthropic Messages (400, bug(platform): Qwen Code on an Anthropic model fails every run with a 400 on tools.2.custom.input_schema #5353), so no Anthropic-format model should run here. Check that the gate refuses one.
    • Window: nothing staged. The inherited gemini-cli turn cap ends a run past it (:77); that is a turn limit, not a window.
    • Compaction: not examined.
    • Resume: yes, --resume, with the current instructions (:56).
    • Tools: yes, mcpServers (:88-93).
    • Live check: window and compaction as for Gemini, plus the Anthropic-gate refusal.

    Hermes (HERMES_AGENT_VERSION 0.19.0)

    • Lanes: managed, byo, and a Nous Portal subscription (:63-66).
    • Window and compaction: nothing staged; not examined.
    • Resume: yes, --resume, with the current instructions (:46).
    • Tools: none. mcp: false (:32), and the exec facts mount none (:29-31). The runtime image test asserts Hermes gets no bridge tools (e5a3243c2).
    • Live check: owner question 3. Do the composed instructions name workspace tools (the task tools, the knowledge pair, leases, image generation)? If they do, the Pi defect's shape applies.

    Cross-cutting

    • Stale pin in comments. Qwen 0.23.3 is cited at qwen-code/harness.yml:15, parsers/claude-stream-json.ts:394 and parsers/claude-stream-json.test.ts:636. The Dockerfile pins 0.24.7.
    • Stale fixture names. Each harness header names fixtures/exec/<runtime>.json; the goldens are .yml.
    • Window values for a live check must avoid 32,768, 128,000 and 200,000, the values a default would produce.
    • Not examined on any runtime: each CLI's own default window and compaction threshold at its pin, except where the comments state one (Claude Code).

    Status: nothing run live; no fix proposed. The four owner questions are unchanged.

  3. yannickmonney commented on Nov 14, 2026

    @yannickmonney
    ContributorAuthor

    Decision

    Rule. On every managed (gateway) lane, Tale tells the CLI the model's effective window, through whatever setting that CLI accepts. The effective window is the catalog window, narrowed by the organization's context limit. Claude Code keeps its documented exception: no variable at 200,000 and above, which protects the 1M window. Where the pinned CLI has no window setting, the harness comment and providers.md record who sizes the window, the CLI's fallback, and where it compacts, and a test enforces this. byo lanes keep the CLI's own model knowledge. A harness without a tool channel is never told about any workspace tool: knowledge tools, granted tools, the ask-human tool, project tools, image generation, host leases. One helper composes that guidance, and a guard test checks it. Proof is automated: goldens pin the staged window, and a new window-reach test runs each runtime against a loopback stand-in model with W = 49,152, past compaction and through a resume. Cursor gets manual boxes.

    Answers

    1. OpenClaw's fixed 200,000/32,000 is a defect. It now follows the effective window, with maxTokens = min(32,000, catalog max output, W/4). Today's values stay as the fallback for an unknown window, through a new default on $number.
    2. byo does not get the catalog window. The catalog entry describes the gateway's model, not the user's direct one.
    3. Having no tool channel is intended for now on Hermes and Cursor. But Hermes is told about tools it cannot call: the knowledge tools, granted tools, project tools, and in automations the ask-human tool via workspace_tool. All of it moves behind one helper gated on harnessMountsMcp. On such a harness, the agent is told to state a missing fact in its final answer and stop, never guess. The editor shows that tool grants have no effect there. Stored grants are kept, not refused or cleared. Cursor drops composed instructions by design.
    4. "The runtime sizes its own conversation" is not acceptable where the pinned CLI accepts a window setting. Where it accepts none, it must be documented with the CLI's fallback and covered by window-reach.

    Rationale. A wrong window ends long runs with one-token answers and empty_turn. An instruction that names a missing tool sends an agent after it, and on the ask-human path it may then guess a fact it should have asked for. Patching call sites one by one misses guidance; one helper plus a guard does not. Results hold only per pinned CLI version, so they rerun on every image build.

    Units (all on main)

    1. fix: one helper gates all tool-dependent guidance, including ask-human and project guidance, on harnessMountsMcp, with a guard test (M)
    2. feat: the editor shows tool grants as having no effect on Hermes and Cursor; stored grants are kept (S, after 1)
    3. feat: $number default and ${model.maxOutputTokens} (M)
    4. fix: OpenClaw follows the window, with a derived output cap (S, after 3 and 6)
    5. docs: audit each pinned CLI's window and compaction settings, with a guard; fix the stale Qwen 0.23.3 and .json references (M)
    6. test: window-reach stand-in for Claude Code, its compact-prompt variant, and Pi (L)
    7. fix: stage the window for Codex, OpenCode, Gemini, Qwen Code and Hermes where the CLI accepts one (L, after 5 and 6)
    8. test: 90 s and no-argument tool calls in bridge-reach, plus Qwen's Anthropic refusal (M)
    9. test: Cursor manual boxes and automation.md rows (S, after 4, 6, 7 and 8)

    Cross-issue amendments (decisions taken together with #4942):

  4. added
    agent-ready
    and removed
    needs discussion
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions