Repository navigation
test(agents): gate prompt and tool bytes on the Gateway, configured-agent and Codex routes - #206948
Conversation
…l bytes - Gateway WebChat turn and configured Telegram agent: system prompt and compacted tool definitions, built by the production attempt pipeline (tool base, bundle, catalog, prompt). - Codex app-server Telegram turn: model-bound layer text and dynamic tool specs from the happy-path snapshot. - Ceilings are main's measured bytes plus 5%, rounded up to 256 B; one table at the prompt manifest owner for the embedded routes, the Codex pair beside its snapshot test.
- The configured Telegram route records bootstrap complete; the fresh WebChat route keeps it pending. - Pin docs and source paths, which the prompt contains. - Count every non-json Codex layer fence so a relabeled layer still counts. - Ceilings: WebChat prompt 14,336 B, Telegram prompt 14,592 B.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: passed. What this changesThis PR adds prompt and tool byte ceilings for embedded WebChat, configured Telegram, and Codex snapshot routes. Example: A contributor increases the embedded WebChat tool definitions to 19,944 bytes.
Review scores
ProductKind: Test only · Worth it: Yes Merge readiness✅ Ready for maintainer review Keep this maintainer-authored PR open: it adds useful byte-growth gates absent from main, and inspection found no definite introduced defect. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherAgent preparation builds prompts and compacted tools from session, configuration, and workspace facts; these tests measure selected outputs before transport serialization. flowchart TD
A[Session and workspace fixtures] --> B[Embedded tool preparation]
B --> C[Compacted tool catalog]
C --> D[System prompt preparation]
C --> E[Embedded byte gates]
D --> E
F[Codex snapshot generator] --> G[Codex byte gates]
Technical reviewBest possible solution: Retain the focused gates at existing preparation and snapshot owners, preserving their explicitly bounded coverage. Do we have a high-confidence way to reproduce the issue? This is additional test coverage rather than a runtime bug fix; source verifies the ungated surfaces, and the author reports synthetic growth failures without an independent execution in this read-only review. Is this the best way to solve the issue? The change extends existing owners with distinct prompt and tool ceilings and avoids duplicating runtime assembly or introducing new configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4849bb76ca96. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +15, Tests +259. Total +274 across 4 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 27, 2026, 4:25 PM ET / 21:25 UTC. |
## Problem `checks-fast-baseline-ratchets` fails on every PR merged with current main: `provider-branching` asks to shrink 3 allowlist entries. The allowlist from #206878 was taken at `ea77ca3d`. PRs merged later removed provider branches (#206735 deleted `openai-strict-tool-setting.ts`, and others touched `attempt-stream.ts` and `openai-tool-schema.ts`). The shrink-only ratchet fails when a file's count drops below its entry. ## Solution `--prune` on current main `8a8e0177`: - `src/agents/openai-strict-tool-setting.ts` 3 → removed (file deleted) - `src/agents/embedded-agent-runner/run/attempt-stream.ts` 2 → 1 - `packages/ai/src/providers/openai-tool-schema.ts` 1 → removed - `packages/ai/src/transports/openai-completions-compat.ts` 61 → 63: #206735 moved the strict-mode default from the deleted helper into the compat owner before the ratchet existed. This records main as it is; no branch is added here. Net: 840 → 837 branches, 218 → 216 files. ## Impact Contributors only. PRs are no longer red on `provider-branching` for branches that main already removed. There is no runtime change. ## Evidence - Before: `check-provider-branching-ratchet.mts --base origin/main` on main `8a8e0177` lists the 3 shrink entries (the same list as the CI failure on #206948). - After: `Provider branching ratchet OK: 216 files, 837 grandfathered branches.` - Local review on this head: patch is correct, 0 findings. Co-authored-by: Ayaan Zaidi <[email protected]>
## Problem `checks-fast-baseline-ratchets` fails on every PR merged with current main: `provider-branching` asks to shrink 3 allowlist entries. The allowlist from openclaw#206878 was taken at `ea4af5f4`. PRs merged later removed provider branches (openclaw#206735 deleted `openai-strict-tool-setting.ts`, and others touched `attempt-stream.ts` and `openai-tool-schema.ts`). The shrink-only ratchet fails when a file's count drops below its entry. ## Solution `--prune` on current main `b5101725`: - `src/agents/openai-strict-tool-setting.ts` 3 → removed (file deleted) - `src/agents/embedded-agent-runner/run/attempt-stream.ts` 2 → 1 - `packages/ai/src/providers/openai-tool-schema.ts` 1 → removed - `packages/ai/src/transports/openai-completions-compat.ts` 61 → 63: openclaw#206735 moved the strict-mode default from the deleted helper into the compat owner before the ratchet existed. This records main as it is; no branch is added here. Net: 840 → 837 branches, 218 → 216 files. ## Impact Contributors only. PRs are no longer red on `provider-branching` for branches that main already removed. There is no runtime change. ## Evidence - Before: `check-provider-branching-ratchet.mts --base origin/main` on main `b5101725` lists the 3 shrink entries (the same list as the CI failure on openclaw#206948). - After: `Provider branching ratchet OK: 216 files, 837 grandfathered branches.` - Local review on this head: patch is correct, 0 findings. Co-authored-by: Ayaan Zaidi <[email protected]>
…gent and Codex routes (openclaw#206948) ## Problem The only prompt byte gate (`FRESH_INSTALL_SYSTEM_PROMPT_BUDGET_BYTES`, 12,288 B) checks a hand-written fresh-install renderer fixture. Every other surface the model receives can grow without a failing check: - the system prompt and the compacted tool definitions that the embedded runtime sends for a Gateway WebChat turn and for a configured channel agent; - the Codex app-server prompt layers and dynamic tool specs, which are the default route for native OpenAI. Tool and prompt bytes are a reported cost (openclaw#200920). A 2026-11-27 audit of production first requests measured them at 18–56 KB of tools per request, with no gate on any route except the fresh fixture. ## Solution Gate each route at the owner that already builds it. Each new ceiling is the size measured on main plus 5%, rounded up to 256 B. Growth within that margin passes. | Route | Surface | Measured on main | Ceiling | Test | |---|---|---:|---:|---| | Fresh install (renderer fixture) | system prompt | 11,395 B | 12,288 B (unchanged) | `system-prompt.inventory-snapshot.test.ts` | | Gateway WebChat turn, fresh install, embedded runtime | system prompt | 13,599 B | 14,336 B | `attempt-prompt-budget.test.ts` (new) | | Gateway WebChat turn, embedded runtime | compacted tool definitions | 17,927 B | 18,944 B | same | | Configured Telegram agent (workspace files, setup complete) | system prompt | 13,676 B | 14,592 B | same | | Configured Telegram agent (workspace files, setup complete) | compacted tool definitions | 21,058 B | 22,272 B | same | | Codex app-server Telegram turn | model-bound layer text | 12,981 B | 13,824 B | `test/scripts/prompt-snapshots.test.ts` | | Codex app-server Telegram turn | dynamic tool specs | 62,551 B | 65,792 B | same | - `attempt-prompt-budget.test.ts` runs the production attempt pipeline: 1. `prepareEmbeddedAttemptToolBase` 2. `prepareEmbeddedAttemptBundleTools` 3. `prepareEmbeddedAttemptToolCatalog`, which compacts the tools as sent 4. `prepareEmbeddedAttemptSystemPrompt`, with the tool directory, skills and bootstrap files - Installed plugin tools, bundle MCP servers and paired-node probes vary by host, so they are mocked out. The budget covers core output. - The workspace path is pinned to `/workspace` and the docs and source paths to `/repo`, because the prompt contains them. The `Runtime:` line (host, OS, Node version) still varies by about 20 B across hosts. - The fresh WebChat turn has first-run bootstrap pending. The configured agent has recorded setup complete. - Tool bytes are compact JSON of `{ name, description, parameters }` for the compacted set. Deferred tools reach the model by name only, so their schemas are not in these numbers. - The Codex prompt is the sum of every non-`json` fenced layer body in the generated happy-path snapshot, from the layers heading to the end of the file. Renderer prose is not counted, and a relabeled or new layer is still counted. - The embedded ceilings live in one table, `PROMPT_BUDGET_BYTES`, in `src/agents/system-prompt-manifest.ts`. The Codex pair sits beside its snapshot test. - A PR that shrinks a surface should lower its ceiling. Nothing enforces that. ## Impact Contributors only. There is no runtime change. A change that grows a route's prompt or tool bytes past 5% fails CI until the growth is cut or the ceiling is raised on purpose in review. ## Evidence - Green on main `5128b80d` (rebased), final head: inventory 3/3, `attempt-prompt-budget` 2/2, prompt snapshots 8/8; `check:baseline-ratchets` all ok; `tsgo` for the scripts test config clean. - Red on a synthetic regression against the same code (throwaway edits, removed): +1,512 B in the shared Execution Bias prompt section, +2,016 B in the `exec` description and +3,990 B in the `sessions_spawn` description. All 7 gates fail: - fresh prompt 12,908 > 12,288 - WebChat prompt 15,112 > 14,336; WebChat tools 19,944 > 18,944 - Telegram prompt 15,189 > 14,592; Telegram tools 23,075 > 22,272 - Codex prompt 14,494 > 13,824; Codex tools 66,540 > 65,792 - Adversarial review, two rounds. Round 1 found tools measured before compaction, a Gateway fixture without the directory, skills or bootstrap, and a markdown slice with renderer prose. Round 2 found a Codex sum that could drop to 0 B on a relabeled fence, a configured agent measured in first-run state, and host checkout paths in the prompt. All six are fixed here. - Local review: round 1 found a closed provider-runtime mock missing its `mock-isolation:` annotation (the mock-exports ratchet would reject it); fixed. CI then caught a capture type error and a lint rule in the Codex fence parser; fixed with named groups. Final head: patch is correct, 0 findings. - Known gaps: - Deferred tool schemas are not gated on the embedded routes. On the Telegram route, 29 deferred tools (about 84 KB, `automations` alone 23.7 KB) appear in the prompt by name only. The Codex dynamic-tool gate covers `sessions_spawn` and the `openclaw` namespace in full. - The Telegram `message` schema comes from a two-action test channel plugin, not the real Telegram plugin. - Plugin, MCP and node tools and new bundled skills are not budgeted. - Steps after the catalog are not measured: the listing pin, the prompt-build tool policy and transport serialization. - Not covered: the Codex-owned native layers (`AGENTS.md`, environment, memories) that Codex adds after OpenClaw sends the thread params. - A failing gate prints the total only, not a per-tool breakdown. Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
The only prompt byte gate (
FRESH_INSTALL_SYSTEM_PROMPT_BUDGET_BYTES, 12,288 B) checks a hand-written fresh-install renderer fixture. Every other surface the model receives can grow without a failing check:Tool and prompt bytes are a reported cost (#200920). A 2026-11-27 audit of production first requests measured them at 18–56 KB of tools per request, with no gate on any route except the fresh fixture.
Solution
Gate each route at the owner that already builds it. Each new ceiling is the size measured on main plus 5%, rounded up to 256 B. Growth within that margin passes.
system-prompt.inventory-snapshot.test.tsattempt-prompt-budget.test.ts(new)test/scripts/prompt-snapshots.test.tsattempt-prompt-budget.test.tsruns the production attempt pipeline:prepareEmbeddedAttemptToolBaseprepareEmbeddedAttemptBundleToolsprepareEmbeddedAttemptToolCatalog, which compacts the tools as sentprepareEmbeddedAttemptSystemPrompt, with the tool directory, skills and bootstrap files/workspaceand the docs and source paths to/repo, because the prompt contains them. TheRuntime:line (host, OS, Node version) still varies by about 20 B across hosts.{ name, description, parameters }for the compacted set. Deferred tools reach the model by name only, so their schemas are not in these numbers.jsonfenced layer body in the generated happy-path snapshot, from the layers heading to the end of the file. Renderer prose is not counted, and a relabeled or new layer is still counted.PROMPT_BUDGET_BYTES, insrc/agents/system-prompt-manifest.ts. The Codex pair sits beside its snapshot test.Impact
Contributors only. There is no runtime change. A change that grows a route's prompt or tool bytes past 5% fails CI until the growth is cut or the ceiling is raised on purpose in review.
Evidence
28b6938f(rebased), final head: inventory 3/3,attempt-prompt-budget2/2, prompt snapshots 8/8.execdescription and +3,990 B in thesessions_spawndescription. All 7 gates fail:automationsalone 23.7 KB) appear in the prompt by name only. The Codex dynamic-tool gate coverssessions_spawnand theopenclawnamespace in full.messageschema comes from a two-action test channel plugin, not the real Telegram plugin.AGENTS.md, environment, memories) that Codex adds after OpenClaw sends the thread params.