Skip to content

chore(anthropic): log hygiene, drop obsolete pdfs beta header, remove dead stream branches - #3976

Closed
hpiclaranet wants to merge 1 commit into
langgenius:mainfrom
hpiclaranet:fix/anthropic-hygiene-logging-034
Closed

hpiclaranet wants to merge 1 commit into
langgenius:mainfrom
hpiclaranet:fix/anthropic-hygiene-logging-034

Conversation

@hpiclaranet

@hpiclaranet hpiclaranet commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Rebased onto current main (7584b133, anthropic 0.3.34 via #3919 "Claude Opus 5.5") — supersedes #3725 with the same change set (#3725 was closed with a pointer to this PR). Version bumped to 0.3.35.

Three low-risk hygiene fixes in the Anthropic provider, verified against the installed anthropic SDK (1.4.0) and current official documentation:

  1. Full-payload logging demoted from INFO to DEBUG — six log statements dumped full request payloads, transformed tool schemas, the cache-block candidates (before pruning), the full API response, and every streamed chunk at INFO. The plugin daemon runs at INFO by default (main.py + the SDK's plugin_logger_handler), so every user prompt, system prompt, and response was written to daemon stdout on every invocation. They are now DEBUG behind a module-level _debug_logging_enabled() guard — and the expensive _sanitize_for_logging() deep-copy of the request payload is also skipped when DEBUG is off. (Response and streamed-chunk logs remain unredacted when DEBUG is on.)
  2. Obsolete pdfs-2024-09-25 beta header removed — PDF (document) support is GA; the current official docs show PDF requests with no beta header. The document block itself is unchanged and continues to be sent.
  3. Unreachable redacted_thinking delta branches removed from the stream handler. The SDK's RawContentBlockDelta union is TextDelta | InputJSONDelta | CitationsDelta | ThinkingDelta | SignatureDelta — there is no redacted-thinking delta type, so both elif chunk.delta.type == "redacted_thinking" branches could never execute. Redacted thinking arrives via content_block_start (a RedactedThinkingBlock), which is still handled; the two close-tag conditions simplify from in ("thinking", "redacted_thinking") to == "thinking". The input_json_delta/tool-use handling from fix(anthropic): stream tag duplication, 529 mapping, image fetch hardening #3907 is preserved.

Release Notes

  • Reduced plugin log volume: full API request/response dumps now log at DEBUG instead of INFO
  • Stop sending the obsolete pdfs-2024-09-25 beta header for PDF input (PDF support is GA)
  • Removed dead stream-handling code for a delta type the Anthropic SDK does not emit

Change Type

  • Documentation / non-plugin change
  • Non-LLM plugin (tools, extensions, datasource, etc.)
  • LLM plugin

Screenshots / Videos

Not applicable — logging levels, request headers, and dead code removal, covered by unit tests.

LLM Plugin Checklist

Areas affected by this change (check all that apply)
  • Message flow (system messages, user ↔ assistant turn-taking)
  • Tool interaction flow (multi-round usage, Agent App and Agent Node)
  • Multimodal input (images, PDFs, audio, video, etc.)
  • Multimodal output (images, audio, video, etc.)
  • Structured output (JSON, XML, etc.)
  • Token consumption metrics
  • Other LLM functionality (reasoning, grounding, prompt caching, etc.)
  • New models / model parameter fixes

Version

  • Bumped top-level version in manifest.yaml (not the one under meta) — 0.3.34 → 0.3.35 (0.3.34 taken by feat(anthropic): add Claude Opus 5.5 #3919)
  • dify_plugin>=0.10.2 is declared in pyproject.toml and locked in uv.lock (>=0.3.0 satisfied; upper bound left open as inherited from main — same as sibling plugins)

Testing

  • Local deployment — plugin suite in a clean uv venv aligned with manifest.yaml, pyproject.toml, and uv.lock (no Dify platform deployment in this run): full anthropic suite passes on the rebased head (4e416e34, main 7584b133, SDK 1.4.0) — 137 passed, 16 skipped (the 16 are live-API tests, no ANTHROPIC_API_KEY set; includes the Opus 5.5 tests from feat(anthropic): add Claude Opus 5.5 #3919). ruff check reports zero findings on the changed files.
  • SaaS (cloud.dify.ai)

Known limitations (pre-existing, out of scope here):

  • The beta-header removal is validated for the official Anthropic API (GA per current docs). A non-standard third-party proxy configured via the anthropic_api_url credential that still required the legacy pdfs-2024-09-25 header would not receive it — no such requirement exists in any official endpoint.
  • The legacy claude-3-5-sonnet-20240620 max-tokens beta header assignment uses direct assignment rather than comma-join composition (pre-existing; that model does not combine with the other beta features).
  • DEBUG logs can contain raw prompt/response content (only request-payload dumps truncate long data fields; response and stream chunks are logged as-is); keep DEBUG off in production.

@hpiclaranet
hpiclaranet force-pushed the fix/anthropic-hygiene-logging-034 branch from 86bcdcc to 4e416e3 Compare October 10, 2026 09:34
@crazywoola

Copy link
Copy Markdown
Member

Thank you for your contribution, @hpiclaranet! This PR currently has merge conflicts with main, so we are closing it for now. Please update your branch against the latest main and resolve the conflicts — note that the consolidated dependency refresh (#4106–#4111) has bumped plugin manifest.yaml versions on main, so please bump models/anthropic/manifest.yaml to the next unused version when you rebase. You are welcome to open a new PR with the updated changes and link back to this one. We appreciate your time and effort!

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.

2 participants