{"record":{"id":"fcff2517ecfe4855","repo":"chatboxai/chatbox","slug":"the-agent-mode-reward-was-claimed-but-the-interru","errorCode":null,"errorMessage":"The Agent Mode reward was claimed, but the interrupted task could not resume","messagePattern":"The Agent Mode reward was claimed, but the interrupted task could not resume","errorType":"exception","errorClass":"AgentModeRewardResumeError","httpStatus":null,"severity":"error","filePath":"src/renderer/packages/agent-mode-reward.ts","lineNumber":41,"sourceCode":"    this.name = 'AgentModeRewardResumeError'\n  }\n}\n\nexport async function claimAgentModeRewardAndResume({\n  claim,\n  showSuccess,\n  resume,\n}: {\n  claim: () => Promise<ClaimedAgentModeReward>\n  showSuccess: (reward: ClaimedAgentModeReward) => void\n  resume: () => Promise<void>\n}): Promise<ClaimedAgentModeReward> {\n  const reward = await claim()\n  showSuccess(reward)\n  try {\n    await resume()\n  } catch (error) {\n    throw new AgentModeRewardResumeError(reward, error)\n  }\n  return reward\n}\n","sourceCodeStart":23,"sourceCodeEnd":45,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/agent-mode-reward.ts#L23-L45","documentation":"Thrown by claimAgentModeRewardAndResume() as an AgentModeRewardResumeError when the reward claim and success display succeed but the subsequent resume() of the interrupted task fails. The error wraps the original resumeCause and preserves the claimed reward so the caller knows the reward was consumed even though the task did not resume — this is critical because the reward cannot be un-claimed.","triggerScenarios":"claim() returns a reward, showSuccess() renders it, then resume() throws — e.g. the interrupted agent task's session was deleted, the network call to resume the task failed, or the task context expired. The wrapped error is attached as resumeCause.","commonSituations":"The interrupted task's session was removed while the reward modal was open; the resume endpoint is transiently unreachable; the task's state was garbage-collected after a long idle. Because the reward is already claimed server-side, the user faces a claimed-but-unusable state.","solutions":["Catch AgentModeRewardResumeError specifically and inform the user the reward was claimed but the task needs manual restart.","Persist the reward details (tokenLimit, expiresAt) locally so the user can restart the task manually within the validity window.","Retry resume() with backoff for transient network failures before surfacing the error."],"exampleFix":"// before\ntry {\n  await resume()\n} catch (error) {\n  throw new AgentModeRewardResumeError(reward, error)\n}\n\n// caller — handle the partial-success state explicitly\ntry {\n  await claimAgentModeRewardAndResume({ claim, showSuccess, resume })\n} catch (e) {\n  if (e instanceof AgentModeRewardResumeError) {\n    toast.info(`Reward claimed, but the task could not resume: ${e.resumeCause}. Restart it manually.`)\n    persistReward(e.reward)\n  } else {\n    throw e\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"import { AgentModeRewardResumeError } from './agent-mode-reward'\nfunction isResumeError(e: unknown): e is AgentModeRewardResumeError {\n  return e instanceof AgentModeRewardResumeError\n}","tryCatchPattern":"try {\n  await claimAgentModeRewardAndResume({ claim, showSuccess, resume })\n} catch (error) {\n  if (isResumeError(error)) {\n    // Reward was claimed; task needs manual restart.\n    persistRewardLocally(error.reward)\n    toast.info('Reward claimed but the task could not resume. Restart it manually.')\n  } else {\n    throw error\n  }\n}","preventionTips":["Catch AgentModeRewardResumeError separately from the claim error so the claimed reward is not lost.","Persist the reward locally on resume failure so the user can use it after a manual restart.","Retry resume() with backoff for transient failures before surfacing the error."],"tags":["agent-mode","reward","resume","error-wrapping","partial-failure"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}