Repository navigation
perf: stop busting the prompt cache and slim per-turn context #2142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7e316c6
e449794
ebb6544
e022fa1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { afterEach, beforeEach, expect, test } from 'bun:test' | ||
| import { withMockMacro } from 'src/test/mockMacro.js' | ||
| import { getSystemPrompt } from './prompts.js' | ||
|
|
||
| // getSystemPrompt returns a minimal prompt without the doing-tasks section | ||
| // when CLAUDE_CODE_SIMPLE is truthy — unset it so the test always exercises | ||
| // the full prompt path regardless of process-level state. | ||
| let originalSimple: string | undefined | ||
|
|
||
| beforeEach(() => { | ||
| originalSimple = process.env.CLAUDE_CODE_SIMPLE | ||
| delete process.env.CLAUDE_CODE_SIMPLE | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| if (originalSimple === undefined) { | ||
| delete process.env.CLAUDE_CODE_SIMPLE | ||
| } else { | ||
| process.env.CLAUDE_CODE_SIMPLE = originalSimple | ||
| } | ||
| }) | ||
|
|
||
| test('coding system prompt includes the timing and wiring robustness guidance', async () => { | ||
| const prompt = await withMockMacro( | ||
| { ISSUES_EXPLAINER: 'report the issue at the tracker', VERSION: '0.0.0-test' }, | ||
| async () => (await getSystemPrompt([], 'test-model')).join('\n'), | ||
| ) | ||
|
|
||
| // Focused assertions on the new "Doing tasks" guidance — not a full-prompt | ||
| // snapshot, so unrelated prompt edits don't churn this test. | ||
| expect(prompt).toContain( | ||
| 'derive timing-sensitive logic (animation, physics, timers) from actual elapsed time', | ||
| ) | ||
| expect(prompt).toContain('Every element you introduce must be wired up') | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -226,6 +226,7 @@ function getSimpleDoingTasksSection(): string { | |
| `Avoid giving time estimates or predictions for how long tasks will take, whether for your own work or for users planning projects. Focus on what needs to be done, not how long it might take.`, | ||
| `If an approach fails, diagnose why before switching tactics—read the error, check your assumptions, try a focused fix. Don't retry the identical action blindly, but don't abandon a viable approach after a single failure either. Escalate to the user with ${ASK_USER_QUESTION_TOOL_NAME} only when you're genuinely stuck after investigation, not as a first response to friction.`, | ||
| `Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it. Prioritize writing safe, secure, and correct code.`, | ||
| `Make behavior explicit rather than environment-dependent: derive timing-sensitive logic (animation, physics, timers) from actual elapsed time instead of assuming a fixed frame or tick rate. Every element you introduce must be wired up — a UI element, state variable, or parameter that nothing ever updates or reads is a bug, not a placeholder.`, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Add a focused test for the new system-prompt guidance. Line 229 changes model-facing behavior. Add or update a Run the targeted Bun test and As per coding guidelines: add or update tests when a change affects behavior. 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| ...codeStyleSubitems, | ||
| `Avoid backwards-compatibility hacks like renaming unused _vars, re-exporting types, adding // removed comments for removed code, etc. If you are certain that something is unused, you can delete it completely.`, | ||
| // @[MODEL LAUNCH]: False-claims mitigation for Capybara v8 (29-30% FC rate vs v4's 16.7%) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.