@@ -59,6 +59,7 @@ type CallResult struct {
5959type commonContext struct {
6060 ID string `json:"id"`
6161 Tool types.Tool `json:"tool"`
62+ CurrentAgent types.ToolReference `json:"currentAgent,omitempty"`
6263 AgentGroup []types.ToolReference `json:"agentGroup,omitempty"`
6364 InputContext []InputContext `json:"inputContext"`
6465 ToolCategory ToolCategory `json:"toolCategory,omitempty"`
@@ -73,10 +74,11 @@ type CallContext struct {
7374
7475type Context struct {
7576 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
8082 // Input is saved only so that we can render display text, don't use otherwise
8183 Input string
8284}
@@ -129,6 +131,18 @@ func (c *Context) ParentID() string {
129131 return c .Parent .ID
130132}
131133
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+
132146func (c * Context ) GetCallContext () * CallContext {
133147 var toolName string
134148 if c .Parent != nil {
@@ -143,12 +157,15 @@ func (c *Context) GetCallContext() *CallContext {
143157 }
144158 }
145159
146- return & CallContext {
160+ result := & CallContext {
147161 commonContext : c .commonContext ,
148162 ParentID : c .ParentID (),
149163 ToolName : toolName ,
150164 DisplayText : types .ToDisplayText (c .Tool , c .Input ),
151165 }
166+
167+ result .CurrentAgent = c .CurrentAgent ()
168+ return result
152169}
153170
154171func (c * Context ) UnmarshalJSON ([]byte ) error {
@@ -215,10 +232,11 @@ func (c *Context) SubCallContext(ctx context.Context, input, toolID, callID stri
215232 AgentGroup : agentGroup ,
216233 ToolCategory : toolCategory ,
217234 },
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 ,
222240 }, nil
223241}
224242
@@ -270,6 +288,7 @@ func (e *Engine) Start(ctx Context, input string) (ret *Return, _ error) {
270288 MaxTokens : tool .Parameters .MaxTokens ,
271289 JSONResponse : tool .Parameters .JSONResponse ,
272290 Cache : tool .Parameters .Cache ,
291+ Chat : tool .Parameters .Chat ,
273292 Temperature : tool .Parameters .Temperature ,
274293 InternalSystemPrompt : tool .Parameters .InternalPrompt ,
275294 }
0 commit comments