Skip to content

feat(terminal): multiple terminal sessions in TerminalTool - #2548

Merged
chaliy merged 1 commit into
mainfrom
claude/project-thread-vu3h37
Oct 7, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/project-thread-vu3h37

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

What changed

  • TerminalTool::with_sessions(size, factory) lets an agent open named terminal tabs on demand with a session argument (max 8). Tabs share the main session's filesystem but keep their own shell state (cwd, variables, history).
  • Background tabs keep running while a call waits on another, so an agent can start a long command in one tab (watch, a server loop) and keep working in another.
  • close: true drops a tab. A tab whose shell exited restarts on its next input. Results list every open session with its activity.
  • The tool schema advertises session/close only when sessions are enabled; plain TerminalTool::new is unchanged.
  • Python Terminal.call and JS Terminal.call accept session and close; both bindings always support sessions.

Why

Agents routinely need a second shell: watch a log while editing, or keep a REPL open while running commands. With one session they had to stop and restart work.

Before / After

Before: one terminal per tool; running watch -n1 date blocks every further call until Ctrl-C.
After:

call {"input":"watch -n1 date\n","session":"mon"}   -> sessions: [main: idle, mon: running]
call {"input":"echo hi > /tmp/x\n"}                   -> main runs while mon keeps refreshing
call {"session":"mon","close":true}                   -> sessions: [main: idle]

Risk

  • Low. terminal feature only (off by default). Session count is capped at 8 so a tool caller cannot grow memory without bound.

Checklist

  • Tests added or updated (Rust, Python, JS)
  • Backward compatibility considered

Generated by Claude Code

TerminalTool::with_sessions opens named tabs on demand via the session
argument (max 8). Tabs share the main session's VFS but keep their own
shell state, and background tabs keep running while a call waits on
another. close drops a tab; an exited tab restarts on next input. Python
and JS Terminal always support sessions.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit eb8dd35 Commit Preview URL

Branch Preview URL
Oct 07 2026, 07:03 AM

@chaliy
chaliy merged commit 2f6c362 into main Oct 7, 2026
48 checks passed
@chaliy
chaliy deleted the claude/project-thread-vu3h37 branch October 7, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant