Description
When the LLM returns an empty or extremely short response (< 2 characters), parse_and_detect_failure() parses it as the fallback Command::Ls (because the empty string matches the _ => Command::Ls pattern). However, the is_parse_failure check evaluates !trimmed.starts_with("ls") — an empty string does not start with "ls", so is_parse_failure = true. The worker logs a parse failure but does not consume a round (because the continue statement skips dec_round()).
If the LLM persistently returns empty responses (e.g., due to API abnormalities), the worker will enter an infinite loop until the llm_calls budget is exhausted.
Reproduction Conditions
The LLM API returns empty responses repeatedly.
Related Code
rust/src/agent/worker/execute.rs:234 — parse_and_detect_failure()
rust/src/agent/worker/mod.rs:220-241 — Parse failure handling and continue
Suggested Fix
Parse failures should also consume a round (or at minimum, implement a consecutive failure counter that forces a "done" state when a threshold is exceeded).
Description
When the LLM returns an empty or extremely short response (< 2 characters),
parse_and_detect_failure()parses it as the fallbackCommand::Ls(because the empty string matches the_ => Command::Lspattern). However, theis_parse_failurecheck evaluates!trimmed.starts_with("ls")— an empty string does not start with "ls", sois_parse_failure = true. The worker logs a parse failure but does not consume a round (because thecontinuestatement skipsdec_round()).If the LLM persistently returns empty responses (e.g., due to API abnormalities), the worker will enter an infinite loop until the
llm_callsbudget is exhausted.Reproduction Conditions
The LLM API returns empty responses repeatedly.
Related Code
rust/src/agent/worker/execute.rs:234—parse_and_detect_failure()rust/src/agent/worker/mod.rs:220-241— Parse failure handling andcontinueSuggested Fix
Parse failures should also consume a round (or at minimum, implement a consecutive failure counter that forces a "done" state when a threshold is exceeded).