Fmo/anthropic multi turn#220
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for the pull request, @felipemontoya! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
There was a problem hiding this comment.
Pull request overview
Adds Anthropic-specific behavior to the provider abstraction: (1) a capability registry replaces ad-hoc provider == "openai" checks, (2) Anthropic gets a new multi_turn_cache capability that injects two cache_control ephemeral breakpoints (last system + last user message) at request time, and (3) remote_response_id is no longer persisted for providers without server_side_thread_id. Also fixes a conte{}nt typo in the threaded orchestrator and adds ADR 0010 documenting the strategy.
Changes:
- Introduce
_PROVIDER_CAPABILITIESandprovider_supports()inproviders/__init__.py, refactor existing OpenAI checks to use it, and add_apply_multi_turn_cache()for Anthropic. - Gate persisting
remote_response_idon theserver_side_thread_idcapability inllm_processor.py. - Fix typo
conte{}nt→contentinthreaded_orchestrator.py; add ADR 0010.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| docs/decisions/0010-anthropic-multi-turn-prompt-caching.md | New ADR documenting the 2-breakpoint Anthropic caching strategy. |
| backend/openedx_ai_extensions/processors/llm/providers/init.py | Adds capability registry, provider_supports(), and _apply_multi_turn_cache(); refactors OpenAI checks. |
| backend/openedx_ai_extensions/processors/llm/llm_processor.py | Skips saving remote_response_id for providers without server-side threading. |
| backend/openedx_ai_extensions/workflows/orchestrators/threaded_orchestrator.py | Fixes a key-name typo when re-injecting initial system messages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Henrrypg
left a comment
There was a problem hiding this comment.
I like these changes, once Github review is addressed, we can go ahead. Thanks @felipemontoya
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #220 +/- ##
==========================================
+ Coverage 95.22% 95.33% +0.10%
==========================================
Files 68 69 +1
Lines 7901 8073 +172
Branches 414 429 +15
==========================================
+ Hits 7524 7696 +172
+ Misses 286 283 -3
- Partials 91 94 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR creates an extension for anthropic providers so that two things are different. One, the ID is not stored for Anthropic as it doesn't support a servers_side_thread_ID.
Second, it adds a cache control key to the messages being sent in chat history.