@@ -522,13 +522,38 @@ func TestAgent_Generate_EmptyPrompt(t *testing.T) {
522522 model := & mockLanguageModel {}
523523 agent := NewAgent (model )
524524
525- result , err := agent .Generate (context .Background (), AgentCall {
526- Prompt : "" , // Empty prompt should cause error
525+ t .Run ("fails without historical messages" , func (t * testing.T ) {
526+ result , err := agent .Generate (context .Background (), AgentCall {
527+ Prompt : "" ,
528+ })
529+ require .Error (t , err )
530+ require .Nil (t , result )
531+ require .Contains (t , err .Error (), "invalid argument: prompt can't be empty" )
532+ })
533+
534+ t .Run ("fails when there are files even with historical messages" , func (t * testing.T ) {
535+ result , err := agent .Generate (context .Background (), AgentCall {
536+ Prompt : "" ,
537+ Messages : []Message {
538+ {Role : MessageRoleUser , Content : []MessagePart {TextPart {Text : "hello" }}},
539+ },
540+ Files : []FilePart {{Filename : "test.txt" , Data : []byte ("test" ), MediaType : "text/plain" }},
541+ })
542+ require .Error (t , err )
543+ require .Nil (t , result )
544+ require .Contains (t , err .Error (), "invalid argument: prompt can't be empty" )
527545 })
528546
529- require .Error (t , err )
530- require .Nil (t , result )
531- require .Contains (t , err .Error (), "invalid argument: prompt can't be empty" )
547+ t .Run ("succeeds if there are historical messages and no files" , func (t * testing.T ) {
548+ result , err := agent .Generate (context .Background (), AgentCall {
549+ Prompt : "" ,
550+ Messages : []Message {
551+ {Role : MessageRoleUser , Content : []MessagePart {TextPart {Text : "hello" }}},
552+ },
553+ })
554+ require .NoError (t , err )
555+ require .NotNil (t , result )
556+ })
532557}
533558
534559// Test with system prompt
0 commit comments