Repository navigation
feat(prompt): host-pluggable system-prompt builder seam - #128
Merged
Merged
Conversation
Add a backward-compatible seam so a host embedding the engine for a non-coding agent can fully own the system prompt (role/tone/safety/tool inventory) with no coding-agent defaults and no 'Available tools:' block. - prompt: new Builder func type (func(Config) Layered); prompt.Build is the documented default and literally satisfies it. - agent: new optional Deps.PromptBuilder field; nil -> prompt.Build, byte-identical to engine/v0.0.1. - agent/loop.go buildRequest resolves the builder once per turn after the same cfg population (Tools + volatile Env), so the nil path is provably byte-identical. Only the MAIN loop routes through it; the compaction summarizer (cascade.go) builds its own prompt.Layered directly and is unaffected. Tests: byte-identity pin (nil == v0.0.1), host-ownership (no defaults, no tool inventory, tools present), flexibility (host can reuse prompt.Build helpers), cascade-isolation (summarizer keeps its own prompt), multi-turn (builder applies every turn), empty-Layered (honored, not back-filled), and a compile-time assignability pin. api: agent.txt + prompt.txt regenerated (Added). CHANGELOG: Added (minor) per COMPATIBILITY.md / ADR-0037.
…ock)
The live e2e default-lane model anthropic/claude-3.5-haiku reached
end-of-life on AWS Bedrock and started 404-ing
("This model version has reached the end of its life"), failing the
provider-smoke canary and gating every later scenario.
Repoint the lane to anthropic/claude-haiku-4.5 — same family, same lane
rationale (tool-call-capable, Bedrock-routed, no OpenAI-family
content_filter on mecatl-shaped tool-bearing requests per finding F2),
catalogued, not EOL'd.
- harness.DefaultModel() default + doc comment (e2e/harness/target.go)
- haikuLane constant value + comment (e2e/restart_helpers_test.go) —
the single source the 6 hard-pinned specs reference
- approve_after_kill lane comment (e2e/approve_after_kill_test.go)
- modelPricing cost-ledger: add haiku-4.5 ($1/$5 per 1M from catalog),
keep the 3.5 entry for the historical cost ledger (e2e/suite_test.go)
- e2e/README.md default-lane references
Found by the live e2e run on PR #128 (unrelated to the PR's change —
the prompt-builder seam is offline-tested and the CI lint/test/api/docs
gates are green).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #127.
Adds a small, backward-compatible seam so a host embedding the engine for a non-coding agent can fully own the system prompt (role, tone, safety, tool inventory) with no coding-agent defaults and no
Available tools:block, whileprompt.Buildstays the default.The Atrium cutover (replacing its hand-rolled agent loop with the imported engine, pinned at
engine/v0.0.1) caught that every model turn carries the engine'sdefaultRole/defaultTone("you are a headless agentic coding harness… cite code asfile_path:line_number… nevergit add -A"), which a non-coding host (Craig, the Slack weekly-update assistant) cannot opt out of. This seam provides the clean parity path.The change
engine/prompt: new exportedBuilderfunc type (func(Config) Layered).prompt.Buildis the documented default implementation and literally satisfies it (same signature).engine/agent: new optionalDeps.PromptBuilder prompt.Builderfield.buildRequestresolvesbuild := e.deps.PromptBuilder; if build == nil { build = prompt.Build }thenSystem: build(cfg)— nil → byte-identical toengine/v0.0.1(the sameprompt.Buildover the samecfg, populated in the same order).buildRequestroutes throughDeps.PromptBuilder. The compaction summarizer (engine/agent/cascade.go) builds its ownprompt.Layered{StablePrefix: summarizerSystemPrompt}directly and is explicitly unaffected — the summarizer's structured-output contract is host-independent.internal/appis unchanged.nilis the default and propagates to the loop, so every shippedmecated/mecatui/mecademobuild is byte-identical to v0.0.1. The seam is purely for external embedders (host-embedding concern, not an operator flag — per the issue).Why the builder-only shape (no tunable knobs)
The issue floated two options: (1) a pluggable builder, (2) narrower knobs (
Config.OmitToolInventory bool,Config.RawPrefix string). This lands only the builder. Justification:prompt.Layered{StablePrefix: hostRole}and ignorescfg.Tools.prompt.Build(cfg)inside its builder and overlays its role — the seam is not all-or-nothing (tested).Tests
Unit + loop-level e2e (offline,
mockllm+memfs— the repo convention):TestBuildSatisfiesBuilder— compile-time + runtime assignability pin (var _ prompt.Builder = prompt.Build).TestBuildRequestNilPromptBuilderIsByteIdenticalToDefault— the v0.0.1 pinning test: nilPromptBuilderproduces anLLMRequest.Systembyte-identical toprompt.Buildover the reconstructed turn-0Config.TestBuildRequestHostPromptBuilderOwnsSystemPrompt— the headline acceptance test: a host builder produces a fully host-owned prompt with none ofdefaultRole/defaultTone/defaultSafety/Available tools:/the registered tool name, with tools present.TestPromptBuilderHostCanStillUseInventoryAndEnv— flexibility: a host can opt back into the tool inventory + env block by callingprompt.Buildfrom inside its builder.TestPromptBuilderDoesNotRouteThroughCompactionSummarizer— isolation: drives a realCascadeCompactorthrough the loop with a host builder installed, captures every provider request, and asserts the summarizer request carriessummarizerSystemPrompt(not the host marker); fails loudly if compaction never reaches tier-4.TestPromptBuilderAppliesEveryTurn— multi-turn: the host builder is consulted on EACH turn (text→tool-call→text), not just the first.TestPromptBuilderEmptyLayeredIsHonoredNotBackfilled— edge: a host builder returning an emptyLayeredis honored (no panic, no silent back-fill of defaults).API / stability contract
engine/api/agent.txt+engine/api/prompt.txtregenerated (task api:update);api:checkpasses.engine/CHANGELOG.md: Added (minor) perengine/COMPATIBILITY.md/ ADR-0037 — a new func type and a new struct field, both additive; no existing identifier changed or removed.Verification
task lint— 0 issues (golangci-lint v2 + go vet, both modules).task test— green (full suite + engine-standaloneGOWORK=offhygiene proof).task api:check— passes.task docs—llms.txtregenerated, 0 broken links/anchors/orphans.go run ./cmd/mecademo— full offline session still prints (turn → tool.call → result).Downstream
Atrium will re-pin to the released tag (a fresh
engine/vX.Y.Zonce merged) and route its assembled prompt throughDeps.PromptBuilder, completing the agent-loop-engine-import cutover (Atrium ADR-0068) at true parity.