Skip to content

[Feature] Prompt / Context Caching #888

Description

@akramcodez

Description

Implement prompt/context caching using provider-specific options (e.g., Anthropic's cacheControl breakpoints or OpenAI's automatic prefix caching). Since the system prompt, tool schemas, and conversation history are resent every turn, caching these prefixes will drastically cut latency and cost.

Use Case

For multi-turn sessions with large system prompts and tool definitions, users currently pay token costs and latency penalties on every turn for static context.

Proposed Solution

Modify source/ai-sdk-client/chat/provider-options.ts to set cache-control hints. Mark stable prefixes (system prompt + tool definitions) as cacheable.

Alternatives Considered

None. This is a native feature of newer model APIs that just needs to be wired up.

Additional Context

  • I have searched existing issues to ensure this is not a duplicate
  • This feature aligns with the project's goals (local-first AI assistance)

Implementation Notes

This is the single highest-leverage change identified for reducing multi-turn latency and cost.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions