# clampTimeout

**Kind:** Function

**Source:** [`atloria-monorepo/libs/agent-core/src/benchmark/agent-hardening.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/libs/agent-core/src/benchmark/agent-hardening.ts#L33)

Agent Hardening — Defensive Patterns for Benchmark Execution

Utilities adopted from SWE-agent and Claude Code:
- Bash timeout clamping utility (prevents single commands from hogging budget)
- Pager-disabling environment (PAGER=cat, etc.)
- Cost limit per task ($3-5 budget)
- Autosubmission on error (partial patch > no patch)
- Zero-progress detection (3 consecutive zero-token turns)

Note: Task-level timeout is 1800s (30 min, matching SWE-agent).
Setup time is excluded — timer starts AFTER setupTask() completes.
Per-command bash timeout is 120s (benchmark) / 60s (interactive).

These are pure utility functions — no side effects, easy to test.

## Signature

```ts
function clampTimeout(requested: number | undefined, ceiling: number, defaultMs: number): number
```

## Parameters

| Name | Type |
|---|---|
| `requested` | `number | undefined` |
| `ceiling` | `number` |
| `defaultMs` | `number` |

**Returns:** `number`
