Skip to content

Commit a89374a

Browse files
committed
Fix --attach flag being silently ignored without a message argument
When running 'docker-agent run --attach image.png' without a message, readInitialMessage returns nil, so WithFirstMessage was never called. This caused SendFirstMessage to return nil immediately, silently discarding the attachment. Synthesize an empty default first message when --attach is provided without an explicit message, so SendFirstMessage proceeds to process the attachment. The downstream CreateUserMessageWithAttachment already handles empty text by substituting a default prompt. Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
1 parent e20da46 commit a89374a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

cmd/root/run.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,11 @@ func (f *runExecFlags) buildAppOpts(args []string) ([]app.Opt, error) {
485485
var opts []app.Opt
486486
if firstMessage != nil {
487487
opts = append(opts, app.WithFirstMessage(*firstMessage))
488+
} else if f.attachmentPath != "" {
489+
// When --attach is used without an explicit message, provide a default
490+
// so that SendFirstMessage processes the attachment.
491+
defaultMsg := ""
492+
opts = append(opts, app.WithFirstMessage(defaultMsg))
488493
}
489494
if len(args) > 2 {
490495
opts = append(opts, app.WithQueuedMessages(args[2:]))

0 commit comments

Comments
 (0)