@@ -36,15 +36,14 @@ type Run struct {
3636 wait func ()
3737 basicCommand bool
3838
39- program * Program
40- callsLock sync.RWMutex
41- calls map [string ]CallFrame
42- parentCallFrameID string
43- rawOutput map [string ]any
44- output , errput string
45- events chan Frame
46- lock sync.Mutex
47- responseCode int
39+ program * Program
40+ callsLock sync.RWMutex
41+ calls CallFrames
42+ rawOutput map [string ]any
43+ output , errput string
44+ events chan Frame
45+ lock sync.Mutex
46+ responseCode int
4847}
4948
5049// Text returns the text output of the gptscript. It blocks until the output is ready.
@@ -104,7 +103,7 @@ func (r *Run) RespondingTool() Tool {
104103}
105104
106105// Calls will return a flattened array of the calls for this run.
107- func (r * Run ) Calls () map [ string ] CallFrame {
106+ func (r * Run ) Calls () CallFrames {
108107 r .callsLock .RLock ()
109108 defer r .callsLock .RUnlock ()
110109 return maps .Clone (r .calls )
@@ -115,11 +114,7 @@ func (r *Run) ParentCallFrame() (CallFrame, bool) {
115114 r .callsLock .RLock ()
116115 defer r .callsLock .RUnlock ()
117116
118- if r .parentCallFrameID == "" {
119- return CallFrame {}, false
120- }
121-
122- return r .calls [r .parentCallFrameID ], true
117+ return r .calls .ParentCallFrame (), true
123118}
124119
125120// ErrorOutput returns the stderr output of the gptscript.
@@ -394,9 +389,6 @@ func (r *Run) request(ctx context.Context, payload any) (err error) {
394389 if event .Call != nil {
395390 r .callsLock .Lock ()
396391 r .calls [event .Call .ID ] = * event .Call
397- if r .parentCallFrameID == "" && event .Call .ParentID == "" {
398- r .parentCallFrameID = event .Call .ID
399- }
400392 r .callsLock .Unlock ()
401393 } else if event .Run != nil {
402394 if event .Run .Type == EventTypeRunStart {
0 commit comments