MCPcopy
hub / github.com/micro/go-micro / callAgent

Method callAgent

flow/flow.go:306–321  ·  view source on GitHub ↗

callAgent hands the rendered prompt to a registered agent's Agent.Chat endpoint over RPC and returns its reply.

(ctx context.Context, name, message string)

Source from the content-addressed store, hash-verified

304// callAgent hands the rendered prompt to a registered agent's Agent.Chat
305// endpoint over RPC and returns its reply.
306func (f *Flow) callAgent(ctx context.Context, name, message string) (string, error) {
307 info, _ := ai.RunInfoFrom(ctx)
308 body, _ := json.Marshal(map[string]string{"message": message, "parent_id": info.RunID})
309 req := f.client.NewRequest(name, "Agent.Chat", &codecbytes.Frame{Data: body})
310 var rsp codecbytes.Frame
311 if err := f.client.Call(ctx, req, &rsp); err != nil {
312 return "", err
313 }
314 var out struct {
315 Reply string `json:"reply"`
316 }
317 if err := json.Unmarshal(rsp.Data, &out); err != nil {
318 return "", err
319 }
320 return out.Reply, nil
321}
322
323// Results returns a copy of all recorded execution results.
324func (f *Flow) Results() []Result {

Callers 1

ExecuteMethod · 0.95

Calls 5

RunInfoFromFunction · 0.92
MarshalMethod · 0.65
NewRequestMethod · 0.65
CallMethod · 0.65
UnmarshalMethod · 0.65

Tested by

no test coverage detected