fix: complete Kling idempotency inputs

Include every request field that can alter Kling video, image, avatar, or lip-sync media in the public idempotency contract. Add a shared regression matrix that detects future cache-key collisions while excluding transport-only controls.
This commit is contained in:
xucailiang
2026-07-10 21:24:11 +08:00
parent b9b9b82b64
commit 6b9ba782d8
5 changed files with 163 additions and 3 deletions

View File

@@ -124,7 +124,17 @@ class KlingAvatar(BaseTool):
backoff_seconds=2.0,
retryable_errors=["1302", "1303", "5000", "5001", "5002"],
)
idempotency_key_fields = ["image_url", "image_path", "audio_id", "sound_file", "sound_file_path", "mode"]
idempotency_key_fields = [
"image_url",
"image_path",
"audio_id",
"sound_file",
"sound_file_url",
"sound_file_path",
"audio_path",
"prompt",
"mode",
]
side_effects = ["paid remote generation via official Kling API", "writes avatar video to output_path"]
user_visible_verification = ["Watch generated avatar video for identity preservation and mouth motion"]
quality_score = 0.82

View File

@@ -139,15 +139,23 @@ class KlingLipSync(BaseTool):
retryable_errors=["1302", "1303", "5000", "5001", "5002"],
)
idempotency_key_fields = [
"operation",
"video_id",
"video_url",
"session_id",
"face_id",
"face_choose",
"auto_select_face",
"audio_id",
"sound_file",
"sound_file_url",
"sound_file_path",
"audio_path",
"sound_start_time",
"sound_end_time",
"sound_insert_time",
"sound_volume",
"original_audio_volume",
]
side_effects = [
"paid remote generation via official Kling API",

View File

@@ -122,13 +122,25 @@ class KlingOfficialImage(BaseTool):
)
idempotency_key_fields = [
"prompt",
"negative_prompt",
"operation",
"api_family",
"model_name",
"image_url",
"image_path",
"image_urls",
"image_paths",
"image_list",
"image_reference",
"image_fidelity",
"human_fidelity",
"aspect_ratio",
"resolution",
"n",
"result_type",
"series_amount",
"element_list",
"watermark",
]
side_effects = [
"paid remote generation via official Kling API",

View File

@@ -142,13 +142,33 @@ class KlingOfficialVideo(BaseTool):
)
idempotency_key_fields = [
"prompt",
"negative_prompt",
"operation",
"api_family",
"model_name",
"reference_image_url",
"reference_image_path",
"model_variant",
"duration",
"aspect_ratio",
"resolution",
"mode",
"sound",
"cfg_scale",
"camera_control",
"reference_image_url",
"reference_image_path",
"reference_tail_image_url",
"reference_tail_image_path",
"reference_image_urls",
"reference_image_paths",
"reference_video_url",
"video_urls",
"image_list",
"video_list",
"element_list",
"multi_shot",
"shot_type",
"multi_prompt",
"watermark",
]
side_effects = [
"paid remote generation via official Kling API",