Repository navigation
feat(prompt): expand MLX behavior protocols + KV-cache doc verification - #153
Merged
Merged
Conversation
Add two behavior protocol sections for local MLX models (ar-plan PR #2): - getToolResultProcessingProtocol: tool failure retry limit (≤3 same-op), failure-mode classification (schema/permission/timeout/not-found), partial read guard. More specific than the general error-recovery protocol. - getLongTaskCheckpointProtocol: 3+ step checkpoint pattern, progress survival across context compression, recovery after interruption. Registration by tier (equal-replacement, compact ≤3K budget): - compact: drops getErrorRecoveryProtocol (overlaps with the new specific tool-result protocol), keeps the two new sections + coding standards. Measured 2940 tokens (≤3000 budget). - standard/extended/full: keep getErrorRecoveryProtocol AND the two new sections (budget ample, no overlap concern at scale). KV-cache (part 2): docs/model-providers.md already documents the accurate conclusion (defer item 8): fusion-mlx /v1/messages honors cache_control (issues #196/#241/#289/#386 CLOSED), fusion-code adapter /v1/chat/completions drops it = large refactor, not a gap. No doc contradiction found. Gates: typecheck 0, 537 tests pass, lint no new errors (baseline-identical), build:dev passes. Co-Authored-By: Claude Fable 5 <[email protected]>
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
Ar-plan PR #2 (P0, M1): expand local MLX behavior prompts + verify KV-cache doc accuracy.
Part 1 — Behavior protocol expansion
Two new protocol sections in
src/constants/behavioral-protocols.ts:getToolResultProcessingProtocol— tool failure retry limit (≤3 same-op, then STOP and report), failure-mode classification (schema error / permission denied / timeout / file not found), partial-read guard. More specific than the general error-recovery protocol.getLongTaskCheckpointProtocol— 3+ step checkpoint pattern, progress survival across context compression, recovery after interruption.Registration by tier in
src/constants/mlx-system-prompt.ts(equal-replacement to stay within the compact ≤3K budget):getErrorRecoveryProtocol(its content overlaps the new, more-specific tool-result protocol — ≤3 retry limit + failure-mode classification subsumes the generic "retry at most TWICE" rule), keeps the two new sections + coding standards. Measured 2940 tokens (≤3000 budget).getErrorRecoveryProtocolAND the two new sections (budget ample, general + specific coexist).Part 2 — KV-cache doc verification
docs/model-providers.md§P1.2 already documents the accurate conclusion (defer item 8): fusion-mlx/v1/messageshonorscache_control(upstream issues #196/#241/#289/#386 all CLOSED), fusion-code MLX adapter goes/v1/chat/completionsdroppingcache_control= large adapter refactor, not a gap. Grep found no contradiction indocs/orsrc/. No edit needed.Files
src/constants/behavioral-protocols.ts— +2 functionssrc/constants/mlx-system-prompt.ts— import + compact-tier registration (compact-only branch, drops errorRecovery)Acceptance
Gates
bun run typecheck— 0 errorsbun test src/__tests__/— 537 pass, 0 failbun run lint— no new errors (baseline-identical: 1 error / 2 warnings / 1 info both before and after, all pre-existing grandfathered file-style)bun run build:dev— passesRisk
Compact-tier budget: adding 2 sections (~556 tokens) exceeded 3K → solved by equal-replacement dropping
getErrorRecoveryProtocolfrom compact (459 tokens, subsumed by the more-specific tool-result protocol). Standard+ tiers unaffected (budget ample).Co-Authored-By: Claude Fable 5 [email protected]