Skip to content

[BUG] Wait tool: command condition returns condition_met immediately when gh run view exits 0 for still-running jobs #816

Closed

Description

@edenreich

Summary

The Wait tool's command condition returns condition_met immediately when the check command exits 0, even if the underlying process is still running. This makes it unusable with commands like gh run view --exit-status that exit 0 for both "still running" and "completed successfully".

Steps to Reproduce

  1. Dispatch a workflow run that takes >30s (e.g. migrate-infer.yml)
  2. Call Wait(condition=command, command="gh run view RUN_ID --repo inference-gateway/.github --exit-status", pending_exit_codes=[8], timeout_seconds=300)
  3. Observe that Wait returns condition_met in ~2s even though the run is still in progress

Expected Behavior

The tool should keep polling until the run actually finishes (or fails), not return immediately on exit 0. The pending_exit_codes mechanism should handle commands that don't have a dedicated "still pending" exit code.

Actual Behavior

pending_exit_codes is designed for commands like gh pr checks that return exit code 8 while pending. But gh run view --exit-status exits 0 for both "still running" and "completed successfully" — it only exits non-zero on failure. So the Wait tool sees exit 0 and thinks the condition is met, returning immediately instead of polling.

Workaround: Use sleep + gh run view in a loop instead.

Activity

  1. added
    bug
    on Jul 9, 2026
  2. added theissue type on Jul 9, 2026
  3. moved this to Todo in 2026on Jul 9, 2026
  4. changed the title [-]Wait tool: command condition returns condition_met immediately when gh run view exits 0 for still-running jobs[/-] [+][BUG] Wait tool: command condition returns condition_met immediately when gh run view exits 0 for still-running jobs[/+] on Jul 9, 2026
  5. edenreich commented on Jul 9, 2026

    @edenreich
    ContributorAuthor

    @infer Can you fix this?

  6. inference-gateway-maintainer commented on Jul 9, 2026

    @inference-gateway-maintainer
    Contributor

    Model: ollama_cloud/deepseek-v4-flash · View Job

    Todos

    • Understand the issue: Wait tool command condition returns condition_met on exit 0 even when process is still running
    • Find and read the Wait tool implementation
    • Design the fix: add pending_exit_codes_include_zero parameter
    • Implement the fix in wait.go
    • Update prompts config for the new parameter
    • Add tests for the new parameter
    • Run pre-commit and push

    Pull Request

    #819

    ✅ Infer Result: Success

    Added a new pending_exit_codes_include_zero boolean parameter to the Wait tool's command condition that, when true, treats exit code 0 as "still pending, keep polling" instead of condition_met, fixing the bug where commands like gh run view --exit-status that exit 0 for both "still running" and "completed successfully" would cause the wait to return immediately.

    Model: ollama_cloud/deepseek-v4-flash · Exit Code: 0 · Duration: 13m 20s

    Tokens: 4,275,711 in · 17,389 out · 4,293,100 total (47 requests)

    Tool calls: 53 total · 92% success rate

    ⚠️ 4 failed tool call(s)
    • Edit: old_string not found in file /home/runner/work/cli/cli/internal/agent/tools/wait.go

    Possible matches found:

    Near line 219:
    if err := validatePendingExitCodes(args); err != nil {
    return err
    }
    }

    return nil
    

    }

    // validatePendingExitCodes checks that pending_exit_codes, when present, is
    // an array of numbers.
    func validatePendingExitCodes(args map[string]any) error {

    Hint: Ensure exact whitespace and indentation match. Use the Read tool to see the current file content.

    • Bash: exit status 1: --- FAIL: TestWaitTool_Execute_CommandPendingIncludeZero (10.00s)
      wait_test.go:780: Execute() should succeed once the check output changes, got error: timed out after 10s waiting for condition 'command'
      wait_test.go:787: Execute() reason = "timeout", want "condition_met"
      FAIL
      FAIL github.com/inference-gateway/cli/internal/agent/tools 14.052s
      FAIL
    • Bash: exit status 1: --- FAIL: TestWaitTool_Execute_CommandPendingIncludeZeroWithPendingCodes (1.00s)
      wait_test.go:809: Execute() error = "check command failed with exit code -1 (not in pending_exit_codes)", want containing "timed out"
      FAIL
      FAIL github.com/inference-gateway/cli/internal/agent/tools 5.050s
      FAIL
    • Bash: exit status -1: �[32mtask: [precommit:run] pre-commit run --all-files
      �[0m[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
      [INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
      [INFO] Once installed this environment will be reused.
      [INFO] This may take a few minutes...
      trim trailing whitespace.................................................Passed
      fix end of files.........................................................Passed
      check yaml...............................................................Passed
      check json...............................................................Passed
      check toml...............................................................Passed
      check for merge conflicts................................................Passed
      check for added large files..............................................Passed
      mixed line ending........................................................Passed
      Go mod tidy..............................................................Passed
      Format code..............................................................Failed
    • hook id: fmt
    • files were modified by this hook

    �[32mtask: [fmt] go fmt ./...
    �[0minternal/agent/tools/wait.go
    internal/agent/tools/wait_test.go

    Lint.....................................................................Passed
    Generate mocks...........................................................Passed

    Triggered by edenreich · Infer Action

  7. moved this from Todo to In progress in 2026on Jul 9, 2026
  8. added a commit that references this issue on Jul 9, 2026
    17522fa
  9. moved this from In progress to QA in 2026on Jul 9, 2026
  10. moved this from QA to Done in 2026on Jul 10, 2026
  11. inference-gateway-releaser commented on Jul 10, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.141.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugreleased

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions