Skip to content

fix(langchain): handle done markers after stdout without trailing newline#36695

Closed
nu1lx wants to merge 1 commit intolangchain-ai:masterfrom
nu1lx:fix-shell-marker-no-newline
Closed

fix(langchain): handle done markers after stdout without trailing newline#36695
nu1lx wants to merge 1 commit intolangchain-ai:masterfrom
nu1lx:fix-shell-marker-no-newline

Conversation

@nu1lx
Copy link
Copy Markdown

@nu1lx nu1lx commented Apr 13, 2026

Fixes #36696

Summary

  • handle shell done markers when stdout does not end with a trailing newline
  • preserve stdout content that appears before the marker on the same line
  • add regression coverage for both normal and truncated non-newline stdout

Why

ShellSession currently only recognizes completion when a stdout line starts with the done marker. If a command writes stdout without a trailing newline, the injected marker is appended to that same line instead. In that case, the marker is missed and the command can time out even though it already finished.

Testing

  • uv run ruff check langchain/agents/middleware/shell_tool.py tests/unit_tests/agents/middleware/implementations/test_shell_tool.py
  • uv run pytest tests/unit_tests/agents/middleware/implementations/test_shell_tool.py -k 'stdout_without_trailing_newline or truncated_stdout_without_trailing_newline or stderr_output_labeling'

AI disclaimer

This PR was drafted with the help of an AI coding agent, then reviewed and refined by a human.

@github-actions github-actions bot added fix For PRs that implement a fix langchain `langchain` package issues & PRs size: S 50-199 LOC labels Apr 13, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 13, 2026

This PR has been automatically closed because you are not assigned to the linked issue.

External contributors must be assigned to an issue before opening a PR for it. Please:

  1. Comment on the linked issue to request assignment from a maintainer
  2. Once assigned, your PR will be reopened automatically

Maintainers: reopen this PR or remove the missing-issue-link label to bypass this check.

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

Labels

external fix For PRs that implement a fix langchain `langchain` package issues & PRs missing-issue-link new-contributor size: S 50-199 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ShellSession times out when stdout has no trailing newline and the done marker is appended to the same line

1 participant