Skip to content

feat(model): add provider-native prompt caching - #2837

Open
guslegend0510 wants to merge 12 commits into
agentscope-ai:mainfrom
guslegend0510:codex/issue-2834-phase1
Open

feat(model): add provider-native prompt caching#2837
guslegend0510 wants to merge 12 commits into
agentscope-ai:mainfrom
guslegend0510:codex/issue-2834-phase1

Conversation

@guslegend0510

Copy link
Copy Markdown
Contributor

Summary

  • Establish shared prompt-cache contracts through GenerateOptions.cacheControl and MessageMetadataKeys.CACHE_CONTROL.
  • Add provider-native prompt caching support:
    • OpenAI automatic and explicit caching protocols.
    • DashScope native and OpenAI-compatible cache markers.
    • Anthropic automatic and explicit cache breakpoints.
    • Gemini implicit caching and existing cachedContent resource references.
  • Normalize cache-read and cache-write token usage across streaming and non-streaming responses.
  • Propagate cache usage through Core, ReActAgent, AG-UI, and Studio.
  • Add English and Chinese provider behavior documentation.
  • Preserve safe behavior for unknown OpenAI-compatible endpoints and unsupported Ollama cache controls.

Validation

  • Core and all five model provider test suites passed.
  • AG-UI and Studio test suites passed.
  • Spotless and git diff --check passed.
  • Documentation build completed successfully.

Gemini cache resource creation, TTL updates, and deletion remain managed by the Google SDK because they have an independent, potentially billable lifecycle.

Closes #2834

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: 完善 prompt cache

2 participants