Skip to content

[Bug]: Under tmux a terminal query's reply is typed into the shell and breaks the next command #6652

Open

Description

@enyst

I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.

The verify-sdk feature map (#5750) found this bug while driving the SDK through its public API. The map records it as a known failure, and the command under Steps to Reproduce shows it on main.

Is there an existing issue for the same bug?

Bug Description

When a command prints a DSR cursor-position query (\e[6n), the query itself is filtered from the observation, but tmux answers it into the shell's input. The observation shows ^[[13;2R, and the next command's output starts with the echoed earlier command and bash: syntax error near unexpected token ';'. The subprocess backend drops the query cleanly.

Expected Behavior

The query is dropped and nothing else shows; echo next prints only next.

Actual Behavior

dsr_reply_visible true, after_dsr_clean false.

Steps to Reproduce

From a checkout of main (uv sync), with the verify-sdk tools on the path:

export PATH="$PWD/.agents/skills/verify-sdk/scripts:$PATH"
sdk-map run --file S14 --only S14.terminal-input-encoding

That runs this recipe from the map (each control-sdk call runs a short program in its own HOME, persistence and workspace):

export SDK_VERIFY_RUN=$(control-sdk new --field run)
control-sdk program S14/terminal --arg auto \
  --check escape_filtered eq true --check dsr_reply_visible eq false --check after_dsr_clean eq true

Acceptance Criteria

  • A terminal query in a command's output does not inject a reply into the shell's input on the tmux backend.
  • A test covers a DSR query followed by another command.
  • The S14.terminal-input-encoding bullet in .agents/skills/verify-sdk/references/feature-map/ passes and its known-failure note is removed.

Installation Method

uv sync in a checkout of main


OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

Repository evidence confirms the failure and bounds the scope. The shared query filter added for #2334 (TerminalQueryFilter in openhands-tools/openhands/tools/terminal/terminal/terminal_session.py) strips query sequences from captured output, but on the tmux backend the shell runs inside a real tmux pane (openhands-tools/openhands/tools/terminal/terminal/tmux_terminal.py), and tmux itself answers a cursor-position query by typing the CPR reply (e.g. ^[[13;2R) into the pane's shell input, corrupting the next command. The fix belongs on the tmux backend path so that queries in command output do not elicit replies into shell input, matching the subprocess backend, which already behaves correctly. The failure is reproduced on main by the repository's own verification recipe (S14.terminal-input-encoding in .agents/skills/verify-sdk/references/feature-map/S14-core-tools.md, known failure recorded 2026-10-13).

Non-goals: no change to SDK-side query filtering at the conversation/visualizer boundary (explicitly out of scope per #2334); no fix for the separate tmux interactive follow-up failure ("No previous running command to interact with") recorded in the same feature map; no Windows/PowerShell backend changes; no public API or schema changes. Suppression of non-DSR queries (OSC/DA) under tmux is only in scope to the extent the chosen mechanism already covers them; the verified case is the DSR query.

Acceptance Criteria

  • On the tmux backend, when a command's output prints a DSR cursor-position query (ESC[6n) and a second command is then executed, the second command's observation contains neither the query nor a CPR reply (e.g. ^[[13;2R), does not begin with the re-echoed earlier command, and the second command runs normally (its expected output appears with exit code 0).
  • The verification recipe sdk-map run --file S14 --only S14.terminal-input-encoding (tmux default backend: escape_filtered eq true, dsr_reply_visible eq false, after_dsr_clean eq true) passes on main.
  • An automated test under tests/tools/terminal/ drives a real tmux-backed session with a command that emits a DSR query followed by another command and asserts the follow-up observation is clean (no injected reply, correct output); it fails against the pre-fix behavior.
  • Existing output-filtering behavior is unchanged on both backends: tests/tools/terminal/test_escape_filter.py passes, including continued filtering of DSR/OSC/DA queries and preservation of non-query escape sequences.
  • The S14.terminal-input-encoding entry in .agents/skills/verify-sdk/references/feature-map/S14-core-tools.md no longer carries the tmux known-failure note.

Activity

  1. added
    bug
    ready-for-dev
    on Nov 9, 2026
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

    bugready-for-dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions