Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
TypeScript aiai-agentsai-memoryanthropicartificial-intelligencechromadbclaudeclaude-agent-sdkclaude-agentsclaude-codeclaude-code-pluginclaude-skillsembeddingslong-term-memorymem0memory-engineopenmemoryragsqlitesupermemory
import { describe, expect, it } from 'bun:test';
import { extractObservationFileEvidence } from '../../../src/services/worker/agents/ResponseProcessor.js';
// A denied or failed Write must not be stored as a completed files_modified
// change: Cursor's postToolUseFailure reports the attempt, not a result (#5371).
describe('extractObservationFileEvidence: failed tool calls', () => {
const message = (over: Record<string, unknown>) => ({ type: 'observation', ...over }) as any;
it('records a successful edit', () => {
const evidence = extractObservationFileEvidence([
message({ tool_name: 'Edit', tool_input: { file_path: 'src/a.ts' } }),
]);
expect(evidence.files_modified).toEqual(['src/a.ts']);
});
it('ignores an edit whose response is marked as an error', () => {
const evidence = extractObservationFileEvidence([
message({
tool_name: 'Edit',
tool_input: { file_path: 'src/a.ts' },
tool_response: { is_error: true, error: 'permission denied' },
}),
]);
expect(evidence.files_modified).toEqual([]);
});
it('ignores a read whose response is marked as an error', () => {
const evidence = extractObservationFileEvidence([
message({
tool_name: 'Read',
tool_input: { file_path: 'src/a.ts' },
tool_response: { isError: true },
}),
]);
expect(evidence.files_read).toEqual([]);
});
it('still records an edit whose response is a normal result', () => {
const evidence = extractObservationFileEvidence([
message({
tool_name: 'Edit',
tool_input: { file_path: 'src/b.ts' },
tool_response: { success: true },
}),
]);
expect(evidence.files_modified).toEqual(['src/b.ts']);
});
it('still records an edit whose stored response is a plain string result', () => {
const evidence = extractObservationFileEvidence([
message({
tool_name: 'Edit',
tool_input: JSON.stringify({ file_path: 'src/c.ts' }),
tool_response: JSON.stringify('{"is_error":true}'),
}),
]);
expect(evidence.files_modified).toEqual(['src/c.ts']);
});
});