AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

ShellSession Times Out When Stdout Has No Trailing Newline And The Done Marker Is Appended To The Same Line

The ShellSession execution erroneously times out when a command produces output without a trailing newline because the completion marker is appended to the same line, causing the startswith check to fail and the session to wait until timeout.

highConfidence 95%LangchainMemoryEmbeddingsAffected V1.2.15

Origin Analysis

The completion marker is injected via a separate printf after the command output. When the command output does not end with a newline, the marker and the output are concatenated into one line. The detection logic checks only if the line starts with the marker, so it misses the marker and treats the command as still running.
Start a ShellSession with bash, execute 'printf "hello without newline"', and observe that the result is empty with timed_out=True instead of returning the output with timed_out=False.

Fixing Code Block

Edge Case Audit

This fix assumes the marker string is unique enough not to appear in legitimate command output. If the marker appears multiple times, only the first occurrence is respected, and any subsequent content is ignored. Malformed marker output (missing exit code) could raise a ValueError; consider wrapping the exit code parsing in a try/except. No concurrency issues are introduced, but rollback to the original code is straightforward if needed.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state