mirror of
https://github.com/davidkaya/aryx.git
synced 2026-08-07 20:28:46 +02:00
fix: use fallback args when tool-specific keys are missing in labels
When toolArguments doesn't contain the expected key (e.g. 'path' for view), fall back to the first usable string value from any argument key instead of showing misleading placeholders like 'Viewed a file'. When no arguments exist at all, show just the tool name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -188,6 +188,10 @@ describe('formatToolCallPrimaryLabel', () => {
|
||||
.toBe('Viewed `index.ts:10-25`');
|
||||
});
|
||||
|
||||
test('falls back to tool name when view has no args', () => {
|
||||
expect(formatToolCallPrimaryLabel('view', {})).toBe('view');
|
||||
});
|
||||
|
||||
test('produces verb-based label for edit', () => {
|
||||
expect(formatToolCallPrimaryLabel('edit', { path: '/src/utils.ts', old_str: 'foo' }))
|
||||
.toBe('Edited `utils.ts`');
|
||||
@@ -223,6 +227,11 @@ describe('formatToolCallPrimaryLabel', () => {
|
||||
.toBe('SQL: Insert todos');
|
||||
});
|
||||
|
||||
test('uses fallback string arg when specific key is missing', () => {
|
||||
expect(formatToolCallPrimaryLabel('view', { file_path: '/src/foo.ts' }))
|
||||
.toBe('Viewed `/src/foo.ts`');
|
||||
});
|
||||
|
||||
test('handles GitHub tools', () => {
|
||||
const result = formatToolCallPrimaryLabel('github-mcp-server-search_code', { query: 'auth' });
|
||||
expect(result).toContain('search code');
|
||||
@@ -274,6 +283,10 @@ describe('extractToolCallSnippet', () => {
|
||||
});
|
||||
|
||||
test('returns undefined for unknown tool', () => {
|
||||
expect(extractToolCallSnippet('custom', { foo: 'bar' })).toBeUndefined();
|
||||
expect(extractToolCallSnippet('custom', {})).toBeUndefined();
|
||||
});
|
||||
|
||||
test('falls back to first string arg when specific key is missing', () => {
|
||||
expect(extractToolCallSnippet('view', { file_path: '/src/foo.ts' })).toBe('/src/foo.ts');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user