Skip to content

chore(anthropic): log hygiene and drop obsolete pdfs beta header - #4147

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

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

Conversation

@hpiclaranet

Copy link
Copy Markdown
Contributor

Summary

Rebased onto current main (888886e6, anthropic 0.3.39) and bumped to 0.3.40, as requested by @crazywoola on closing #3976. This supersedes #3976 (which was closed due to merge conflicts on the previous base; same two hygiene changes, adjusted for the newer main). It carries two low-risk hygiene fixes in the Anthropic provider, verified against the installed anthropic SDK (2.1.0) and the current official documentation.

Note on scope: the original #3976 also proposed removing "unreachable" redacted_thinking delta branches from the stream handler. That is not included here: the current main (0.3.39) now handles redacted_thinking actively via a think_open flag (and preserves current_redacted_thinking_blocks), so that change would reintroduce a regression. This PR keeps the streaming logic intact and contains only the two changes below.

  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, 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.

Release Notes

  • Moved verbose Anthropic request, response, tool-schema, and streaming payload logs from INFO to DEBUG
  • Removed obsolete pdfs-2024-09-25 beta header for PDF input (PDF support is GA)

Change Type

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

Screenshots / Videos

Not applicable — logging levels and request-header changes, 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.39 → 0.3.40
  • dify_plugin>=0.10.2,<0.11.0 is declared in pyproject.toml and locked in uv.lock (satisfies the required >=0.3.0,<0.11.0 range)

Testing

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.
  • 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

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest main (888886e6, anthropic 0.3.39) and bumped to 0.3.40 as requested — this supersedes the closed #3976.

Note for reviewers: as mentioned in the Summary, the previous PR also proposed dropping the redacted_thinking delta branches, but that change is intentionally not carried over — the current main treats redacted_thinking actively via think_open (and preserves current_redacted_thinking_blocks), so removing it would regress. This PR is scoped to the two hygiene changes only.

Suite on the rebased head: 165 passed, 18 skipped (live-API tests, no key); ruff check clean.

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.

1 participant