|
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 from the ENABLED strategies below: |
| 336 | +If the task quality is insufficient, select the best recovery strategy: |
337 | 337 |
|
338 | | -{available_strategies} |
| 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 |
339 | 388 |
|
340 | 389 | **DECISION GUIDELINES:** |
341 | 390 |
|
|
354 | 403 | - No explanations or text outside the JSON structure |
355 | 404 | - Ensure all required fields are included |
356 | 405 | - Use null for optional fields when not applicable |
357 | | -- ONLY use strategies listed above as ENABLED |
358 | 406 | """ |
359 | 407 | ) |
360 | 408 |
|
|
369 | 417 | QUALITY_EVALUATION_RESPONSE_FORMAT = """JSON format: |
370 | 418 | { |
371 | 419 | "quality_score": 0-100, |
372 | | - "reasoning": "explanation (1-2 sentences)", |
| 420 | + "reasoning": "explanation (1-2 sentences)", |
373 | 421 | "issues": ["issue1", "issue2"], |
374 | 422 | "recovery_strategy": "retry|reassign|replan|decompose or null", |
375 | 423 | "modified_task_content": "new content if replan, else null" |
376 | 424 | }""" |
377 | 425 |
|
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 quality issues |
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 | | - - **Note**: Only available for quality issues, not failures""", |
398 | | - "replan": """**replan** - Modify task content with clearer instructions |
399 | | - - **Best for**: |
400 | | - * Unclear or ambiguous requirements |
401 | | - * Missing context or information |
402 | | - * Task description needs improvement |
403 | | - - **Requirements**: |
404 | | - * Provide modified_task_content with enhanced, clear instructions |
405 | | - * Modified task must be actionable for an AI agent |
406 | | - * Address the root cause identified in issues""", |
407 | | - "decompose": """**decompose** - Break into smaller, manageable subtasks |
408 | | - - **Best for**: |
409 | | - * Task is too complex for a single worker |
410 | | - * Multiple distinct sub-problems exist |
411 | | - * Persistent failures despite retries |
412 | | - * Capability mismatches that need specialization |
413 | | - - **Consider**: |
414 | | - * Task depth (avoid if depth > 2) |
415 | | - * Whether subtasks can run in parallel""", |
416 | | - "create_worker": """**create_worker** - Create new specialized worker |
417 | | - - **Best for**: |
418 | | - * No existing worker has required capabilities |
419 | | - * Need specialized skills not currently available |
420 | | - - **Consider**: |
421 | | - * Whether decomposition could work instead |
422 | | - * Cost of creating new worker vs alternatives |
423 | | - - **Note**: Only available for task failures, not quality issues""", |
424 | | -} |
425 | | - |
426 | 426 | TASK_AGENT_SYSTEM_MESSAGE = """You are an intelligent task management assistant responsible for planning, analyzing, and quality control. |
427 | 427 |
|
428 | 428 | Your responsibilities include: |
|
0 commit comments