-
Notifications
You must be signed in to change notification settings - Fork 4
refactor: replace magic numbers with documented named constants #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| //! Centralized timeout constants for the Cortex CLI. | ||
| //! | ||
| //! This module provides consistent timeout values used throughout the codebase. | ||
| //! Centralizing these values ensures uniformity and makes it easier to adjust | ||
| //! timeouts across the application. | ||
|
|
||
| /// Default timeout for the entire execution in seconds (10 minutes). | ||
| /// | ||
| /// This is the maximum time allowed for a complete headless execution, | ||
| /// including all LLM requests and tool executions. | ||
| pub const DEFAULT_EXEC_TIMEOUT_SECS: u64 = 600; | ||
|
|
||
| /// Default timeout for a single LLM request in seconds (2 minutes). | ||
| /// | ||
| /// This is the maximum time to wait for a single completion request | ||
| /// to the LLM provider. | ||
| pub const DEFAULT_REQUEST_TIMEOUT_SECS: u64 = 120; | ||
|
|
||
| /// Default timeout for streaming responses in seconds (5 minutes). | ||
| /// | ||
| /// Extended timeout for LLM streaming requests where responses are | ||
| /// delivered incrementally over time. | ||
| pub const DEFAULT_STREAMING_TIMEOUT_SECS: u64 = 300; | ||
|
|
||
| /// Default timeout for health check requests in seconds (5 seconds). | ||
| /// | ||
| /// Short timeout used for quick health check endpoints. | ||
| pub const DEFAULT_HEALTH_CHECK_TIMEOUT_SECS: u64 = 5; | ||
|
|
||
| /// Default timeout for graceful shutdown in seconds (30 seconds). | ||
| /// | ||
| /// Maximum time to wait for in-flight operations to complete during | ||
| /// shutdown before forcing termination. | ||
| pub const DEFAULT_SHUTDOWN_TIMEOUT_SECS: u64 = 30; | ||
|
|
||
| /// Default timeout for batch execution in seconds (5 minutes). | ||
| /// | ||
| /// Maximum time allowed for executing a batch of parallel tool calls. | ||
| pub const DEFAULT_BATCH_TIMEOUT_SECS: u64 = 300; | ||
|
|
||
| /// Default timeout for individual read operations in seconds (30 seconds). | ||
| /// | ||
| /// Timeout for individual read operations to prevent hangs when | ||
| /// Content-Length doesn't match actual body size. | ||
| pub const DEFAULT_READ_TIMEOUT_SECS: u64 = 30; | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| #[test] | ||
| fn test_timeout_values_are_reasonable() { | ||
| // Exec timeout should be greater than request timeout | ||
| assert!(DEFAULT_EXEC_TIMEOUT_SECS > DEFAULT_REQUEST_TIMEOUT_SECS); | ||
|
|
||
| // Streaming timeout should be greater than request timeout | ||
| assert!(DEFAULT_STREAMING_TIMEOUT_SECS > DEFAULT_REQUEST_TIMEOUT_SECS); | ||
|
|
||
| // Health check should be short | ||
| assert!(DEFAULT_HEALTH_CHECK_TIMEOUT_SECS <= 10); | ||
|
|
||
| // Batch timeout should be reasonable | ||
| assert!(DEFAULT_BATCH_TIMEOUT_SECS >= 60); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timeout_secsparameter is still defined inBatchToolArgsand the tool definition but is no longer used in the implementation. Either remove it entirely (breaking change) or use it for an overall batch timeout wrapper around the parallel execution.Prompt To Fix With AI