@@ -77,8 +77,6 @@ type SubSessionConfig struct {
7777 Title string
7878 // ToolsApproved overrides whether tools are pre-approved in the child session.
7979 ToolsApproved bool
80- // Thinking propagates the parent's thinking-mode flag.
81- Thinking bool
8280 // PinAgent, when true, pins the child session to AgentName via
8381 // session.WithAgentName. This is required for concurrent background
8482 // tasks that must not share the runtime's mutable currentAgent field.
@@ -110,7 +108,7 @@ func newSubSession(parent *session.Session, cfg SubSessionConfig, childAgent *ag
110108 session .WithMaxConsecutiveToolCalls (childAgent .MaxConsecutiveToolCalls ()),
111109 session .WithTitle (cfg .Title ),
112110 session .WithToolsApproved (cfg .ToolsApproved ),
113- session .WithThinking (cfg . Thinking ),
111+ session .WithThinking (childAgent . ThinkingConfigured () ),
114112 session .WithSendUserMessage (false ),
115113 session .WithParentID (parent .ID ),
116114 }
@@ -121,8 +119,8 @@ func newSubSession(parent *session.Session, cfg SubSessionConfig, childAgent *ag
121119}
122120
123121// runSubSessionForwarding runs a child session within the parent, forwarding all
124- // events to the caller's event channel and propagating session state (tool
125- // approvals, thinking) back to the parent when done.
122+ // events to the caller's event channel and propagating tool approval state
123+ // back to the parent when done.
126124//
127125// This is the "interactive" path used by transfer_task where the parent agent
128126// loop is blocked while the child executes.
@@ -137,7 +135,6 @@ func (r *LocalRuntime) runSubSessionForwarding(ctx context.Context, parent, chil
137135 }
138136
139137 parent .ToolsApproved = child .ToolsApproved
140- parent .Thinking = child .Thinking
141138
142139 parent .AddSubSession (child )
143140 evts <- SubSessionCompleted (parent .ID , child , callerAgent )
@@ -216,7 +213,6 @@ func (r *LocalRuntime) RunAgent(ctx context.Context, params agenttool.RunParams)
216213 AgentName : params .AgentName ,
217214 Title : "Background agent task" ,
218215 ToolsApproved : true ,
219- Thinking : sess .Thinking ,
220216 PinAgent : true ,
221217 }
222218
@@ -252,43 +248,35 @@ func (r *LocalRuntime) handleTaskTransfer(ctx context.Context, sess *session.Ses
252248
253249 slog .Debug ("Transferring task to agent" , "from_agent" , a .Name (), "to_agent" , params .Agent , "task" , params .Task )
254250
255- ca := r .CurrentAgentName ()
256-
257251 // Emit agent switching start event
258- evts <- AgentSwitching (true , ca , params .Agent )
252+ evts <- AgentSwitching (true , a . Name () , params .Agent )
259253
260254 r .setCurrentAgent (params .Agent )
261255 defer func () {
262- r .setCurrentAgent (ca )
256+ r .setCurrentAgent (a . Name () )
263257
264258 // Emit agent switching end event
265- evts <- AgentSwitching (false , params .Agent , ca )
259+ evts <- AgentSwitching (false , params .Agent , a . Name () )
266260
267261 // Restore original agent info in sidebar
268- if originalAgent , err := r .team .Agent (ca ); err == nil {
269- evts <- AgentInfo (originalAgent .Name (), getAgentModelID (originalAgent ), originalAgent .Description (), originalAgent .WelcomeMessage ())
270- }
262+ evts <- AgentInfo (a .Name (), getAgentModelID (a ), a .Description (), a .WelcomeMessage ())
271263 }()
272264
273265 // Emit agent info for the new agent
274- if newAgent , err := r .team .Agent (params .Agent ); err == nil {
275- evts <- AgentInfo (newAgent .Name (), getAgentModelID (newAgent ), newAgent .Description (), newAgent .WelcomeMessage ())
276- }
277-
278- slog .Debug ("Creating new session with parent session" , "parent_session_id" , sess .ID , "tools_approved" , sess .ToolsApproved , "thinking" , sess .Thinking )
279-
280266 child , err := r .team .Agent (params .Agent )
281267 if err != nil {
282268 return nil , err
283269 }
270+ evts <- AgentInfo (child .Name (), getAgentModelID (child ), child .Description (), child .WelcomeMessage ())
271+
272+ slog .Debug ("Creating new session with parent session" , "parent_session_id" , sess .ID , "tools_approved" , sess .ToolsApproved )
284273
285274 cfg := SubSessionConfig {
286275 Task : params .Task ,
287276 ExpectedOutput : params .ExpectedOutput ,
288277 AgentName : params .Agent ,
289278 Title : "Transferred task" ,
290279 ToolsApproved : sess .ToolsApproved ,
291- Thinking : sess .Thinking ,
292280 }
293281
294282 s := newSubSession (sess , cfg , child )
0 commit comments