Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,15 @@ wait

This does not apply to lightweight LLM-only targets (azure, openai, gemini, openrouter) which can run with higher concurrency.

### Writing Tests

Tests should be lean and focused on what matters. Follow these principles:

- **Only test new or changed behavior.** Don't write tests for existing behavior that's already covered by the 1600+ core tests. If you fix a bug, test the fix and its edge cases — not the surrounding module.
- **One test per distinct behavior.** Don't write separate tests for trivially different inputs that exercise the same code path.
- **No tests for obvious code.** If a function returns `undefined` for missing input and that's a one-line null check, you don't need a test for it unless it's a regression risk.
- **Regression tests > comprehensive tests.** A test that would have caught the bug is worth more than five tests that exercise happy paths.

### Verifying Evaluator Changes

Unit tests alone are insufficient for evaluator changes. After implementing or modifying evaluators:
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/evaluation/formatting/segment-formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ export function formatSegment(
return undefined;
}

// Agent mode: return file reference only
// Agent mode: return file reference with absolute path so agents can locate
// the file regardless of their working directory. resolvedPath is set by
// message-processor.ts during file resolution; fall back to the display
// path when it is absent (e.g. in unit tests with synthetic segments).
if (mode === 'agent') {
return `<file: path="${filePath}">`;
const absolutePath = asString(segment.resolvedPath) ?? filePath;
return `<file: path="${absolutePath}">`;
}

// LM mode: return embedded content with XML tags
Expand Down
20 changes: 20 additions & 0 deletions packages/core/test/evaluation/formatting/segment-formatter.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { describe, expect, it } from 'bun:test';

import { formatSegment } from '../../../src/evaluation/formatting/segment-formatter.js';

describe('formatSegment agent mode file paths', () => {
it('uses resolvedPath (absolute) when available', () => {
const segment = {
type: 'file',
path: 'snippets/data.csv',
text: 'content',
resolvedPath: '/abs/path/to/snippets/data.csv',
};
expect(formatSegment(segment, 'agent')).toBe('<file: path="/abs/path/to/snippets/data.csv">');
});

it('falls back to display path when resolvedPath is absent', () => {
const segment = { type: 'file', path: 'snippets/data.csv', text: 'content' };
expect(formatSegment(segment, 'agent')).toBe('<file: path="snippets/data.csv">');
});
});
Loading