MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / TestAgentErrorEventPreservesAPIStatusMetadata

Function TestAgentErrorEventPreservesAPIStatusMetadata

test/agent_test.go:72–92  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func 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
94func (t *largeReadTool) Execute(_ context.Context, _ coretools.ExecutionContext, input any) (string, error) {
95 switch v := input.(type) {

Callers

nothing calls this directly

Calls 4

HandleStreamEventMethod · 0.95
NewConfigFunction · 0.92
NewCoreExecutionEngineFunction · 0.92
NewAgentStateFunction · 0.92

Tested by

no test coverage detected