Skip to content

Commit d0050b2

Browse files
fix(tmux_read): implement tail behaviour and change default lines from 100 to 20
- Always capture full _MAX_READ_LINES scrollback buffer from tmux - Slice last N lines in Python for true tail behaviour - Change default lines: 100 -> 20 - Update description to reflect new behaviour Tested with: claude-sonnet-4-6 Co-Authored-By: bpsa2 <241537330+bpsa2@users.noreply.github.com>
1 parent c971069 commit d0050b2

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/smolagents/bp_tools_tmux.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,23 +164,26 @@ class TmuxReadTool(Tool):
164164
},
165165
"lines": {
166166
"type": "integer",
167-
"description": "Number of scrollback lines to capture. Defaults to 100.",
167+
"description": "Number of lines to return from the end of the buffer (tail behaviour). Defaults to 20.",
168168
"nullable": True,
169169
},
170170
}
171171
output_type = "string"
172172

173173
def forward(self, session_name: str, lines: int | None = None) -> str:
174174
if lines is None:
175-
lines = 100
175+
lines = 20
176176
lines = min(lines, _MAX_READ_LINES)
177177
full = _full_name(session_name)
178-
result = _run_tmux("capture-pane", "-t", full, "-p", "-S", f"-{lines}")
178+
# Always capture the full scrollback; tail-slice in Python afterwards.
179+
result = _run_tmux("capture-pane", "-t", full, "-p", "-S", f"-{_MAX_READ_LINES}")
179180
if result.returncode != 0:
180181
return f"ERROR: {result.stderr.strip()}"
181-
# Strip trailing blank lines for cleaner output
182182
output = result.stdout.rstrip("\n")
183-
return output if output else "(empty screen)"
183+
if not output:
184+
return "(empty screen)"
185+
# Return only the last `lines` lines (tail behaviour).
186+
return "\n".join(output.splitlines()[-lines:])
184187

185188

186189
# ======================================================================

0 commit comments

Comments
 (0)