feat: add exclude_dynamic_sections input for cross-session prompt caching#1362
Open
sestakvit wants to merge 1 commit into
Open
feat: add exclude_dynamic_sections input for cross-session prompt caching#1362sestakvit wants to merge 1 commit into
sestakvit wants to merge 1 commit into
Conversation
…hing Wires the Agent SDK's excludeDynamicSections option to an action input. When true, per-user dynamic content (working directory, git status, auto-memory path) is stripped from the cached system prompt prefix and re-injected as the first user message. This makes the system prompt static across sessions, enabling cross-run prompt cache hits in CI fleets where many independent runs share the same prompt. Has no effect when a custom system_prompt is set (SDK behaviour). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
The Agent SDK (
@anthropic-ai/claude-agent-sdk) supportsexcludeDynamicSections: trueon theclaude_codesystem prompt preset. When enabled, per-user dynamic content — working directory, git status, auto-memory path — is stripped from the cached system prompt prefix and re-injected as the first user message. This keeps the system prompt byte-for-byte identical across sessions, enabling prompt cache hits between independent runs that share the same prompt.This is particularly valuable in CI fleet use cases (GitHub Actions workflows, PR validation bots) where many unrelated runs share the same prompt and would otherwise get a cache miss on every invocation due to the dynamic working-directory/git-status sections.
This PR wires that existing SDK option up to an action input.
Changes
action.yml: addsexclude_dynamic_sectionsboolean input (defaultfalse) and passes it asEXCLUDE_DYNAMIC_SECTIONSenv varbase-action/src/run-claude.ts: addsexcludeDynamicSections?: booleantoClaudeOptionsbase-action/src/parse-sdk-options.ts: passes the option into theclaude_codepreset system prompt objectsrc/entrypoints/run.ts: readsEXCLUDE_DYNAMIC_SECTIONSenv var and passes it throughbase-action/src/index.ts: same for standalone base-action usage (INPUT_EXCLUDE_DYNAMIC_SECTIONS)Usage
Notes
system_promptis set (matches SDK behaviour —excludeDynamicSectionsonly applies to theclaude_codepreset)false