From faf66cf453a163a33f426ef12402e2254c67a110 Mon Sep 17 00:00:00 2001 From: viettranx Date: Sun, 8 Mar 2026 23:05:53 +0700 Subject: [PATCH] fix(tools): remove unsupported duration_seconds param from MiniMax music API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MiniMax music generation API silently ignores duration_seconds — audio length is determined by lyrics length (vocal) or model default (~3-4 min for instrumental). Updated tool description to clarify this limitation. --- internal/tools/create_audio.go | 7 ++----- internal/tools/create_audio_minimax.go | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/internal/tools/create_audio.go b/internal/tools/create_audio.go index 182baedb..56380508 100644 --- a/internal/tools/create_audio.go +++ b/internal/tools/create_audio.go @@ -40,7 +40,7 @@ func NewCreateAudioTool(registry *providers.Registry, elevenlabsKey, elevenlabsB func (t *CreateAudioTool) Name() string { return "create_audio" } func (t *CreateAudioTool) Description() string { - return "Generate music, sound effects, or ambient audio from a text description. Returns a MEDIA: path to the generated audio file." + return "Generate music, sound effects, or ambient audio from a text description. Returns a MEDIA: path to the generated audio file. Note: for music, duration is determined by lyrics length — provide longer/shorter lyrics to control length. The 'duration' parameter only applies to sound effects." } func (t *CreateAudioTool) Parameters() map[string]interface{} { @@ -57,7 +57,7 @@ func (t *CreateAudioTool) Parameters() map[string]interface{} { }, "duration": map[string]interface{}{ "type": "integer", - "description": "Duration in seconds.", + "description": "Duration in seconds (only for sound effects). For music, duration is controlled by lyrics length.", }, "lyrics": map[string]interface{}{ "type": "string", @@ -125,9 +125,6 @@ func (t *CreateAudioTool) Execute(ctx context.Context, args map[string]interface chain[i].Params["prompt"] = prompt chain[i].Params["lyrics"] = lyrics chain[i].Params["instrumental"] = instrumental - if duration > 0 { - chain[i].Params["duration"] = duration - } } // Override timeout to 300s for music generation (slow API). diff --git a/internal/tools/create_audio_minimax.go b/internal/tools/create_audio_minimax.go index 51337932..be35cd80 100644 --- a/internal/tools/create_audio_minimax.go +++ b/internal/tools/create_audio_minimax.go @@ -27,7 +27,8 @@ func callMinimaxMusicGen(ctx context.Context, apiKey, apiBase, model, prompt str instrumental = true } - duration := GetParamInt(params, "duration", 0) + // NOTE: MiniMax music API does NOT support a duration parameter. + // Audio length is determined by lyrics length (vocal) or the model's default (~3-4 min for instrumental). body := map[string]interface{}{ "model": model, @@ -44,9 +45,6 @@ func callMinimaxMusicGen(ctx context.Context, apiKey, apiBase, model, prompt str if lyrics != "" { body["lyrics"] = lyrics } - if duration > 0 { - body["duration_seconds"] = duration - } jsonBody, err := json.Marshal(body) if err != nil {