File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -256,13 +256,8 @@ export namespace Agent {
256256
257257 export async function defaultAgent ( ) {
258258 const agents = await list ( )
259- const primary = agents . find ( ( a ) => a . mode !== "subagent" && a . hidden !== true )
260- if ( primary ) return primary . name
261-
262- const visible = agents . find ( ( a ) => a . hidden !== true )
263- if ( visible ) return visible . name
264-
265- return "build"
259+ const primaryVisible = agents . find ( ( a ) => a . mode !== "subagent" && a . hidden !== true )
260+ return primaryVisible ?. name || "build"
266261 }
267262
268263 export async function generate ( input : { description : string ; model ?: { providerID : string ; modelID : string } } ) {
Original file line number Diff line number Diff line change @@ -513,8 +513,6 @@ test("explicit Truncate.DIR deny is respected", async () => {
513513 } )
514514} )
515515
516- // Tests for Agent.defaultAgent()
517-
518516test ( "defaultAgent returns build when no default_agent config" , async ( ) => {
519517 await using tmp = await tmpdir ( )
520518 await Instance . provide ( {
@@ -627,3 +625,22 @@ test("defaultAgent returns plan when build is disabled and default_agent not set
627625 } ,
628626 } )
629627} )
628+
629+ test ( "defaultAgent returns first primary-capable agent when all natives are disabled" , async ( ) => {
630+ await using tmp = await tmpdir ( {
631+ config : {
632+ agent : {
633+ build : { disable : true } ,
634+ plan : { disable : true } ,
635+ } ,
636+ } ,
637+ } )
638+ await Instance . provide ( {
639+ directory : tmp . path ,
640+ fn : async ( ) => {
641+ const agent = await Agent . defaultAgent ( )
642+ // build and plan are disabled, so it should return general
643+ expect ( agent ) . toBe ( "build" )
644+ } ,
645+ } )
646+ } )
You can’t perform that action at this time.
0 commit comments