{"record":{"id":"f809fd5aeb6cdc92","repo":"Hmbown/CodeWhale","slug":"import-exceeds-the-this-maxevents-tolocalestring-event-limit","errorCode":null,"errorMessage":"Import exceeds the ${this.maxEvents.toLocaleString()} event limit.","messagePattern":"Import exceeds the (.+?) event limit\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/pet_watch/pet-native.js","lineNumber":2267,"sourceCode":"    get retainedBytes() { return this.bytes; }\n    measure(event, proposed = event) {\n        const safe = this.project(proposed);\n        if (this.maxBytes !== Infinity) {\n            const size = new TextEncoder().encode(JSON.stringify(safe)).length;\n            const total = this.bytes - (this.sizes.get(event) ?? 0) + size;\n            if (total > this.maxBytes)\n                throw new Error('Runtime observation exceeds its retained input limit.');\n            this.bytes = total;\n            this.sizes.set(event, size);\n        }\n        for (const key of Object.keys(event))\n            if (!Object.hasOwn(safe, key))\n                delete event[key];\n        Object.assign(event, safe);\n    }\n    push(event) {\n        if (this.events.length >= this.maxEvents)\n            throw new Error(`Import exceeds the ${this.maxEvents.toLocaleString()} event limit.`);\n        this.measure(event);\n        pushEvent(this.events, event);\n    }\n    /** Keep unfinished lifetimes plus the recent window needed by the bucketer's\n     * 12-second recurrence measure. A completion may still arrive for any open item. */\n    prune(beforeWall) {\n        if (!Number.isFinite(beforeWall))\n            throw new Error('Invalid Runtime retention horizon.');\n        if (this.origin === undefined)\n            return;\n        const cutoff = beforeWall - this.origin;\n        let keep = 0;\n        for (const event of this.events) {\n            if (event.openEnded || Math.max(event.endTime, (0, model_js_1.errorOnsetOf)(event)) >= cutoff)\n                this.events[keep++] = event;\n            else {\n                this.bytes -= this.sizes.get(event) ?? 0;\n                this.sizes.delete(event);","sourceCodeStart":2249,"sourceCodeEnd":2285,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/pet_watch/pet-native.js#L2249-L2285","documentation":"The Runtime event store enforces a maximum number of retained events (maxEvents). push() rejects any push once the store is full, throwing the same limit message used by the session import path. Like the byte cap, it bounds memory and rendering cost.","triggerScenarios":"Calling runtime.push(event) when events.length already equals maxEvents; importing a runtime record stream with more non-delta events than maxEvents.","commonSituations":"Long-running threads producing many tool calls/approvals; importing an old large runtime export; a low maxEvents configured for embedded or test use applied to production data.","solutions":["Raise maxEvents when constructing/configuring the Runtime.","Prune old events with prune(beforeWall) to free slots before pushing.","Chunk the import across multiple Runtime instances.","Filter out low-value records (deltas already skipped; consider other noise) before import."],"exampleFix":"// before\nconst rt = new Runtime({ maxEvents: 500 });\n// after\nconst rt = new Runtime({ maxEvents: 100000 });","handlingStrategy":"try-catch","validationCode":"if (rt.events.length >= rt.maxEvents) rt.prune(Date.now());","typeGuard":null,"tryCatchPattern":"try { rt.push(event); } catch (e) { if (e.message.startsWith('Import exceeds the')) { rt.prune(Date.now()); rt.push(event); } else throw e; }","preventionTips":["Configure maxEvents for the largest expected thread.","Prune before pushing in append loops.","Chunk oversized imports.","Skip delta/noise records before import."],"tags":["limit","events","runtime"],"backgroundTag":"value-out-of-range","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T16:17:23.217Z"}