@@ -59,6 +59,7 @@ type CallResult struct {
59
59
type commonContext struct {
60
60
ID string `json:"id"`
61
61
Tool types.Tool `json:"tool"`
62
+ CurrentAgent types.ToolReference `json:"currentAgent,omitempty"`
62
63
AgentGroup []types.ToolReference `json:"agentGroup,omitempty"`
63
64
InputContext []InputContext `json:"inputContext"`
64
65
ToolCategory ToolCategory `json:"toolCategory,omitempty"`
@@ -73,10 +74,11 @@ type CallContext struct {
73
74
74
75
type Context struct {
75
76
commonContext
76
- Ctx context.Context
77
- Parent * Context
78
- LastReturn * Return
79
- Program * types.Program
77
+ Ctx context.Context
78
+ Parent * Context
79
+ LastReturn * Return
80
+ CurrentReturn * Return
81
+ Program * types.Program
80
82
// Input is saved only so that we can render display text, don't use otherwise
81
83
Input string
82
84
}
@@ -129,6 +131,18 @@ func (c *Context) ParentID() string {
129
131
return c .Parent .ID
130
132
}
131
133
134
+ func (c * Context ) CurrentAgent () types.ToolReference {
135
+ for _ , ref := range c .AgentGroup {
136
+ if ref .ToolID == c .Tool .ID {
137
+ return ref
138
+ }
139
+ }
140
+ if c .Parent != nil {
141
+ return c .Parent .CurrentAgent ()
142
+ }
143
+ return types.ToolReference {}
144
+ }
145
+
132
146
func (c * Context ) GetCallContext () * CallContext {
133
147
var toolName string
134
148
if c .Parent != nil {
@@ -143,12 +157,15 @@ func (c *Context) GetCallContext() *CallContext {
143
157
}
144
158
}
145
159
146
- return & CallContext {
160
+ result := & CallContext {
147
161
commonContext : c .commonContext ,
148
162
ParentID : c .ParentID (),
149
163
ToolName : toolName ,
150
164
DisplayText : types .ToDisplayText (c .Tool , c .Input ),
151
165
}
166
+
167
+ result .CurrentAgent = c .CurrentAgent ()
168
+ return result
152
169
}
153
170
154
171
func (c * Context ) UnmarshalJSON ([]byte ) error {
@@ -215,10 +232,11 @@ func (c *Context) SubCallContext(ctx context.Context, input, toolID, callID stri
215
232
AgentGroup : agentGroup ,
216
233
ToolCategory : toolCategory ,
217
234
},
218
- Ctx : ctx ,
219
- Parent : c ,
220
- Program : c .Program ,
221
- Input : input ,
235
+ Ctx : ctx ,
236
+ Parent : c ,
237
+ Program : c .Program ,
238
+ CurrentReturn : c .CurrentReturn ,
239
+ Input : input ,
222
240
}, nil
223
241
}
224
242
@@ -270,6 +288,7 @@ func (e *Engine) Start(ctx Context, input string) (ret *Return, _ error) {
270
288
MaxTokens : tool .Parameters .MaxTokens ,
271
289
JSONResponse : tool .Parameters .JSONResponse ,
272
290
Cache : tool .Parameters .Cache ,
291
+ Chat : tool .Parameters .Chat ,
273
292
Temperature : tool .Parameters .Temperature ,
274
293
InternalSystemPrompt : tool .Parameters .InternalPrompt ,
275
294
}
0 commit comments