@@ -287,3 +287,114 @@ func TestIsThinkingBudgetDisabled(t *testing.T) {
287287 })
288288 }
289289}
290+
291+ func TestWithPromptFiles (t * testing.T ) {
292+ t .Setenv ("OPENAI_API_KEY" , "dummy" )
293+
294+ tests := []struct {
295+ name string
296+ cliPromptFiles []string
297+ expected []string
298+ }{
299+ {
300+ name : "no CLI prompt files" ,
301+ cliPromptFiles : nil ,
302+ expected : []string {}, // basic.yaml has no add_prompt_files
303+ },
304+ {
305+ name : "single CLI prompt file" ,
306+ cliPromptFiles : []string {"AGENTS.md" },
307+ expected : []string {"AGENTS.md" },
308+ },
309+ {
310+ name : "multiple CLI prompt files" ,
311+ cliPromptFiles : []string {"AGENTS.md" , "CLAUDE.md" },
312+ expected : []string {"AGENTS.md" , "CLAUDE.md" },
313+ },
314+ }
315+
316+ for _ , tt := range tests {
317+ t .Run (tt .name , func (t * testing.T ) {
318+ agentSource , err := config .Resolve ("testdata/basic.yaml" , nil )
319+ require .NoError (t , err )
320+
321+ var opts []Opt
322+ if len (tt .cliPromptFiles ) > 0 {
323+ opts = append (opts , WithPromptFiles (tt .cliPromptFiles ))
324+ }
325+
326+ team , err := Load (t .Context (), agentSource , & config.RuntimeConfig {}, opts ... )
327+ require .NoError (t , err )
328+
329+ rootAgent , err := team .Agent ("root" )
330+ require .NoError (t , err )
331+
332+ assert .Equal (t , tt .expected , rootAgent .AddPromptFiles ())
333+ })
334+ }
335+ }
336+
337+ func TestWithPromptFilesMergesWithConfig (t * testing.T ) {
338+ t .Setenv ("OPENAI_API_KEY" , "dummy" )
339+
340+ // Create a temp agent file with add_prompt_files configured
341+ tempDir := t .TempDir ()
342+ agentFile := filepath .Join (tempDir , "agent.yaml" )
343+ agentYAML := `version: "2"
344+ agents:
345+ root:
346+ model: openai/gpt-4o
347+ instruction: test
348+ add_prompt_files:
349+ - config-file.md
350+ `
351+ require .NoError (t , os .WriteFile (agentFile , []byte (agentYAML ), 0o644 ))
352+
353+ agentSource , err := config .Resolve (agentFile , nil )
354+ require .NoError (t , err )
355+
356+ // Load with CLI prompt files - should merge with config
357+ team , err := Load (t .Context (), agentSource , & config.RuntimeConfig {},
358+ WithPromptFiles ([]string {"cli-file.md" }))
359+ require .NoError (t , err )
360+
361+ rootAgent , err := team .Agent ("root" )
362+ require .NoError (t , err )
363+
364+ // Config files come first, then CLI files
365+ expected := []string {"config-file.md" , "cli-file.md" }
366+ assert .Equal (t , expected , rootAgent .AddPromptFiles ())
367+ }
368+
369+ func TestWithPromptFilesDeduplicates (t * testing.T ) {
370+ t .Setenv ("OPENAI_API_KEY" , "dummy" )
371+
372+ // Create a temp agent file with add_prompt_files configured
373+ tempDir := t .TempDir ()
374+ agentFile := filepath .Join (tempDir , "agent.yaml" )
375+ agentYAML := `version: "2"
376+ agents:
377+ root:
378+ model: openai/gpt-4o
379+ instruction: test
380+ add_prompt_files:
381+ - AGENTS.md
382+ - CLAUDE.md
383+ `
384+ require .NoError (t , os .WriteFile (agentFile , []byte (agentYAML ), 0o644 ))
385+
386+ agentSource , err := config .Resolve (agentFile , nil )
387+ require .NoError (t , err )
388+
389+ // CLI specifies a file that's already in config - should deduplicate
390+ team , err := Load (t .Context (), agentSource , & config.RuntimeConfig {},
391+ WithPromptFiles ([]string {"AGENTS.md" , "extra.md" }))
392+ require .NoError (t , err )
393+
394+ rootAgent , err := team .Agent ("root" )
395+ require .NoError (t , err )
396+
397+ // AGENTS.md should only appear once (from config), extra.md added at end
398+ expected := []string {"AGENTS.md" , "CLAUDE.md" , "extra.md" }
399+ assert .Equal (t , expected , rootAgent .AddPromptFiles ())
400+ }
0 commit comments