Replace magic time.Sleep literals in pkg/cli with named duration constants#34373
Merged
Conversation
5 tasks
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix hardcoded time.Sleep literals in production pkg/cli/
Replace magic May 24, 2026
time.Sleep literals in pkg/cli with named duration constants
pelikhan
approved these changes
May 24, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR replaces several inline time.Sleep duration literals in pkg/cli with named time.Duration constants to make the intent of each delay explicit at the call site while keeping the timing policy near the code it governs.
Changes:
- Introduce named duration constants for repository initialization, workflow trigger pacing, and MCP inspector/server startup/shutdown waits.
- Replace hardcoded
time.Sleep(<literal>)calls with the corresponding named constants across the affected CLI flows.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/trial_repository.go | Adds trialRepoInitDelay constant and uses it for post-repo-create initialization wait. |
| pkg/cli/run_workflow_execution.go | Adds betweenWorkflowsDelay constant and uses it to pace sequential workflow triggers. |
| pkg/cli/mcp_inspect.go | Adds mcpScriptsServerShutdownDelay constant and uses it during mcp-scripts shutdown cleanup. |
| pkg/cli/mcp_inspect_mcp_scripts_server.go | Adds a named delay constant for readiness polling sleep while waiting for the server to come up. |
| pkg/cli/mcp_inspect_inspector.go | Adds grouped constants for stdio server startup wait and inter-process cleanup pacing, and uses them in the inspector flow. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 2
| const ( | ||
| // mcpStdioServerStartupDelay gives stdio MCP servers time to start accepting connections. | ||
| mcpStdioServerStartupDelay = 2 * time.Second | ||
| // mcpProcessCleanupDelay spaces cleanup signals so each MCP process can exit cleanly. |
Comment on lines
21
to
25
| mcpScriptsStartPort = 3000 | ||
| mcpScriptsPortRange = 10 | ||
| // mcpScriptsServerStartupDelay paces readiness checks while the mcp-scripts server boots. | ||
| mcpScriptsServerStartupDelay = 200 * time.Millisecond | ||
| ) |
This was referenced May 24, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Several production paths in
pkg/cliencoded pacing and startup/shutdown waits as inlinetime.Sleepliterals. This change aligns those waits with the existing local named-constant pattern already used elsewhere in the CLI for retry and API cooldown behavior.Replace hardcoded CLI delays with local constants
time.Durationconstants for:Keep delay policy scoped to each call site
constblock to keep related timing policy together.Make intent explicit at the call sites