Add provider-specific cache front matter and wiring for OpenAI/Anthropic/Gemini#8
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f5d8edd0c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| reasoning: ReasoningSchema.optional(), | ||
| sampling: SamplingSchema.optional(), | ||
| response: ResponseSchema.optional(), | ||
| cache: CacheSchema.optional(), |
There was a problem hiding this comment.
Merge cache in applyOverrides before rendering
Adding cache to override schema here makes environments/tiers/runtime cache blocks validate, but mergeOverride in src/overrides/apply-overrides.ts never applies override.cache. That means resolveAssetForProvider silently drops all cache overrides, so cache behavior cannot actually vary by environment or tier even though this commit documents cache as overridable.
Useful? React with 👍 / 👎.
| export const PromptDefaultsSchema = z.object({ | ||
| provider: z.enum(['openai', 'anthropic', 'google', 'gemini', 'openrouter', 'any']).optional(), | ||
| model: z.string().optional(), | ||
| cache: CacheSchema.optional(), |
There was a problem hiding this comment.
Propagate defaults cache into loaded prompt assets
This makes defaults.md accept a cache block, but defaults application in src/parser/loader.ts does not merge or apply defaults.cache (the merge and short-circuit checks still only handle provider/model/metadata/system). As a result, cache settings in folder defaults are parsed but never inherited by prompt files, so the new defaults examples and init template cache config are no-ops.
Useful? React with 👍 / 👎.
Motivation
cachefront matter block to express vendor-specific prompt/context caching hints and allow adapters to map those hints to provider APIs.Description
cacheschemas (CacheSchema,OpenAICacheSchema,AnthropicCacheSchema,GeminiCacheSchema) to the prompt schema and wirecacheintoPromptAsset,PromptDefaults, and overrides.openai.prompt_cache_key/retentiontoprompt_cache_key/prompt_cache_retention; Anthropic supportsmode: automatic→ top-levelcache_controlandmode: explicit→ block-levelcache_controlon system, prompt, and tools; Gemini mapsgemini.cached_content(orgoogle.cached_content) tocachedContentand warns when both differ.README.md,docs/prompt-format.md,docs/providers.md,docs/schema.md) and thepromptopskit initscaffold to document and demonstratecacheusage.cacheas a known front-matter key.Testing
tests/providers.test.tscovering OpenAI, Anthropic, and Gemini cache behaviors, and they passed when running the test suite.Codex Task