You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: preserve SDK behavior while closing runtime resources - #396
SDK calls can leak HTTP responses and generators, interleave TCP frames, or leave CLI readers blocked after the child process exits.
This fixes cleanup on completion, failure and cancellation, serializes TCP writes, and handles reconnects and CLI/Serverless shutdown.
Also fixes tool-action and trigger registration, SSE line endings and event fields, manifest revalidation, and schema/documentation errors.
Public behavior and provider hooks are preserved against main at 86e81e72 (SDK 0.11.0).
Tests cover all 37 dispatch actions using local HTTP/TLS services, sockets, subprocesses and an installed SDK wheel.
Validation at b880bc18:
Python 3.12 and 3.13: 1,470 tests passed on each, with no skips.
just check, just build, just docs, prek hooks and git diff --check passed.
Remaining fixes: #397 (SSE comments/fields), #398 (Serverless error text), #399 (Agent token counting), #400 (literal stops), #401 (embedding validation). #394 stays open for the full requirements.
Large datasource/Agent blobs can still exceed the daemon's 5 MiB frame limit after base64 encoding.
Deployed Dify, the released Go CLI, external APIs and sustained load were not tested.
I have checked whether this change affects the backward compatibility of the plugin declared in README.md
I have checked whether this change affects the forward compatibility of the plugin declared in README.md
If this change introduces a breaking change, I have discussed it with the project maintainer and specified the release version in the README.md — not applicable: existing behavior is preserved against the baseline above.
I have described the compatibility impact and the corresponding version number in the PR description
I have checked whether the plugin version is updated in the README.md
Available Checks
just build has passed
Relevant documentation has been updated (if necessary)
Validate embedding batches before acceptance and preserve index order
tests/regressions.md:20
This pins behavior that contradicts #394 while the PR closes that issue. The issue requires validating each embedding batch’s shape, indices, and finite values before accepting it or sending the next batch, but the linked tests explicitly accept missing/duplicate/out-of-range indices, non-finite vectors, and provider-order attachment. Either implement those validations (and index-based ordering) or leave #394 open and track this requirement separately.
This issue also appears in the following locations of the same file:
The advertised HTTP-response cleanup is incomplete: only the TTS path is made context-managed here, while openai_compatible/text_embedding.py:127, rerank.py:84, and speech2text.py:53 still create responses without closing them. In particular, embedding and rerank HTTP-error paths raise before consuming the body, so connections can remain occupied until garbage collection. Apply the same guaranteed cleanup to every response-owning model path.
Using the response as a context manager allows an exception from Response.close() to replace the actual request/streaming error; it can also make validate_credentials() reject valid credentials after the sample chunk succeeded. The existing LLM and embedding HTTP paths explicitly suppress cleanup failures (openai_compatible/llm.py:331-333 and text_embedding.py:222-224) to preserve the primary result. Please close this response in a finally block under suppress(Exception) as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SDK calls can leak HTTP responses and generators, interleave TCP frames, or leave CLI readers blocked after the child process exits.
This fixes cleanup on completion, failure and cancellation, serializes TCP writes, and handles reconnects and CLI/Serverless shutdown.
Also fixes tool-action and trigger registration, SSE line endings and event fields, manifest revalidation, and schema/documentation errors.
Public behavior and provider hooks are preserved against
mainat86e81e72(SDK 0.11.0).Tests cover all 37 dispatch actions using local HTTP/TLS services, sockets, subprocesses and an installed SDK wheel.
Validation at
b880bc18:just check,just build,just docs, prek hooks andgit diff --checkpassed.Remaining fixes: #397 (SSE comments/fields), #398 (Serverless error text), #399 (Agent token counting), #400 (literal stops), #401 (embedding validation).
#394 stays open for the full requirements.
Large datasource/Agent blobs can still exceed the daemon's 5 MiB frame limit after base64 encoding.
Deployed Dify, the released Go CLI, external APIs and sustained load were not tested.
Refs #394.
Replaces #395.
Pull Request Checklist
Compatibility Check
README.mdREADME.mdREADME.md— not applicable: existing behavior is preserved against the baseline above.README.mdAvailable Checks
just buildhas passed