From 5980b06f582927c1ca45dea71b37872abbd56596 Mon Sep 17 00:00:00 2001 From: Niall Faughnan <6485010+faughnn@users.noreply.github.com> Date: Wed, 12 Aug 2026 14:29:29 +0100 Subject: [PATCH] notebooklm: send audio custom instructions as UniversalAudioDetails.prompt Custom instructions for an Audio Overview were unusable: any non-empty instruction string failed with InvalidInput (API error 3 on R7cb6c). CreateAudioOverviewWithOptions gated the CreateUniversalArtifact path on opts.Instructions == "", so supplying instructions diverted the request to the legacy CreateAudioOverviewRequest.custom_instructions field, which the server no longer accepts. UniversalAudioDetails already carries a prompt field (field 1) for exactly this, but it was never populated. Populate prompt from opts.Instructions and drop the emptiness condition, so instructions travel on the modern request instead of diverting to the legacy one. Adds a round-trip test pinning prompt at wire index 0, since a silent regression there drops the steer without surfacing an error. Verified against the live API: instructions are accepted and honoured. A generated overview instructed to open with a specific marker phrase began with exactly that phrase, where the same request previously errored. --- notebooklm/audio_prompt_proto_test.go | 61 +++++++++++++++++++++++++++ notebooklm/client_audio.go | 7 ++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 notebooklm/audio_prompt_proto_test.go diff --git a/notebooklm/audio_prompt_proto_test.go b/notebooklm/audio_prompt_proto_test.go new file mode 100644 index 00000000..20fabc94 --- /dev/null +++ b/notebooklm/audio_prompt_proto_test.go @@ -0,0 +1,61 @@ +package notebooklm + +import ( + "encoding/json" + "reflect" + "testing" + + pb "github.com/tmc/nlm/gen/notebooklm/v1alpha1" + "github.com/tmc/nlm/internal/beprotojson" +) + +// TestUniversalAudioDetailsPromptRoundTrip pins the wire position of the audio +// steer. Custom instructions for an Audio Overview travel in +// UniversalAudioDetails.prompt (field 1) on CreateUniversalArtifact; the legacy +// CreateAudioOverviewRequest.custom_instructions path is rejected by the server. +// If prompt ever stops encoding at index 0, instructions are silently dropped and +// the audio is generated with default treatment, which is not an observable error. +func TestUniversalAudioDetailsPromptRoundTrip(t *testing.T) { + wire := []interface{}{ + "fabricated audio steer", + float64(1), + nil, + nil, + "en", + nil, + float64(2), + } + data, err := json.Marshal(wire) + if err != nil { + t.Fatal(err) + } + + var got pb.UniversalAudioDetails + if err := beprotojson.Unmarshal(data, &got); err != nil { + t.Fatal(err) + } + if got.GetPrompt() != "fabricated audio steer" { + t.Fatalf("prompt = %q, want %q", got.GetPrompt(), "fabricated audio steer") + } + if got.GetStyle() != 1 { + t.Fatalf("style = %d, want 1", got.GetStyle()) + } + if got.GetLanguage() != "en" { + t.Fatalf("language = %q, want %q", got.GetLanguage(), "en") + } + if got.GetEnabled() != 2 { + t.Fatalf("enabled = %d, want 2", got.GetEnabled()) + } + + encoded, err := beprotojson.Marshal(&got) + if err != nil { + t.Fatal(err) + } + var roundTrip interface{} + if err := json.Unmarshal(encoded, &roundTrip); err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(roundTrip, wire) { + t.Fatalf("round trip = %#v, want %#v", roundTrip, wire) + } +} diff --git a/notebooklm/client_audio.go b/notebooklm/client_audio.go index ddda08fe..72afafb2 100644 --- a/notebooklm/client_audio.go +++ b/notebooklm/client_audio.go @@ -49,7 +49,11 @@ func (c *Client) CreateAudioOverviewWithOptions(ctx context.Context, projectID s if len(sourceIDs) == 0 { return nil, fmt.Errorf("project has no sources - add sources before creating audio overview") } - if opts.Instructions == "" && opts.AudioType == pb.AudioType_AUDIO_TYPE_DEEP_DIVE && + // Custom instructions travel in UniversalAudioDetails.prompt. The legacy + // CreateAudioOverviewRequest.custom_instructions path below is rejected by + // the server (InvalidInput on R7cb6c), so instructions must not divert the + // request away from CreateUniversalArtifact. + if opts.AudioType == pb.AudioType_AUDIO_TYPE_DEEP_DIVE && opts.Length == pb.AudioLength_AUDIO_LENGTH_DEFAULT && opts.Language == "en" { audioSources := make([]*pb.SourceIdList, 0, len(sourceIDs)) for _, sourceID := range sourceIDs { @@ -62,6 +66,7 @@ func (c *Client) CreateAudioOverviewWithOptions(ctx context.Context, projectID s Kind: 1, SourceGroups: universalArtifactSourceGroups(sourceIDs), Audio: &pb.UniversalAudioOptions{Details: &pb.UniversalAudioDetails{ + Prompt: opts.Instructions, Style: int32(opts.Length), Sources: audioSources, Language: opts.Language,