MCPcopy
hub / github.com/google/ax / TestHandleSubagentCall_Failure

Function TestHandleSubagentCall_Failure

internal/gemini/gemini_planner_test.go:355–394  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

353}
354
355func TestHandleSubagentCall_Failure(t *testing.T) {
356 mockExec := &mockExecutor{
357 execFunc: func(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, o agent.OutputHandler) (proto.State, error) {
358 return proto.State_STATE_UNSPECIFIED, fmt.Errorf("subagent execution failed")
359 },
360 }
361
362 p := &geminiPlannerAgent{}
363 fc := &genai.FunctionCall{
364 Name: "test-subagent",
365 Args: map[string]any{
366 "history": "Previous history summary",
367 "prompt": "Current user prompt",
368 },
369 }
370
371 var handlerOutput *proto.AgentOutputs
372 handler := func(outgoing *proto.AgentOutputs) error {
373 handlerOutput = outgoing
374 return nil
375 }
376
377 err := p.handleSubagentCall(context.Background(), "test-conv", fc, nil, nil, mockExec, handler)
378 if err != nil {
379 t.Fatalf("handleSubagentCall failed: %v", err)
380 }
381
382 msg := handlerOutput.Messages[0]
383 tr := msg.Content.GetToolResult()
384 fr := tr.GetFunctionResult()
385 resp := fr.GetResponse()
386 resultVal := resp.Fields["result"].GetStringValue()
387 if resultVal != "sub agent failed" {
388 t.Errorf("expected 'sub agent failed', got %s", resultVal)
389 }
390 errVal := resp.Fields["error"].GetStringValue()
391 if !strings.Contains(errVal, "subagent execution failed") {
392 t.Errorf("expected error to contain 'subagent execution failed', got %s", errVal)
393 }
394}
395
396func TestHandleSubagentCall_Panic(t *testing.T) {
397 mockExec := &mockExecutor{

Callers

nothing calls this directly

Calls 4

handleSubagentCallMethod · 0.95
GetToolResultMethod · 0.80
GetFunctionResultMethod · 0.80
GetResponseMethod · 0.80

Tested by

no test coverage detected