@@ -44,6 +44,7 @@ import { Truncate } from "@/tool/truncate"
4444import { decodeDataUrl } from "@/util/data-url"
4545import { Process } from "@/util/process"
4646import { Cause , Effect , Exit , Layer , Option , Scope , ServiceMap } from "effect"
47+ import { EffectLogger } from "@/effect/logger"
4748import { InstanceState } from "@/effect/instance-state"
4849import { makeRuntime } from "@/effect/run-service"
4950import { TaskTool , type TaskPromptOps } from "@/tool/task"
@@ -64,6 +65,7 @@ const STRUCTURED_OUTPUT_SYSTEM_PROMPT = `IMPORTANT: The user has requested struc
6465
6566export namespace SessionPrompt {
6667 const log = Log . create ( { service : "session.prompt" } )
68+ const elog = EffectLogger . create ( { service : "session.prompt" } )
6769
6870 export interface Interface {
6971 readonly cancel : ( sessionID : SessionID ) => Effect . Effect < void >
@@ -102,7 +104,7 @@ export namespace SessionPrompt {
102104 const revert = yield * SessionRevert . Service
103105
104106 const cancel = Effect . fn ( "SessionPrompt.cancel" ) ( function * ( sessionID : SessionID ) {
105- log . info ( "cancel" , { sessionID } )
107+ yield * elog . info ( "cancel" , { sessionID } )
106108 yield * state . cancel ( sessionID )
107109 } )
108110
@@ -196,11 +198,7 @@ export namespace SessionPrompt {
196198 const t = cleaned . length > 100 ? cleaned . substring ( 0 , 97 ) + "..." : cleaned
197199 yield * sessions
198200 . setTitle ( { sessionID : input . session . id , title : t } )
199- . pipe (
200- Effect . catchCause ( ( cause ) =>
201- Effect . sync ( ( ) => log . error ( "failed to generate title" , { error : Cause . squash ( cause ) } ) ) ,
202- ) ,
203- )
201+ . pipe ( Effect . catchCause ( ( cause ) => elog . error ( "failed to generate title" , { error : Cause . squash ( cause ) } ) ) )
204202 } )
205203
206204 const insertReminders = Effect . fn ( "SessionPrompt.insertReminders" ) ( function * ( input : {
@@ -1302,13 +1300,14 @@ NOTE: At any point in time through this workflow you should feel free to ask the
13021300 const runLoop : ( sessionID : SessionID ) => Effect . Effect < MessageV2 . WithParts > = Effect . fn ( "SessionPrompt.run" ) (
13031301 function * ( sessionID : SessionID ) {
13041302 const ctx = yield * InstanceState . context
1303+ const slog = elog . with ( { sessionID } )
13051304 let structured : unknown | undefined
13061305 let step = 0
13071306 const session = yield * sessions . get ( sessionID )
13081307
13091308 while ( true ) {
13101309 yield * status . set ( sessionID , { type : "busy" } )
1311- log . info ( "loop" , { step, sessionID } )
1310+ yield * slog . info ( "loop" , { step } )
13121311
13131312 let msgs = yield * MessageV2 . filterCompactedEffect ( sessionID )
13141313
@@ -1344,7 +1343,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
13441343 ! hasToolCalls &&
13451344 lastUser . id < lastAssistant . id
13461345 ) {
1347- log . info ( "exiting loop" , { sessionID } )
1346+ yield * slog . info ( "exiting loop" )
13481347 break
13491348 }
13501349
@@ -1540,7 +1539,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
15401539 )
15411540
15421541 const command = Effect . fn ( "SessionPrompt.command" ) ( function * ( input : CommandInput ) {
1543- log . info ( "command" , input )
1542+ yield * elog . info ( "command" , { sessionID : input . sessionID , command : input . command , agent : input . agent } )
15441543 const cmd = yield * commands . get ( input . command )
15451544 if ( ! cmd ) {
15461545 const available = ( yield * commands . list ( ) ) . map ( ( c ) => c . name )
0 commit comments