fix(mindcraft-skills): scale collectBlock timeout with count
Live test showed count=1 succeeds in ~25s but count=8 timed out at 90s because gathering 8 logs naturally takes ~200s of pathing + dig + pickup across the area. Fixed 90s ceiling was too tight for legitimate bulk collection. Scale timeout linearly: 30s overhead + 30s per requested block, capped at 600s. count=1 → 60s, count=4 → 150s, count=8 → 270s, count=20 → 630s (capped at 600). Catches real hangs (wrong name, unreachable) without killing legitimate long collections in dense forest. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -268,8 +268,12 @@ export default async function mindcraftSkills(pi: ExtensionAPI) {
|
||||
async execute(_id, params: { blockType: string; count?: number }) {
|
||||
const bot = getBot();
|
||||
const count = Math.max(1, Math.min(64, Math.floor(params.count ?? 1)));
|
||||
// Timeout scales with count: ~30s per block plus 30s overhead.
|
||||
// Allows count=8 (about 4 min) without hanging forever on
|
||||
// pathfinder-unreachable cases.
|
||||
const timeoutMs = Math.min(600_000, 30_000 + count * 30_000);
|
||||
const ok = await safeCall("collectBlock", () =>
|
||||
withTimeout(skills.collectBlock(bot, params.blockType, count), 90_000, `collectBlock(${params.blockType}, ${count})`),
|
||||
withTimeout(skills.collectBlock(bot, params.blockType, count), timeoutMs, `collectBlock(${params.blockType}, ${count})`),
|
||||
);
|
||||
return textResult(ok ? `Collected ${count} of ${params.blockType}.` : `collectBlock returned false for ${params.blockType}.`, { ok, blockType: params.blockType, count });
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user