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)
| 304 | // callAgent hands the rendered prompt to a registered agent's Agent.Chat |
| 305 | // endpoint over RPC and returns its reply. |
| 306 | func (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. |
| 324 | func (f *Flow) Results() []Result { |
no test coverage detected