Skip to content

Fmo/anthropic multi turn#220

Merged
felipemontoya merged 3 commits into
openedx:mainfrom
eduNEXT:fmo/anthropic-multi-turn
May 13, 2026
Merged

Fmo/anthropic multi turn#220
felipemontoya merged 3 commits into
openedx:mainfrom
eduNEXT:fmo/anthropic-multi-turn

Conversation

@felipemontoya
Copy link
Copy Markdown
Member

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.

felipemontoya and others added 2 commits May 13, 2026 16:28
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@felipemontoya felipemontoya requested review from Henrrypg and Copilot May 13, 2026 21:37
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels May 13, 2026
@openedx-webhooks
Copy link
Copy Markdown

Thanks for the pull request, @felipemontoya!

This repository is currently maintained by @felipemontoya.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_CAPABILITIES and provider_supports() in providers/__init__.py, refactor existing OpenAI checks to use it, and add _apply_multi_turn_cache() for Anthropic.
  • Gate persisting remote_response_id on the server_side_thread_id capability in llm_processor.py.
  • Fix typo conte{}ntcontent in threaded_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.

Comment thread backend/openedx_ai_extensions/processors/llm/providers/__init__.py
Comment thread backend/openedx_ai_extensions/processors/llm/providers/__init__.py
Comment thread backend/openedx_ai_extensions/processors/llm/providers/__init__.py
Comment thread backend/openedx_ai_extensions/workflows/orchestrators/threaded_orchestrator.py Outdated
Comment thread backend/openedx_ai_extensions/processors/llm/providers/__init__.py
Copy link
Copy Markdown
Contributor

@Henrrypg Henrrypg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.33%. Comparing base (bb0cdb5) to head (23f14c3).

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     
Flag Coverage Δ
unittests 95.33% <ø> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@felipemontoya felipemontoya merged commit e962171 into openedx:main May 13, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in Contributions May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants