@@ -36,15 +36,14 @@ type Run struct {
36
36
wait func ()
37
37
basicCommand bool
38
38
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
48
47
}
49
48
50
49
// Text returns the text output of the gptscript. It blocks until the output is ready.
@@ -104,7 +103,7 @@ func (r *Run) RespondingTool() Tool {
104
103
}
105
104
106
105
// 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 {
108
107
r .callsLock .RLock ()
109
108
defer r .callsLock .RUnlock ()
110
109
return maps .Clone (r .calls )
@@ -115,11 +114,7 @@ func (r *Run) ParentCallFrame() (CallFrame, bool) {
115
114
r .callsLock .RLock ()
116
115
defer r .callsLock .RUnlock ()
117
116
118
- if r .parentCallFrameID == "" {
119
- return CallFrame {}, false
120
- }
121
-
122
- return r .calls [r .parentCallFrameID ], true
117
+ return r .calls .ParentCallFrame (), true
123
118
}
124
119
125
120
// ErrorOutput returns the stderr output of the gptscript.
@@ -394,9 +389,6 @@ func (r *Run) request(ctx context.Context, payload any) (err error) {
394
389
if event .Call != nil {
395
390
r .callsLock .Lock ()
396
391
r .calls [event .Call .ID ] = * event .Call
397
- if r .parentCallFrameID == "" && event .Call .ParentID == "" {
398
- r .parentCallFrameID = event .Call .ID
399
- }
400
392
r .callsLock .Unlock ()
401
393
} else if event .Run != nil {
402
394
if event .Run .Type == EventTypeRunStart {
0 commit comments