@@ -5,6 +5,7 @@ import { join } from "node:path";
55import { test } from "node:test" ;
66import { createApp } from "../apps/server/src/app.ts" ;
77import { createStore } from "../apps/server/src/db.ts" ;
8+ import { createDemoModel , demoModel } from "../apps/server/src/demo/model.ts" ;
89import type { ActionProposal } from "../packages/domain/src/index.ts" ;
910import { fixture as computerFixture } from "./helpers/computer.ts" ;
1011import { modelFixture } from "./helpers/model.ts" ;
@@ -115,3 +116,51 @@ test("CopilotKit model worker executes server tools and persists the confirmed o
115116 await rm ( directory , { recursive : true , force : true } ) ;
116117 }
117118} ) ;
119+
120+ test ( "the model worker keeps the text a model replies with when it calls no tool" , async ( t ) => {
121+ const directory = await mkdtemp ( join ( tmpdir ( ) , "openmuse-model-text-" ) ) ;
122+ const db = await createStore ( ) ;
123+ const mock = createDemoModel ( { latency : 0 , firstByteDelay : 0 } ) ;
124+ await mock . start ( ) ;
125+ const previousBase = process . env . OPENAI_BASE_URL ;
126+ const previousKey = process . env . OPENAI_API_KEY ;
127+ process . env . OPENAI_BASE_URL = `${ mock . url } /v1` ;
128+ process . env . OPENAI_API_KEY = "local-demo-test" ;
129+ t . after ( async ( ) => {
130+ if ( previousBase === undefined ) delete process . env . OPENAI_BASE_URL ;
131+ else process . env . OPENAI_BASE_URL = previousBase ;
132+ if ( previousKey === undefined ) delete process . env . OPENAI_API_KEY ;
133+ else process . env . OPENAI_API_KEY = previousKey ;
134+ await mock . stop ( ) ;
135+ } ) ;
136+ const server = await createApp ( db , {
137+ mode : "sample" ,
138+ port : 8787 ,
139+ host : "127.0.0.1" ,
140+ publicUrl : "http://localhost:8787" ,
141+ dataDir : directory ,
142+ agentBackend : "model" ,
143+ intelligenceApiKey : "test-project-key-never-sent" ,
144+ model : demoModel ,
145+ googleRedirectUri : "http://localhost:8787/api/google/callback" ,
146+ allowedOrigins : [ ] ,
147+ } ) ;
148+ try {
149+ const task = await server . agent . createTask ( "owner" , { prompt : "Plan my week" } ) ;
150+ await server . agent . worker . tick ( ) ;
151+ const result = await server . agent . detail ( "owner" , task . id ) ;
152+ assert . equal ( result . task . status , "waiting_input" ) ;
153+ assert . match ( String ( result . task . state . lastUpdate ) , / F i n d c o o l s t u f f o n H a c k e r N e w s / ) ;
154+ assert . ok (
155+ result . events . some (
156+ ( event ) =>
157+ event . title === "Agent update" && / F i n d c o o l s t u f f o n H a c k e r N e w s / . test ( event . detail ) ,
158+ ) ,
159+ "the reply is recorded in the task timeline" ,
160+ ) ;
161+ } finally {
162+ await server . agent . stop ( ) ;
163+ await db . close ( ) ;
164+ await rm ( directory , { recursive : true , force : true } ) ;
165+ }
166+ } ) ;
0 commit comments