@@ -182,7 +182,6 @@ func (a *Agent) SharedState() *types.AgentSharedState {
182182
183183// SetStreamCallback sets (or replaces) the stream callback on a live agent.
184184// This allows callers to wire streaming events after agent creation,
185- // e.g. in distributed mode where the callback routes to NATS.
186185func (a * Agent ) SetStreamCallback (fn func (cogito.StreamEvent )) {
187186 a .options .streamCallback = fn
188187}
@@ -254,7 +253,7 @@ func (a *Agent) Ask(opts ...types.JobOption) *types.JobResult {
254253// AskDirect executes a job synchronously without requiring Run() to be active.
255254// Unlike Ask/Execute which enqueue to the internal jobQueue (consumed by Run()),
256255// AskDirect calls consumeJob directly. This enables stateless execution where
257- // the caller manages the event loop (e.g., NATS-based distributed execution).
256+ // the caller manages the event loop
258257func (a * Agent ) AskDirect (opts ... types.JobOption ) * types.JobResult {
259258 xlog .Debug ("Agent AskDirect()" , "agent" , a .Character .Name , "model" , a .options .LLMAPI .Model )
260259 defer func () {
@@ -1063,6 +1062,13 @@ func (a *Agent) consumeJob(job *types.Job, role string) {
10631062 if s == "" {
10641063 return
10651064 }
1065+ // Forward reasoning to stream callback
1066+ if a .options .streamCallback != nil {
1067+ a .options .streamCallback (cogito.StreamEvent {
1068+ Type : cogito .StreamEventReasoning ,
1069+ Content : s ,
1070+ })
1071+ }
10661072 if a .observer != nil && job .Obs != nil {
10671073 job .Obs .AddProgress (
10681074 types.Progress {
@@ -1154,6 +1160,19 @@ func (a *Agent) consumeJob(job *types.Job, role string) {
11541160 }
11551161 }
11561162
1163+ // Forward tool selection to stream callback
1164+ if a .options .streamCallback != nil {
1165+ toolName := tc .Name
1166+ if chosenAction != nil {
1167+ toolName = chosenAction .Definition ().Name .String ()
1168+ }
1169+ a .options .streamCallback (cogito.StreamEvent {
1170+ Type : cogito .StreamEventToolCall ,
1171+ ToolName : toolName ,
1172+ ToolArgs : fmt .Sprintf ("%v" , tc .Arguments ),
1173+ })
1174+ }
1175+
11571176 if a .observer != nil && job .Obs != nil {
11581177 obs := a .observer .NewObservable ()
11591178 obs .Name = "decision"
0 commit comments