Skip to content

Conversation

@tadasant
Copy link

@tadasant tadasant commented Jul 28, 2025

(closed this because diff was nasty -- going to re-open against 1.1.4)

#3691

Description

This PR adds support for configurable task timeouts in sub-recipes, allowing users to specify custom execution timeouts for individual sub-recipes that may require more time than the default timeout allows.

Motivation

Currently, all sub-recipe tasks use a global default timeout (typically 300 seconds). However, some sub-recipes may legitimately need more time to complete, such as:

  • Long-running data processing tasks
  • Complex build processes
  • Tasks that involve downloading large files
  • Integration tests that take significant time

Without the ability to configure timeouts per sub-recipe, users have to either:

  1. Increase the global timeout for all tasks (inefficient)
  2. Break down long-running tasks into smaller pieces (not always practical)
  3. Accept that some valid tasks will timeout (poor user experience)

Implementation Details

1. Task Timeout Extraction

  • Added get_task_timeout() method to the Task struct that extracts the task_timeout value from the task payload
  • Supports both sub_recipe and text_instruction task types
  • Returns Option<u64> to handle cases where no timeout is specified

2. Sub-Recipe Task Creation

  • Modified create_sub_recipe_task() to extract task_timeout from sub-recipe values if present
  • The timeout is parsed from string to u64 and included in the task payload
  • Invalid timeout values are gracefully ignored

3. Task Execution

  • Updated both single-task and parallel execution to use task-specific timeouts
  • Falls back to the default timeout when no task-specific timeout is provided
  • Workers now extract the timeout for each task individually

4. Backward Compatibility

  • The feature is fully backward compatible
  • Existing sub-recipes without task_timeout specified will continue to use the default timeout
  • No changes required to existing recipe definitions

Usage Example

Users can now specify a timeout in their sub-recipe configuration:

sub_recipes:
  - name: long_running_build
    path: recipes/build.yaml
    values:
      task_timeout: "7200"  # 2 hours
      target: "release"

Testing

Comprehensive test coverage has been added:

  • Unit tests for timeout extraction logic
  • Tests for handling invalid timeout values
  • Integration tests for task creation with timeouts
  • Edge case handling (negative numbers, non-numeric strings)

All tests pass successfully.

Changes Made

  1. types.rs: Added get_task_timeout() method to extract timeout from task payload
  2. sub_recipe_tools.rs: Modified task creation to include timeout in payload
  3. executor.rs: Updated to use task-specific timeouts for single task execution
  4. workers.rs: Modified worker loop to use task-specific timeouts
  5. Comprehensive test suite: Added tests for all new functionality

Note

This PR is based on the v1.1.4 release (commit cc34ce2) to ensure compatibility with the stable version. The implementation accounts for the directory structure differences between versions (using sub_recipe_execution_tool instead of subagent_execution_tool).

zanesq and others added 29 commits July 16, 2025 14:10
…over text and chat input height returning to auto (block#3469)
rust failures are not related
- Add get_task_timeout method to Task struct to extract timeout from payload
- Update workers and executor to use task-specific timeouts
- Modify sub_recipe_tools to include task_timeout in task payload when present
- Support both sub_recipe and text_instruction task types

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add unit tests for get_task_timeout method in types module
- Test timeout extraction for both sub_recipe and text_instruction tasks
- Add tests for sub_recipe_tools task creation with timeouts
- Test invalid timeout values and edge cases
- Add executor tests for custom timeout handling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@tadasant tadasant closed this Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants