@@ -380,15 +380,19 @@ describe("modelsAliasesAddCommand", () => {
380380 expect ( written . agents ?. defaults ?. models ?. [ "openai/gpt-5.4-mini" ] ?. alias ) . toBe ( "fast" ) ;
381381 } ) ;
382382
383- it ( "attaches the alias to the target named by the CAS-fenced snapshot, not a pre-command read" , async ( ) => {
384- // The config loaded at command start maps `target` to one model; by the time
385- // the write snapshot is taken another writer has remapped it. The write is
386- // fenced by the snapshot hash, so the alias must follow the snapshot's target.
383+ it ( "resolves alias targets from the CAS-fenced snapshot" , async ( ) => {
387384 const staleCfg = {
388- agents : { defaults : { models : { "openai/gpt-5.6-sol" : { alias : "target " } } } } ,
385+ agents : { defaults : { models : { "openai/gpt-5.6-sol" : { alias : "old-alias " } } } } ,
389386 } as unknown as OpenClawConfig ;
390387 const currentCfg = {
391- agents : { defaults : { models : { "anthropic/claude-opus-5" : { alias : "target" } } } } ,
388+ agents : {
389+ defaults : {
390+ models : {
391+ "openai/gpt-5.6-sol" : { params : { temperature : 0.2 } } ,
392+ "anthropic/claude-opus-5" : { alias : "old-alias" } ,
393+ } ,
394+ } ,
395+ } ,
392396 } as unknown as OpenClawConfig ;
393397 mocks . loadModelsConfig . mockResolvedValue ( staleCfg ) ;
394398 mocks . readConfigFileSnapshot . mockResolvedValue ( {
@@ -398,47 +402,24 @@ describe("modelsAliasesAddCommand", () => {
398402 mocks . replaceConfigFile . mockResolvedValue ( undefined ) ;
399403 const runtime = makeRuntime ( ) ;
400404
401- await modelsAliasesAddCommand ( "new-name " , "target " , runtime ) ;
405+ await modelsAliasesAddCommand ( "new-alias " , "old-alias " , runtime ) ;
402406
403- expect ( mocks . replaceConfigFile ) . toHaveBeenCalledOnce ( ) ;
404407 const [ replaceParams ] = mocks . replaceConfigFile . mock . calls [ 0 ] ?? [ ] ;
405408 expect ( replaceParams ?. baseHash ) . toBe ( "current-hash" ) ;
406409 expect ( replaceParams ?. nextConfig . agents ?. defaults ?. models ) . toEqual ( {
407- "anthropic/claude-opus-5" : { alias : "new-name" } ,
410+ "openai/gpt-5.6-sol" : { params : { temperature : 0.2 } } ,
411+ "anthropic/claude-opus-5" : { alias : "new-alias" } ,
408412 } ) ;
409- expect ( runtime . logs ) . toContain ( "Alias new-name -> anthropic/claude-opus-5" ) ;
413+ expect ( runtime . logs ) . toContain ( "Alias new-alias -> anthropic/claude-opus-5" ) ;
410414 } ) ;
411415
412- it . each ( [
413- {
414- label : "resolves a runtime-only alias while writing only source config" ,
415- sourceConfig : {
416- agents : { defaults : { models : { "anthropic/claude-sonnet-4-6" : { } } } } ,
417- } ,
418- runtimeConfig : {
419- agents : { defaults : { models : { "anthropic/claude-sonnet-4-6" : { alias : "sonnet" } } } } ,
420- } ,
421- expectedModels : { "anthropic/claude-sonnet-4-6" : { alias : "fast" } } ,
422- } ,
423- {
424- label : "keeps authored aliases ahead of runtime-only aliases" ,
425- sourceConfig : {
426- agents : { defaults : { models : { "openai/gpt-5.5" : { alias : "sonnet" } } } } ,
427- } ,
428- runtimeConfig : {
429- agents : {
430- defaults : {
431- models : {
432- "openai/gpt-5.5" : { alias : "sonnet" } ,
433- "anthropic/claude-sonnet-4-6" : { alias : "sonnet" } ,
434- } ,
435- } ,
436- } ,
437- } ,
438- expectedModels : { "openai/gpt-5.5" : { alias : "fast" } } ,
439- } ,
440- ] ) ( "$label (parity with models set)" , async ( { sourceConfig, runtimeConfig, expectedModels } ) => {
441- mocks . loadModelsConfig . mockResolvedValue ( runtimeConfig ) ;
416+ it ( "resolves a runtime-only alias while persisting only source config" , async ( ) => {
417+ const sourceConfig = {
418+ agents : { defaults : { models : { "anthropic/claude-sonnet-4-6" : { } } } } ,
419+ } ;
420+ const runtimeConfig = {
421+ agents : { defaults : { models : { "anthropic/claude-sonnet-4-6" : { alias : "sonnet" } } } } ,
422+ } ;
442423 mocks . readConfigFileSnapshot . mockResolvedValue ( {
443424 ...snapshot ( sourceConfig as unknown as OpenClawConfig ) ,
444425 runtimeConfig,
@@ -448,7 +429,9 @@ describe("modelsAliasesAddCommand", () => {
448429 await modelsAliasesAddCommand ( "fast" , "sonnet" , makeRuntime ( ) ) ;
449430
450431 const [ replaceParams ] = mocks . replaceConfigFile . mock . calls [ 0 ] ?? [ ] ;
451- expect ( replaceParams ?. nextConfig . agents ?. defaults ?. models ) . toEqual ( expectedModels ) ;
432+ expect ( replaceParams ?. nextConfig . agents ?. defaults ?. models ) . toEqual ( {
433+ "anthropic/claude-sonnet-4-6" : { alias : "fast" } ,
434+ } ) ;
452435 } ) ;
453436} ) ;
454437
0 commit comments