TestEmbeddedPromptFitsFixedSystem guards the invariant the packer relies on: FixedSystem must reserve enough budget for the embedded system prompt PLUS the "\n\nWorking directory: " anchor buildSystem appends. If a prompt edit pushes the embedded text past this, the reservation under-counts an
(t *testing.T)
| 15 | // silently over-fills the real context, a bug with no other test to catch it. |
| 16 | // anchorAllowance covers a generously long working-directory path (~384 chars). |
| 17 | func TestEmbeddedPromptFitsFixedSystem(t *testing.T) { |
| 18 | const anchorAllowance = 96 // tokens; "\n\nWorking directory: " + a deep container path |
| 19 | used := Tokens(config.DefaultSystemPrompt) + anchorAllowance |
| 20 | if used > FixedSystem { |
| 21 | t.Fatalf("embedded prompt (%d tok) + anchor allowance (%d) = %d exceeds FixedSystem=%d; trim the prompt or bump FixedSystem", |
| 22 | Tokens(config.DefaultSystemPrompt), anchorAllowance, used, FixedSystem) |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | func TestTokensHeuristic(t *testing.T) { |
| 27 | cases := map[string]int{ |