agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

bug(modelcatalog): discovery failure surfaces raw Go sentinel "exec: WaitDelay expired before I/O complete" in New Task dialog

Open OrcInc opened this issue 3 months ago • 5 comments

Bug

The Create a new task dialog shows an opaque raw Go sentinel as the model-picker warning when the selected agent (agy / Antigravity in the report) leaves a descendant process holding the discovery command's output pipe:

agy model discovery: exec: WaitDelay expired before I/O complete

Discovery also fails outright — the model picker degrades to free-text with no model list, and the warning paints in error-orange above the composer.

Source: reported by Aryan F in Discord #bug-triage (thread 1543907622300811346), 2026-08-31 | Analyzed against: f2fcecbf7 (origin/main) | Confidence: High

New Task dialog showing the raw WaitDelay error and Auth unknown badges

Reproduction

  1. Install agy (Antigravity) — its launcher leaves estate/language-server descendant processes alive after the parent CLI exits.
  2. Open the app → Create a new task with Agy selected (or any command-backed agent whose CLI leaves pipe-holding descendants).
  3. The daemon runs discovery: agy models via Discover() (backend/internal/adapters/agent/modelcatalog/catalog.go).
  4. Orange error line appears: agy model discovery: exec: WaitDelay expired before I/O complete, and no model list loads.

Verified locally with an equivalent fixture: a script that exits 0 while a backgrounded (sleep 5) & descendant keeps stdout/stderr open — Discover fails with exactly this error shape after the 2s WaitDelay, with the 20s context still live.

Root Cause

modelcatalog.Discover() runs agy models with cmd.CombinedOutput() (catalog.go:158-164):

  • modelCommand() sets cmd.WaitDelay = commandTerminationWait (2s, catalog.go:268) — added so a timed-out discovery doesn't linger while orphaned descendants hold the pipes.
  • agy's parent process exits quickly, but a descendant keeps the output pipe open. CombinedOutput() therefore can't complete I/O; after the 2s WaitDelay it returns exec.ErrWaitDelay while runCtx (20s) is still live.
  • modelDiscoveryError() (catalog.go:298-306) only maps errors when runCtx.Err() is DeadlineExceeded or Canceled. exec.ErrWaitDelay matches neither branch, so it falls to the generic wrap: "agy model discovery: exec: WaitDelay expired before I/O complete" — the raw Go sentinel shipped straight to the UI.
  • The service layer converts discovery errors into a warning string on the fallback catalog (backend/internal/service/agent/service.go:590-595), and TaskComposer.tsx:246 (modelWarning) renders it verbatim as the orange line — so any unmapped discovery error surfaces raw by design. The mapping gap is in modelDiscoveryError.

Impact scope: every command-backed adapter using CombinedOutput discovery (agy, opencode, kilocode, aider, grok, cursor, pi, kimchi, auggie, devin, kiro, …) on any platform where the CLI leaves pipe-holding descendants. agy/Antigravity is the known recurring offender.

Reporter's screenshot also shows "Auth unknown" on agy/Copilot rows: that is #4639, a separate known issue — agy AuthStatus() still returns Unknown unconditionally on main (the fix PR #4640 was closed unmerged). Not a regression; not covered by this issue.

Fix

fix/model-discovery-waitdelay (PR incoming): in modelDiscoveryError, match errors.Is(commandErr, exec.ErrWaitDelay) and rewrite it into a human-readable explanation:

agy model discovery timed out: the agent CLI exited but left a descendant process holding the output pipe (WaitDelay 2s exceeded)

Tests: sentinel-mapping unit test + a real-command fixture (#!/bin/sh + (sleep 5) & + exit 0) asserting Discover returns the rewritten message. Both pass; full go test ./internal/adapters/agent/... ./internal/service/agent/... green.

Follow-ups considered, not in scope of this fix:

  • Making discovery resilient to pipe-holding descendants (e.g. cmd.Stdout/cmd.Stderr into explicit buffers closed on parent exit, or a process-group kill) so agy catalogs can succeed — larger change, needs its own issue if wanted.
  • agy auth status remains "Auth unknown" until #4639's fix lands.

Impact

  • Users on agy (and any agent with pipe-holding descendants) see a cryptic Go sentinel in the New Task dialog and get no model list.
  • The error is deterministic for affected agents: the manual-fallback catalog persists the warning, so it reappears on every dialog open until a discovery succeeds.
  • No crash, no data loss — degraded UX with an unreadable error.

Related

  • #4639 — agy "Auth unknown" badge (separate, closed-unmerged-fix)
  • #3385 — adapter-aware model selection (introduced the discovery layer)
  • #4114 — tightened agent auth probes (touched agy AuthStatus)

OrcInc avatar Aug 31 '26 09:08 OrcInc

Thanks for contributing to Agent Orchestrator.

This issue is being picked up by the current external contributor on-call pair:

  • @neversettle17-101
  • @illegalcall

If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @neversettle17-101 and @illegalcall here.

For faster context or live questions, you can also join the AO Discord.

Join the session here: https://discord.gg/H6ZDcUXmq

Come by if you want to see what is being built, ask questions, or just hang around with the community.

somewherelostt avatar Aug 31 '26 15:08 somewherelostt

Correction to the Related section: the agy auth-readiness fix now lives in open PR #4589 (centralize harness readiness), which flips agy AuthStatus() to Authorized when the binary is installed — rationale: keyring/browser auth has no documented non-interactive status command, and launch remains authoritative. #4589 is still OPEN, so shipped builds keep showing "Auth unknown" until it merges.

OrcInc avatar Sep 01 '26 17:09 OrcInc

Status: PR #4703 closed in favor of folding the fix into #4610 (per @nikhilachale). #4610 currently does not cover this — agy keeps the CombinedOutput path and modelDiscoveryError is untouched, so the raw-sentinel leak remains reachable. Fix commit available for cherry-pick: 25537feaf on fix/model-discovery-waitdelay. Issue stays open until the mapping lands.

OrcInc avatar Sep 01 '26 17:09 OrcInc

alread fixed in #5051

nikhilachale avatar Sep 08 '26 18:09 nikhilachale

Rechecked against current main after #5051 merged: this remains reproducible in code. modelDiscoveryError still maps only context deadline/cancellation and otherwise wraps exec.ErrWaitDelay verbatim, so #5051 did not resolve this sentinel leak. The earlier fix commit 25537feaf remains unmerged. Assigning for a focused implementation.

codebanditssss avatar Sep 23 '26 14:09 codebanditssss