Skip to content

feat(anthropic): add Claude Opus 5.5 and refresh dependencies - #3919

Draft
WH-2099 wants to merge 4 commits into
mainfrom
feat/anthropic-opus-5-5
Draft

WH-2099 wants to merge 4 commits into
mainfrom
feat/anthropic-opus-5-5

Conversation

@WH-2099

@WH-2099 WH-2099 commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #3916.

Adds claude-opus-5-5 using the official specifications and migration requirements.
The model has a 1M-token context, 128K-token output limit, always-on adaptive thinking, and a medium effort default.
Standard input/output pricing is $4/$20 per million tokens, with cache reads charged at 5% of the input rate.
Existing request handling supplies adaptive thinking, strips unsupported sampling parameters, and reuses native structured output and automatic tool choice.
Preserves each response's complete content in its own assistant message and replays those blocks in their original order.
Function Calling Agent retains this metadata in streaming and non-streaming tool loops, preserves images, freezes tool schemas, and leaves the caller’s initial history list intact.
Function Calling and ReAct check configured or schema-default output budgets before every request and stop on exhausted context without lowering the output limit below a thinking budget.
Replayed text and tool-use blocks retain the configured cache thresholds and TTL, with the existing four-breakpoint limit.
This replaces the shared latest-thinking state, which could inject a later signature into earlier messages and violate Opus 5.5's thinking-prefix binding during multi-turn tool use.

Refreshes direct and transitive dependencies to current stable releases, including Anthropic SDK 1.8.0 and pyrefly 1.3.1.

Cross-repository dependencies

Keep this PR in draft until the replay fixes are released and the complete deployed combination is verified.
The plugin lockfile currently pins SDK commit 5d5799eeceb938eda4337bcd229f3dcf41b27596 from SDK #390; replace this source override with its published version before release.
The host also requires Graphon #261, Dify #41095, and daemon #828.
Dify currently pins Graphon 0.7, so its review build uses a 0.7 backport rather than the incompatible Graphon 0.8 runtime.
The final minimum Dify version and daemon image must come from actual containing releases; existing manifest minima do not certify this replay support.
Cross-session history restoration is outside this in-memory tool-loop fix.

Release Notes

  • Add Claude Opus 5.5 with a 1M-token context window, 128K output limit, and medium reasoning effort by default.
  • Support its always-on adaptive thinking and discounted prompt-cache reads.
  • Show summarized thinking by default so progress between tool calls remains visible.
  • Preserve thinking signatures, content order, and image inputs across streamed and non-streamed Agent tool conversations.
  • Apply existing prompt-cache settings when replaying signed content.
  • Update the Anthropic SDK and dependency lockfile.

Change Type

  • LLM plugin
  • Agent strategy plugin

LLM Plugin Checklist

  • Message flow
  • Tool interaction flow
  • Token consumption metrics
  • Other LLM functionality (reasoning and prompt caching)
  • New models / model parameter fixes

Version

  • Bumped top-level manifest.yaml version to 0.3.33.
  • Bumped Dify Agent Strategies manifest.yaml version to 0.0.49; upgrade it alongside the Anthropic plugin for the Function Calling Agent fix.
  • Anthropic uses dify_plugin>=0.10.2; both plugins lock the immutable SDK fix above.

Testing

  • Fresh Python 3.13.15 environment with the updated immutable SDK pin: uv run --locked pytest --ignore=tests/test_llm_live.py -q — 119 passed.
  • Agent strategy tests in a fresh locked Python 3.13.15 environment: uv run --locked pytest -q — 82 passed.
  • Six new strategy cases use real token counting and model/tool mocks to verify exhausted-context handling for FC blocking, FC streaming, and ReAct with explicit and default budgets; each fails with the original SDK helper.
  • Real Function Calling Agent regression covers two tool rounds, streaming and non-streaming, text/image prompts, interleaved thinking/tool/redacted content, the real Plugin SDK Session and HTTP transport serialization, mutable nested tool schemas, and fresh provider instances.
  • Cache regression covers enabled/disabled policies, thresholds, TTL, immutable signatures, and the four-breakpoint limit.
  • Real Anthropic SDK request serialization through an offline HTTP mock preserves signed content when cache settings change.
  • Truncated tool JSON raises an explicit incomplete-arguments error rather than producing a replayable partial tool call.
  • uv lock --check, new model validation with AIModelEntity, and git diff --check passed.
  • Earlier plugin revisions packaged successfully using Dify CLI 0.6.10; packaging has not been repeated after this SDK pin and budget update.
  • Live API requests and Dify UI deployment were not run.

Copilot AI balanced review requested due to automatic review settings September 22, 2026 19:49
@WH-2099 WH-2099 self-assigned this Sep 22, 2026
@WH-2099
WH-2099 force-pushed the feat/anthropic-opus-5-5 branch from 498c84d to 5c01e55 Compare September 22, 2026 19:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Empty truncated tool arguments can still be replayed, and opaque replay bypasses configured assistant prompt caching.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Adds Claude Opus 5.5 support and replaces shared thinking state with per-message content replay.

Changes:

  • Registers Opus 5.5 with updated capabilities, pricing, and adaptive-thinking defaults.
  • Preserves ordered Anthropic content blocks across tool rounds.
  • Refreshes dependencies, tests, documentation, and plugin metadata.
File Description
models/​anthropic/​models/​llm/​llm.py Implements model handling and content replay.
models/​anthropic/​models/​llm/​claude-opus-5-5.yaml Defines Opus 5.5 capabilities and pricing.
models/​anthropic/​models/​llm/​_position.yaml Adds the model to display ordering.
models/​anthropic/​tests/​test_thinking_replay.py Tests ordered multi-turn replay and truncation.
models/​anthropic/​tests/​test_opus5_parameters.py Tests Opus 5.5 schema and request parameters.
models/​anthropic/​tests/​test_llm.py Tests classification and cache pricing.
models/​anthropic/​README.md Documents Opus 5.5 behavior.
models/​anthropic/​pyproject.toml Updates direct dependencies.
models/​anthropic/​uv.lock Refreshes resolved dependencies.
models/​anthropic/​manifest.yaml Bumps the plugin version.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1312 to +1320
for block in content_blocks:
if block["type"] == "tool_use" and tool_params_by_id.get(block["id"]):
try:
block["input"] = json.loads(tool_params_by_id[block["id"]])
except json.JSONDecodeError as ex:
raise InvokeError(
f"Anthropic returned incomplete tool arguments (stop_reason={finish_reason}). "
"Increase max_tokens and retry."
) from ex
Comment thread models/anthropic/models/llm/llm.py Outdated
Copilot AI review requested due to automatic review settings September 22, 2026 19:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

Empty truncated tool inputs can be executed, and opaque replay bypasses configured assistant caching.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)

Copilot AI review requested due to automatic review settings September 22, 2026 20:18
@WH-2099
WH-2099 force-pushed the feat/anthropic-opus-5-5 branch from 5c01e55 to 1c274cb Compare September 22, 2026 20:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Image retention is applied to every vision provider, regressing providers that only support images on the initial tool-loop request.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
Resolved since last review (1)

Comment on lines +896 to 898
# Keep the original prefix across tool rounds for signed reasoning replay.
if not supports_vision:
prompt_messages = self._clear_user_prompt_image_messages(prompt_messages)
@WH-2099
WH-2099 marked this pull request as draft September 22, 2026 20:49

This branch has not been deployed

No deployments
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.

feat(anthropic): support Claude Opus 5.5 and refresh dependencies

2 participants