{"record":{"id":"070d31fa559392e8","repo":"paperclipai/paperclip","slug":"bridge-host-response-body-capacity-is-busy","errorCode":null,"errorMessage":"Bridge host response body capacity is busy.","messagePattern":"Bridge host response body capacity is busy\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/adapter-utils/src/sandbox-callback-bridge.ts","lineNumber":1131,"sourceCode":"      // the handler writes the real response.\n      if (!claimForHandler()) {\n        return;\n      }\n\n      // Build the response, then finalize once. The handler already holds the\n      // claim, so `finalize` writes the real response.\n      let response: SandboxCallbackBridgeResponse;\n      let handlerReturned = false;\n      try {\n        const { bodyEncoding, ...forwardRequest } = request;\n        const result = await input.handleRequest({ ...forwardRequest,\n          body: bodyEncoding === \"base64\" ? decodeSandboxBridgeBody(request, maxBodyBytes) : request.body,\n        }, { signal: guard.controller.signal, reservation });\n        handlerReturned = true;\n        const responseBytes = Buffer.byteLength(result.body ?? \"\");\n        if (responseBytes > maxBodyBytes) throw new Error(\"Bridge response body exceeded the configured size limit.\");\n        if (!reservation.reserve(4 * sandboxBridgeEnvelopeLimit(responseBytes))) {\n          throw new Error(\"Bridge host response body capacity is busy.\");\n        }\n        const responseBody = encodeSandboxBridgeBody(result.body ?? \"\", maxBodyBytes);\n        response = {\n          id: request.id,\n          status: result.status,\n          headers: result.headers ?? {},\n          ...responseBody,\n          completedAt: new Date().toISOString(),\n        };\n      } catch (error) {\n        console.warn(\n          `[paperclip] sandbox callback bridge handler failed for ${request.id}: ${error instanceof Error ? error.message : String(error)}`,\n        );\n        // Tell a worker abort apart from a normal handler failure. The recovery\n        // path aborts `guard.controller` when the per-iteration timeout or the\n        // watchdog fires. The abort reaches this catch only after the handler\n        // claimed the request and started the host operation. The bridge cannot\n        // cancel a host operation that is in flight, so the mutation may have","sourceCodeStart":1113,"sourceCodeEnd":1149,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/packages/adapter-utils/src/sandbox-callback-bridge.ts#L1113-L1149","documentation":"Before the host encodes and writes a bridge response, it reserves 4 * sandboxBridgeEnvelopeLimit(responseBytes) bytes against the process memory ledger. If the ledger cannot grant that reservation (other in-flight requests have claimed the budget), the host fails this request rather than over-committing memory. This is a transient back-pressure signal, not a size violation of the response itself.","triggerScenarios":"reservation.reserve(4 * sandboxBridgeEnvelopeLimit(responseBytes)) returns false because concurrent bridge traffic has already consumed the shared byte budget.","commonSituations":"Many sandbox callbacks firing at once (fan-out tools); a slow handler pinning its reservation while other requests queue; budget sized for single-request workloads but hit under parallel agent runs.","solutions":["Retry the request after a short backoff; capacity frees when in-flight responses complete.","Reduce concurrent sandbox bridge requests or queue them client-side.","Increase the bridge's total response capacity / memory ledger configuration."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return await bridge.dispatch(req); } catch (e) {\n  if (e.message.includes(\"capacity is busy\")) { await sleep(backoff); return bridge.dispatch(req); }\n  throw e;\n}","preventionTips":["Throttle concurrent sandbox callback requests client-side","Apply bounded exponential backoff on this error","Size the bridge memory ledger for expected parallelism","Avoid long-running handlers that pin reservations"],"tags":["sandbox","backpressure","capacity","concurrency"],"backgroundTag":"rate-limit-exceeded","analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}