feat: align Go/Node DSML tool-call parsing drift tolerance and update API docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
CJACK
2026-05-10 16:17:46 +08:00
parent cee8757d14
commit eaeb403fda
32 changed files with 879 additions and 102 deletions

View File

@@ -6,6 +6,7 @@ import (
"encoding/base64"
"encoding/hex"
"encoding/json"
"errors"
"io"
"net/http"
"strings"
@@ -39,6 +40,31 @@ func TestBuildUploadMultipartBodyOmitsPurposeAndIncludesFilePart(t *testing.T) {
}
}
func TestDoUploadDoesNotFallbackForNonIdempotentUpload(t *testing.T) {
var fallbackCalled bool
client := &Client{}
_, err := client.doUpload(
context.Background(),
doerFunc(func(req *http.Request) (*http.Response, error) {
_, _ = io.ReadAll(req.Body)
return nil, errors.New("ambiguous upload write failure")
}),
doerFunc(func(*http.Request) (*http.Response, error) {
fallbackCalled = true
return &http.Response{StatusCode: http.StatusOK, Header: make(http.Header), Body: io.NopCloser(strings.NewReader("{}"))}, nil
}),
dsprotocol.DeepSeekUploadFileURL,
map[string]string{"Content-Type": "multipart/form-data"},
[]byte("body"),
)
if err == nil {
t.Fatal("expected upload error")
}
if fallbackCalled {
t.Fatal("upload fallback should not be called for a non-idempotent request")
}
}
func TestExtractUploadFileResultSupportsNestedShapes(t *testing.T) {
got := extractUploadFileResult(map[string]any{
"data": map[string]any{