slug エージェントが暴走するのを対処

This commit is contained in:
nrslib 2026-02-10 21:18:48 +09:00
parent d185039c73
commit eb32cf0138
5 changed files with 47 additions and 16 deletions

View File

@ -130,6 +130,7 @@ describe('template file existence', () => {
'score_interactive_policy', 'score_interactive_policy',
'score_summary_system_prompt', 'score_summary_system_prompt',
'score_slug_system_prompt', 'score_slug_system_prompt',
'score_slug_user_prompt',
'perform_phase1_message', 'perform_phase1_message',
'perform_phase2_message', 'perform_phase2_message',
'perform_phase3_message', 'perform_phase3_message',

View File

@ -63,11 +63,16 @@ describe('summarizeTaskName', () => {
// Then // Then
expect(result).toBe('add-auth'); expect(result).toBe('add-auth');
expect(mockGetProvider).toHaveBeenCalledWith('claude'); expect(mockGetProvider).toHaveBeenCalledWith('claude');
const callPrompt = mockProviderCall.mock.calls[0]?.[0];
expect(callPrompt).toContain('Generate a slug from the task description below.');
expect(callPrompt).toContain('<task_description>');
expect(callPrompt).toContain('long task name for testing');
expect(callPrompt).toContain('</task_description>');
expect(mockProviderCall).toHaveBeenCalledWith( expect(mockProviderCall).toHaveBeenCalledWith(
'long task name for testing', expect.any(String),
expect.objectContaining({ expect.objectContaining({
cwd: '/project', cwd: '/project',
allowedTools: [], permissionMode: 'readonly',
}) })
); );
}); });

View File

@ -70,10 +70,11 @@ export class TaskSummarizer {
name: 'summarizer', name: 'summarizer',
systemPrompt: loadTemplate('score_slug_system_prompt', 'en'), systemPrompt: loadTemplate('score_slug_system_prompt', 'en'),
}); });
const response = await agent.call(taskName, { const prompt = loadTemplate('score_slug_user_prompt', 'en', { taskDescription: taskName });
const response = await agent.call(prompt, {
cwd: options.cwd, cwd: options.cwd,
model, model,
allowedTools: [], permissionMode: 'readonly',
}); });
const slug = sanitizeSlug(response.content); const slug = sanitizeSlug(response.content);

View File

@ -0,0 +1,12 @@
<!--
template: score_slug_user_prompt
role: user prompt for task-name-to-slug generation
vars: taskDescription
caller: infra/task/summarize
-->
Generate a slug from the task description below.
Output ONLY the slug text.
<task_description>
{{taskDescription}}
</task_description>

View File

@ -0,0 +1,12 @@
<!--
template: score_slug_user_prompt
role: user prompt for task-name-to-slug generation
vars: taskDescription
caller: infra/task/summarize
-->
Generate a slug from the task description below.
Output ONLY the slug text.
<task_description>
{{taskDescription}}
</task_description>