Skip to content

feat(agent): opt-in worker cache-prefix split (P3.5 phase C) - #427

Merged
BaaRai merged 2 commits into
mainfrom
feat/worker-cache-prefix
Nov 20, 2026
Merged

BaaRai merged 2 commits into
mainfrom
feat/worker-cache-prefix

Conversation

@BaaRai

@BaaRai BaaRai commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Summary

Opt-in ARTEX_CACHE_PREFIX=1 splits the worker system prompt at DynamicBoundary = 1 so sibling workers in the same task share a cacheable static prefix, with the model-visible text byte-identical to the legacy prompt. Off by default; planner, mainagent, chat and goals are untouched.

  • Static segment: body + untrustedContentTail + workerTrafficBlock.
  • Dynamic segment: workerArtifactSpec(runDir) through <available-deferred-tools>, in the original order; the leading \n\n is absorbed because providers join segments with \n\n.
  • Flag off delegates to the existing deferredSystem path, byte-identical segments and boundary.
  • Custom worker prompts using {{.Now}} remain volatile in the static segment (documented).
  • docs/context-telemetry.md records the exact split, the future task-stable-prefix optimization (needs reordering), and how to measure it with ARTEX_CONTEXT_TELEMETRY=1.

Verification

  • Unit test: flag off byte-identical to legacy; flag on static prefix identical across sibling workers; visible joined text byte-identical.
  • End-to-end: two real workers on one task with distinct runDir/intent/assets, deferred MCP and lessons; tools unchanged; planner and mainagent unchanged; MeasureContext sees a non-zero split.
  • Independent adversarial check: the provider's joinSystem (trim/drop/empty) produces the same wire text as the unsplit prompt.
  • go test -p 1 -count=1 ./agent green with Postgres; ./server green except the pre-existing TestCoreTaskLifecyclePG dirty-DB 3s poll, which passes isolated on a fresh database.
  • Merge-tree clean against main 40a4358.

@BaaRai
BaaRai merged commit 0d85fc9 into main Nov 20, 2026
6 checks passed
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