feat: add per-model promptCompression config #36
No reviewers
Labels
No labels
code-review
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
sam/brainless!36
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/prompt-compression"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds an opt-in
promptCompressionflag on each model inbrainless.json(default false). When enabled, the model's system prompt carries a compacted copy of the honey-for-devs AGENTS.md ruleset (less code, less prose, denser agent-to-agent messages), embedded frominternal/harness/honey_compressed.txtviago:embed.How it works
internal/config/config.go(promptCompression, default false,omitzero).selectorModel.GenerateContent(where the active model is resolved per prompt) appends the compacted text to the request's system instruction when the model's flag is on — the baseagentInstructionstays untouched, and the per-model prompt prefix remains cache-stable.Compacted prompt
A distilled copy of https://github.com/Green-PT/honey-for-devs/blob/main/AGENTS.md (~7.4 KB → ~2.9 KB): the three levers (less code, less prose, denser agent-to-agent messages), intensity modes, the Lever-1 code ladder, the "never cut" safety list, Lever 2 (say less, keep exact), Lever 3 (agent-to-agent compression), Lever 3b (request less input), and loop pacing.
Verification
go build ./...,go vet ./...,golangci-lint run(0 issues)go test ./internal/config ./internal/harness— new tests:TestLoadParsesPromptCompression(config round-trip + default false) andTestSelectorModelPromptCompression(instruction appended only for enabled models)Docs
README.md: newpromptCompressionbullet under model configbrainless.json.example: flag shown on the flash modelSkill-guided review (code-style, naming, docs, error-handling, safety, concurrency, security, dependency-management, testing, performance, observability, modernize) of head
8b31de0vs base99487eb.Verification run in this session:
go build ./...exit 0,go vet ./...exit 0,gofmt -lcleango test ./...all packages ok;go test -race ./internal/config ./internal/harnessokgo tool cover -func→ appendSystemInstruction 53.8%go doc google.golang.org/genai NewContentFromText / NewPartFromText→ signatures match the call sitesgit diff -- go.mod go.sum= 0 lines: no dependency changes; upstream AGENTS.md link resolves and the embedded copy is a faithful distillationNo blocking or important findings. One suggestion (inline on registry.go: appendSystemInstruction's edge branches are untested; a table test pins the ADK mirror against version drift).
@ -646,0 +658,4 @@// appendSystemInstruction appends text to the request's system instruction,// mirroring ADK's internal AppendInstructions (the selector runs after the// instruction request processor has installed the static agentInstruction).func appendSystemInstruction(req *model.LLMRequest, text string) {🟡 SUGGESTION — appendSystemInstruction is at 53.8% coverage (
go tool cover -funcon this head): the nil-Config, nil-SystemInstruction, empty-Parts, and empty-last-part branches are untested. TestSelectorModelPromptCompression only exercises the selector path, where ADK always installs the agent instruction first (instruction_processor.go runs in preprocess), so those branches stay dead in production — but this helper is a hand-mirror of ADK's unexported utils.AppendInstructions (internal/utils/utils.go:138, adk v2.5.0), and the mirror has no test pinning its exact behavior. When the ADK version bumps and AppendInstructions changes shape, only a direct table test on the helper catches the drift. Fix: add a small table-driven test calling appendSystemInstruction directly (nil Config, nil SystemInstruction, empty Parts, non-text last part) asserting the resulting Parts layout.Resolved in
3b1d7fb: addedTestAppendSystemInstruction, a table test covering every branch of the ADK mirror — nil Config, nil SystemInstruction, non-empty last text part (absorbs the append), empty Parts (new part), and a non-text last part (keeps its place, new text part appended). Asserts the exact resulting Parts layout.appendSystemInstructioncoverage went 53.8% → 100%; build/vet/lint/tests all green.