Hmbown/CodeWhale · error · Error
Import exceeds the event limit.
Error message
Import exceeds the ${maxEvents.toLocaleString()} event limit. What it means
This error is thrown by the Codewhale session importer when the number of events parsed from a session snapshot exceeds maxEvents, the configured cap on import size. The library throws early (before creating each event) to avoid unbounded memory growth during import. It is a hard guard, not a soft warning: the whole import aborts.
Solutions
- Increase the maxEvents option passed to the import call.
- Split the session export into smaller chunks and import them separately.
- Reduce imported content, e.g. filter out non-message entries before import.
- Verify you are importing a single session, not a multi-session concatenation.
Example fix
// before
importCodewhaleSession(snapshot); // default maxEvents
// after
importCodewhaleSession(snapshot, { maxEvents: 100_000 }); Defensive patterns
Strategy: validation
Validate before calling
const events = collectEvents(snapshot);
if (events.length >= maxEvents) throw new Error(`Snapshot has ${events.length} events, over limit ${maxEvents}`); Type guard
function isWithinEventLimit(count, maxEvents) {
return Number.isInteger(maxEvents) && count < maxEvents;
} Try / catch
try {
importCodewhaleSession(snapshot, { maxEvents });
} catch (e) {
if (String(e.message).includes('event limit')) {
console.error(`Session too large: raise maxEvents or split the export (${e.message})`);
} else throw e;
} Prevention
- Count entries in the snapshot before importing and size maxEvents accordingly.
- Set maxEvents generously (or explicitly) rather than relying on defaults.
- Split very long session exports at the source.
- Never concatenate multiple sessions into one import.
When it happens
Trigger: Calling the Codewhale session import (the function containing the sourceEntries loop at pet/ios/Resources/pet-native.js:2067) with a session snapshot whose entry count meets or exceeds the maxEvents limit. Each entry that would push events.length to maxEvents triggers the throw.
Common situations: Importing a very long Codewhale session (hours-long agent runs with thousands of turns); re-importing an already-grown session; passing a too-small maxEvents option; accidentally importing a concatenated export containing several sessions.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- Import exceeds the event limit.
- Import exceeds the event limit.
- Codewhale session produced no inspectable events.
- Import exceeds the event limit.
- A managed, project or plugin connector already uses this…
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/63ccf85bf928c9bc.
Report an issue: GitHub.
Appendix: source
Thrown at pet/ios/Resources/pet-native.js:2067
}
const events = [];
const pending = new Map();
let seq = 0;
const originWall = orderOnly ? undefined : sourceEntries.map(e => parseTime(e.created_at)).find((n) => n !== undefined);
const agentId = 'parent';
const model = str(metadata.model);
const provider = str(metadata.model_provider);
const when = (entry, fallback) => {
if (orderOnly || originWall === undefined)
return { start: fallback, open: false };
const t = parseTime(entry.created_at);
if (t === undefined)
return { start: fallback, open: true };
return { start: t - originWall, open: false };
};
for (const entry of sourceEntries) {
if (events.length >= maxEvents)
throw new Error(`Import exceeds the ${maxEvents.toLocaleString()} event limit.`);
const entryId = str(entry.id) ?? `${sessionId}/entry/${seq}`;
const message = obj(entry.message ?? (entry.kind === 'message' ? entry : {}));
const role = str(message.role) ?? (str(entry.kind) === 'user' ? 'user' : str(entry.kind) === 'assistant' ? 'assistant' : undefined);
const blocks = Array.isArray(message.content) ? message.content.map(obj) : [];
if (!blocks.length) {
const text = str(entry.text) ?? str(message.text);
if (text)
blocks.push({ type: role === 'user' ? 'text' : 'text', text });
}
if (!blocks.length)
continue;
const parentEventId = events.length ? events[events.length - 1].id : undefined;
for (const block of blocks) {
const t = when(entry, seq);
const idBase = `${entryId}/${seq}`;
const type = str(block.type) ?? 'text';
const raw = pointer('codewhale.session/v1', { sessionId, entryId, seq, blockType: type, toolUseId: block.id ?? block.tool_use_id });
if (type === 'tool_use' || type === 'server_tool_use') {View on GitHub (pinned to 433685b202)