Testing Core Error Processors
How to write integration tests for error processors in packages/core/src/processors/.
Get the complete skill folder, including its scripts and reference files.
When to use this skill
Use Testing Core Error Processors when an AI agent needs a reusable SKILL.md workflow for this job: How to write integration tests for error processors in packages/core/src/processors/.
When not to use it
Skip Testing Core Error Processors when the task is outside the coding category, or when a more specific skill in this directory already covers the same workflow with clearer triggers.
How to install
Where will you use it?
mkdir -p ~/.claude/skills/testing-core-error-processors # Save SKILL.md to ~/.claude/skills/testing-core-error-processors/SKILL.md
- Claude Code personal install: place the skill and its bundled files at ~/.claude/skills/testing-core-error-processors/SKILL.md. For a shared project, commit the folder at .claude/skills/testing-core-error-processors/ instead.
- Current Claude Code detects SKILL.md changes in watched directories during the session. If you just created a top-level skills directory, run /reload-skills. Check that the skill is listed before testing its trigger.
- For Claude chat or Cowork in the Desktop app, manage uploaded skills in Customize > Skills; copying files into a local Claude Code folder is not a Desktop install. Other agents may use different install locations.
Full install guide for Claude, Cursor, and Codex →
Try a starter prompt
After installing the skill, paste this starter prompt into your agent to verify it triggers on a small task.
Use the Testing Core Error Processors skill for this task: Use Testing Core Error Processors when this documented workflow matches the task. Confirm any required inputs or files before making changes.
What supports this recommendation?
68/100 provisional content score. This measures documentation, practical detail and source signals. It is not a measured task success rate or a security certification.
- Documentation
- 68/100
- Practical detail
- 68/100
- Source evidence
- 63/100
- Source signals
- 72/100
Model compatibility evidence
- claudeinferred
The skill text mentions Claude or a closely associated term. This is keyword-derived compatibility; no hands-on model test is recorded.
- chatgptuntested
No model-specific signal or recorded compatibility test was found.
- geminiuntested
No model-specific signal or recorded compatibility test was found.
- copilotuntested
No model-specific signal or recorded compatibility test was found.
- llamauntested
No model-specific signal or recorded compatibility test was found.
- perplexityuntested
No model-specific signal or recorded compatibility test was found.
- mistraluntested
No model-specific signal or recorded compatibility test was found.
- grokuntested
No model-specific signal or recorded compatibility test was found.
Inferred compatibility is based on content signals. Check the app, its available tools and setup requirements before running a skill.
What this skill does
# Testing Core Error Processors
How to write integration tests for error processors in `packages/core/src/processors/`.
## Prerequisites
- Build core before running tests: `pnpm build:core` (from repo root) - If focused vitest runs fail to resolve `@internal/test-utils/setup`, the build step was skipped
## Mock Model Pattern
Use `MockLanguageModelV2` from `@internal/ai-sdk-v5/test` to simulate API errors and verify retry behavior.
```ts import { APICallError } from '@internal/ai-sdk-v5'; import { convertArrayToReadableStream, MockLanguageModelV2 } from '@internal/ai-sdk-v5/test';
// Track calls and captured prompts let callCount = 0; const receivedPrompts: any[] = [];
const model = new MockLanguageModelV2({ doGenerate: async ({ prompt }) => { callCount++; receivedPrompts.push(JSON.parse(JSON.stringify(prompt))); if (callCount === 1) { throw new APICallError({ message: '...', url: '...', requestBodyValues: {}, statusCode: 400, responseBody: '...', isRetryable: false, }); } return { rawCall: { rawPrompt: null, rawSettings: {} }, finishReason: 'stop', usage: { inputTokens: 10, outputTokens: 20, totalTokens: 30 }, content: [{ type: 'text', text: 'response' }], warnings: [], }; }, doStream: async ({ prompt }) => { // Same error logic as doGenerate // IMPORTANT: Stream response must include all event types: return { rawCall: { rawPrompt: null, rawSettings: {} }, warnings: [], stream: convertArrayToReadableStream([ { type: 'stream-start', warnings: [] }, { type: 'response-metadata', id: 'id-0', modelId: 'mock-model', timestamp: new Date(0) }, { type: 'text-start', id: 'text-1' }, { type: 'text-delta', id: 'text-1', delta: 'response text' }, { type: 'text-end', id: 'text-1' }, { type: 'finish', finishReason: 'stop', usage: { inputTokens: 10, outputTokens: 20, totalTokens: 30 } }, ]), }; }, }); ```
### Stream Mock Gotcha
The stream mock format requires `stream-start`, `response-metadata`, `text-start`, `text-delta`, `text-end`, and `finish` events. Using only `text-delta` + `finish` (the minimal format) will result in empty text output because the AI SDK expects the full event sequence. See `prefill-error-recovery.test.ts` for the reference pattern.
## Test Structure
For each error processor, write at minimum:
1. **Happy path**: Processor catches the target error, modifies messages, retries successfully - Assert: `agent.generate()` succeeds, mock called 2x, retry prompt has expected modifications 2. **Control test**: Same scenario without the processor — error propagates - Assert: `agent.generate()` throws the expected error 3. **Selectivity test**: Processor ignores unrelated errors (e.g. rate limit 429) - Assert: Error propagates, mock called only 1x
## Passing Messages with Tool Calls
When seeding conversation history for tool-related tests, pass messages as the second argument to `agent.generate()` or `agent.stream()` using the AI SDK message format:
```ts const messages = [ { role: 'user', content: 'Do something' }, { role: 'assistant', content: [{ type: 'tool-call', toolCallId: 'some-id', toolName: 'myTool', args: {} }] }, { role: 'tool', content: [{ type: 'tool-result', toolCallId: 'some-id', toolName: 'myTool', result: 'done' }] }, ]; await agent.generate(messages); ```
## Running Tests
```bash # Run focused processor tests npx vitest run packages/core/src/processors/my-processor.test.ts
# Run all processor tests npx vitest run packages/core/src/processors/
# Full core test suite (slower) pnpm test:core ```
## Devin Secrets Needed
None for mock-based integration tests. For live API tests:
- `ANTHROPIC_API_KEY` — for testing against real Anthropic API - `OPENROUTER_API_KEY` — for testing provider switching scenarios
Intended uses
- Use Testing Core Error Processors when this documented workflow matches the task.
Implementation notes
- Review the source instructions and adapt inputs before running the workflow.
Try it, then tell us how it went
A copied prompt does not tell us whether the task worked. Report your result after checking the output. We collect your tool and outcome, never your files or prompt.