feat(FN-1000): add token cap detection for agent task execution

- Add tokenCap to ProjectSettings with tokenCapEnabled flag, default 500K tokens
- Create TokenCapDetector class with usage tracking and cap enforcement
- Wire TokenCapDetector into executor agentWork() to auto-fail tasks exceeding cap
- Add token cap input fields to Settings Modal dashboard UI
- Add comprehensive unit tests for TokenCapDetector (174 lines)
This commit is contained in:
gsxdsm
2026-04-05 22:50:03 -07:00
parent 931093a4e2
commit 904e4c8e00
6 changed files with 306 additions and 0 deletions

View File

@@ -695,6 +695,21 @@ export function SettingsModal({
);
})()}
<div className="form-group">
<label htmlFor="tokenCap">Token Cap</label>
<input
id="tokenCap"
type="number"
placeholder="100000"
value={(form as any).tokenCap ?? ""}
onChange={(e) => {
const val = e.target.value;
setForm((f) => ({ ...f, tokenCap: val ? parseInt(val, 10) : undefined } as any));
}}
/>
<small>Automatically compact context when approaching this token count. Leave empty to use default behavior (compact only on overflow errors).</small>
</div>
{/* --- Planning & Validation --- */}
<h4 className="settings-section-heading" style={{ marginTop: "1.5rem" }}>Planning &amp; Validation</h4>
{modelsLoading ? (