(t *testing.T)
| 70 | } |
| 71 | |
| 72 | func TestAgentErrorEventPreservesAPIStatusMetadata(t *testing.T) { |
| 73 | cfg := config.NewConfig() |
| 74 | engine := agent.NewCoreExecutionEngine(&cfg) |
| 75 | state := agent.NewAgentState() |
| 76 | turn := &agent.ModelTurn{} |
| 77 | action := engine.HandleStreamEvent(map[string]any{ |
| 78 | "type": "error", |
| 79 | "message": `DeepSeek API error 400 400 Bad Request: {"error":"bad"}`, |
| 80 | "status_code": 400, |
| 81 | "raw_error": `{"error":"bad"}`, |
| 82 | }, turn, nil, &state, 0) |
| 83 | if action.Event == nil || action.Event.Type != "error" { |
| 84 | t.Fatalf("expected error event, got %#v", action) |
| 85 | } |
| 86 | if action.Event.Metadata["status_code"] != 400 || action.Event.Metadata["raw_error"] != `{"error":"bad"}` { |
| 87 | t.Fatalf("agent wrapper should preserve API status metadata, got %#v", action.Event.Metadata) |
| 88 | } |
| 89 | if action.Event.Content != `DeepSeek API error 400 400 Bad Request: {"error":"bad"}` { |
| 90 | t.Fatalf("agent wrapper should preserve raw message, got %q", action.Event.Content) |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | func (t *largeReadTool) Execute(_ context.Context, _ coretools.ExecutionContext, input any) (string, error) { |
| 95 | switch v := input.(type) { |
nothing calls this directly
no test coverage detected