| 144 | } |
| 145 | |
| 146 | func TestBashTimeoutCappedAtOneHour(t *testing.T) { |
| 147 | // 999999s must clamp to 3600. Can't sleep an hour to prove it, so a short |
| 148 | // command just has to complete quickly: no overflow, no panic. |
| 149 | call := chmctx.ToolCall{ |
| 150 | ID: "t2", Name: "bash", |
| 151 | Arguments: map[string]any{ |
| 152 | "cmd": "echo clamped", |
| 153 | "timeout_seconds": float64(999999), |
| 154 | }, |
| 155 | } |
| 156 | msg := Execute(context.Background(), call) |
| 157 | if !strings.Contains(msg.Content, "clamped") { |
| 158 | t.Fatalf("expected echo output: %q", msg.Content) |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | // TestBashTimeoutOverflowClamped: extreme floats must be clamped BEFORE the |
| 163 | // Duration multiply. `time.Duration(1e18) * time.Second` overflows int64 to a |