@@ -19,7 +19,7 @@ package controller2
1919import (
2020 "context"
2121 "fmt"
22- "log"
22+ "log/slog "
2323
2424 "github.com/google/ax/internal/controller/executor"
2525 "github.com/google/ax/internal/harness/harnesstest"
@@ -76,7 +76,11 @@ func (d *Controller) Exec(ctx context.Context, req *proto.ExecRequest, handler E
7676 h , err := d .registry .Harness (req .AgentId )
7777 if err != nil {
7878 // Fallback to test harness
79- log .Printf ("WARNING: harness %s not found in registry, falling back to test harness: %v" , req .AgentId , err )
79+ slog .WarnContext (ctx , "Harness not found in registry, falling back to test harness" ,
80+ slog .String ("agent_id" , req .AgentId ),
81+ slog .String ("conversation_id" , req .ConversationId ),
82+ slog .Any ("error" , err ),
83+ )
8084 h = harnesstest .New ()
8185 }
8286 exec , err := h .Start (ctx , req .ConversationId )
@@ -128,7 +132,10 @@ func (a *harnessHandler) OnMessage(ctx context.Context, execID string, msg *prot
128132 }
129133 // TODO(anj): The harness should send the full input sent to get this particular response.
130134 if _ , err := a .eventLog .Append (ctx , event ); err != nil {
131- log .Printf ("WARNING: failed to log streamed message: %v" , err )
135+ slog .WarnContext (ctx , "Failed to log streamed message to event log" ,
136+ slog .String ("conversation_id" , a .conversationID ),
137+ slog .Any ("error" , err ),
138+ )
132139 }
133140
134141 if a .execHandler == nil {
@@ -147,7 +154,10 @@ func (a *harnessHandler) OnComplete(ctx context.Context, execID string) error {
147154 State : proto .State_STATE_COMPLETED ,
148155 }
149156 if _ , err := a .eventLog .Append (ctx , event ); err != nil {
150- log .Printf ("WARNING: failed to log completion event: %v" , err )
157+ slog .WarnContext (ctx , "Failed to log completion event to event log" ,
158+ slog .String ("conversation_id" , a .conversationID ),
159+ slog .Any ("error" , err ),
160+ )
151161 }
152162 return nil
153163}
0 commit comments