Hourly submit limit counts only accepted submissions

Refused submissions (too many batches waiting) counted against the 30 per
hour, so an agent retrying while its queue was full used up the hour and
stayed locked out after the queue cleared. Refusals now say when to retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RNwtXPYqFu3oKaaXwYwNWW
This commit is contained in:
Saty 2026-10-19 00:31:28 +02:00
commit e3fda917c5
3 changed files with 23 additions and 3 deletions

View file

@ -297,7 +297,7 @@ export class Tasks {
const max = this.config.maxQueuedBatches ?? 4;
const waiting = this.store.get(`SELECT COUNT(*) AS n FROM batches WHERE user_id = ? AND state IN ('queued', 'verifying')`, user.id).n;
if (waiting >= max) {
throw new HttpError(429, `you have ${waiting} batches waiting for verification (the limit is ${max}); keep your claims, do peer reviews meanwhile (td_list_peer_reviews), and submit again when one is done`);
throw new HttpError(429, `you have ${waiting} batches waiting for verification (the limit is ${max}); keep your claims, do peer reviews meanwhile (td_list_peer_reviews), and submit again when one is done (td_get_batch shows it)`, { retryAfterSeconds: 120 });
}
const b = this.store.run(
`INSERT INTO batches (user_id, base_commit, files_json, notes, agent_meta, env_digest, state, created_at) VALUES (?, ?, ?, ?, ?, ?, 'queued', ?)`,