MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / Execute

Method Execute

go/engine/node/functioncall.go:68–89  ·  view source on GitHub ↗
(ctx context.Context, scope *engine.Scope)

Source from the content-addressed store, hash-verified

66
67func (n *FunctionCall) Execute(ctx context.Context, scope *engine.Scope) (string, error) {
68 args := make(map[string]expr.Value, len(n.fn.Info.Arguments))
69 for _, arg := range n.fn.Info.Arguments {
70 v, err := expr.Eval(n.inputBindings[arg.Uid], scope)
71 if err != nil {
72 return "", fmt.Errorf("function_call %s: argument %s: %w", n.ID(), arg.Name, err)
73 }
74 args[arg.Uid] = v.Cast(arg.DataType)
75 }
76
77 results, err := n.fn.Call(ctx, args)
78 if err != nil {
79 return "", fmt.Errorf("function_call %s: %w", n.ID(), err)
80 }
81
82 for _, ret := range n.fn.Info.Returns {
83 if err := engine.ApplyOutput(scope, n.ID(), ret.Uid, n.outputBindings[ret.Uid], results[ret.Uid]); err != nil {
84 return "", fmt.Errorf("function_call %s: applying output %s: %w", n.ID(), ret.Name, err)
85 }
86 }
87 return n.Next(engine.PortCtrl, scope)
88}
89
90// Tools exposes this function as an LLM-callable tool.
91func (n *FunctionCall) Tools() ([]llmproxy.FunctionTool, error) {
92 properties := make(map[string]any, len(n.fn.Info.Arguments))

Callers 1

TestFunctionCall_ExecuteFunction · 0.95

Calls 4

CastMethod · 0.80
CallMethod · 0.80
NextMethod · 0.80
IDMethod · 0.65

Tested by 1

TestFunctionCall_ExecuteFunction · 0.76