| 51 | } |
| 52 | |
| 53 | func TestChainMaxSteps(t *testing.T) { |
| 54 | chain := NewChain(ChainConfig{MaxSteps: 2}) |
| 55 | |
| 56 | step := Step{ |
| 57 | Title: "Test Step", |
| 58 | Confidence: 0.9, |
| 59 | NextAction: NextActionContinue, |
| 60 | } |
| 61 | |
| 62 | // 添加第一个步骤 |
| 63 | if err := chain.AddStep(step); err != nil { |
| 64 | t.Fatalf("failed to add first step: %v", err) |
| 65 | } |
| 66 | |
| 67 | // 添加第二个步骤 |
| 68 | if err := chain.AddStep(step); err != nil { |
| 69 | t.Fatalf("failed to add second step: %v", err) |
| 70 | } |
| 71 | |
| 72 | // 尝试添加第三个步骤(应该失败) |
| 73 | if err := chain.AddStep(step); err == nil { |
| 74 | t.Error("expected error when exceeding max steps") |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | func TestChainShouldContinue(t *testing.T) { |
| 79 | tests := []struct { |