( messages: Message[] | undefined, toolUseContext: ToolUseContext, )
| 3455 | } |
| 3456 | |
| 3457 | async function getTaskReminderAttachments( |
| 3458 | messages: Message[] | undefined, |
| 3459 | toolUseContext: ToolUseContext, |
| 3460 | ): Promise<Attachment[]> { |
| 3461 | if (!isTodoV2Enabled()) { |
| 3462 | return [] |
| 3463 | } |
| 3464 | |
| 3465 | // Skip for ant users |
| 3466 | if (process.env.USER_TYPE === 'ant') { |
| 3467 | return [] |
| 3468 | } |
| 3469 | |
| 3470 | // When SendUserMessage is in the toolkit, it's the primary communication |
| 3471 | // channel and the model is always told to use it (#20467). TaskUpdate |
| 3472 | // becomes a side channel — nudging the model about it conflicts with the |
| 3473 | // brief workflow. The tool itself stays available; this only gates the nag. |
| 3474 | if ( |
| 3475 | BRIEF_TOOL_NAME && |
| 3476 | toolUseContext.options.tools.some(t => toolMatchesName(t, BRIEF_TOOL_NAME)) |
| 3477 | ) { |
| 3478 | return [] |
| 3479 | } |
| 3480 | |
| 3481 | // Skip if TaskUpdate tool is not available |
| 3482 | if ( |
| 3483 | !toolUseContext.options.tools.some(t => |
| 3484 | toolMatchesName(t, TASK_UPDATE_TOOL_NAME), |
| 3485 | ) |
| 3486 | ) { |
| 3487 | return [] |
| 3488 | } |
| 3489 | |
| 3490 | // Skip if no messages provided |
| 3491 | if (!messages || messages.length === 0) { |
| 3492 | return [] |
| 3493 | } |
| 3494 | |
| 3495 | const { turnsSinceLastTaskManagement, turnsSinceLastReminder } = |
| 3496 | getTaskReminderTurnCounts(messages) |
| 3497 | |
| 3498 | // Check if we should show a reminder |
| 3499 | if ( |
| 3500 | turnsSinceLastTaskManagement >= TODO_REMINDER_CONFIG.TURNS_SINCE_WRITE && |
| 3501 | turnsSinceLastReminder >= TODO_REMINDER_CONFIG.TURNS_BETWEEN_REMINDERS |
| 3502 | ) { |
| 3503 | const tasks = await listTasks(getTaskListId()) |
| 3504 | return [ |
| 3505 | { |
| 3506 | type: 'task_reminder', |
| 3507 | content: tasks, |
| 3508 | itemCount: tasks.length, |
| 3509 | }, |
| 3510 | ] |
| 3511 | } |
| 3512 | |
| 3513 | return [] |
| 3514 | } |
no test coverage detected