|
333 | 333 |
|
334 | 334 | **STEP 2: DETERMINE RECOVERY STRATEGY (if quality insufficient)** |
335 | 335 |
|
336 | | -If the task quality is insufficient, select the best recovery strategy: |
| 336 | +If the task quality is insufficient, select the best recovery strategy from the ENABLED strategies below: |
337 | 337 |
|
338 | | -**Available Strategies:** |
339 | | -
|
340 | | -1. **retry** - Retry with the same worker and task content |
341 | | - - **Best for**: |
342 | | - * Network errors, connection timeouts, temporary API issues |
343 | | - * Random failures that are likely temporary |
344 | | - * Minor quality issues that may resolve on retry |
345 | | - - **Not suitable for**: |
346 | | - * Fundamental task misunderstandings |
347 | | - * Worker capability gaps |
348 | | - * Persistent quality problems |
349 | | -
|
350 | | -2. **reassign** - Assign to a different worker |
351 | | - - **Best for**: |
352 | | - * Current worker lacks required skills/expertise |
353 | | - * Worker-specific quality issues |
354 | | - * Task requires different specialization |
355 | | - - **Not suitable for**: |
356 | | - * Task description is unclear (use replan instead) |
357 | | - * Task is too complex (use decompose instead) |
358 | | - - **Note**: Only available for quality issues, not failures |
359 | | -
|
360 | | -3. **replan** - Modify task content with clearer instructions |
361 | | - - **Best for**: |
362 | | - * Unclear or ambiguous requirements |
363 | | - * Missing context or information |
364 | | - * Task description needs improvement |
365 | | - - **Requirements**: |
366 | | - * Provide modified_task_content with enhanced, clear instructions |
367 | | - * Modified task must be actionable for an AI agent |
368 | | - * Address the root cause identified in issues |
369 | | -
|
370 | | -4. **decompose** - Break into smaller, manageable subtasks |
371 | | - - **Best for**: |
372 | | - * Task is too complex for a single worker |
373 | | - * Multiple distinct sub-problems exist |
374 | | - * Persistent failures despite retries |
375 | | - * Capability mismatches that need specialization |
376 | | - - **Consider**: |
377 | | - * Task depth (avoid if depth > 2) |
378 | | - * Whether subtasks can run in parallel |
379 | | -
|
380 | | -5. **create_worker** - Create new specialized worker |
381 | | - - **Best for**: |
382 | | - * No existing worker has required capabilities |
383 | | - * Need specialized skills not currently available |
384 | | - - **Consider**: |
385 | | - * Whether decomposition could work instead |
386 | | - * Cost of creating new worker vs alternatives |
387 | | - - **Note**: Only available for task failures, not quality issues |
| 338 | +{available_strategies} |
388 | 339 |
|
389 | 340 | **DECISION GUIDELINES:** |
390 | 341 |
|
|
403 | 354 | - No explanations or text outside the JSON structure |
404 | 355 | - Ensure all required fields are included |
405 | 356 | - Use null for optional fields when not applicable |
| 357 | +- ONLY use strategies listed above as ENABLED |
406 | 358 | """ |
407 | 359 | ) |
408 | 360 |
|
|
423 | 375 | "modified_task_content": "new content if replan, else null" |
424 | 376 | }""" |
425 | 377 |
|
| 378 | +# Strategy descriptions for dynamic prompt generation |
| 379 | +STRATEGY_DESCRIPTIONS = { |
| 380 | + "retry": """**retry** - Retry with the same worker and task content |
| 381 | + - **Best for**: |
| 382 | + * Network errors, connection timeouts, temporary API issues |
| 383 | + * Random failures that are likely temporary |
| 384 | + * Minor quality issues that may resolve on retry |
| 385 | + - **Not suitable for**: |
| 386 | + * Fundamental task misunderstandings |
| 387 | + * Worker capability gaps |
| 388 | + * Persistent quality problems""", |
| 389 | + "reassign": """**reassign** - Assign to a different worker |
| 390 | + - **Best for**: |
| 391 | + * Current worker lacks required skills/expertise |
| 392 | + * Worker-specific issues or errors |
| 393 | + * Task requires different specialization |
| 394 | + - **Not suitable for**: |
| 395 | + * Task description is unclear (use replan instead) |
| 396 | + * Task is too complex (use decompose instead)""", |
| 397 | + "replan": """**replan** - Modify task content with clearer instructions |
| 398 | + - **Best for**: |
| 399 | + * Unclear or ambiguous requirements |
| 400 | + * Missing context or information |
| 401 | + * Task description needs improvement |
| 402 | + - **Requirements**: |
| 403 | + * Provide modified_task_content with enhanced, clear instructions |
| 404 | + * Modified task must be actionable for an AI agent |
| 405 | + * Address the root cause identified in issues""", |
| 406 | + "decompose": """**decompose** - Break into smaller, manageable subtasks |
| 407 | + - **Best for**: |
| 408 | + * Task is too complex for a single worker |
| 409 | + * Multiple distinct sub-problems exist |
| 410 | + * Persistent failures despite retries |
| 411 | + * Capability mismatches that need specialization |
| 412 | + - **Consider**: |
| 413 | + * Task depth (avoid if depth > 2) |
| 414 | + * Whether subtasks can run in parallel""", |
| 415 | + "create_worker": """**create_worker** - Create new specialized worker |
| 416 | + - **Best for**: |
| 417 | + * No existing worker has required capabilities |
| 418 | + * Need specialized skills not currently available |
| 419 | + - **Consider**: |
| 420 | + * Whether decomposition could work instead |
| 421 | + * Cost of creating new worker vs alternatives""", |
| 422 | +} |
| 423 | + |
426 | 424 | TASK_AGENT_SYSTEM_MESSAGE = """You are an intelligent task management assistant responsible for planning, analyzing, and quality control. |
427 | 425 |
|
428 | 426 | Your responsibilities include: |
|
0 commit comments