Skip to main content

How can I use coding agents from the Databricks SSH tunnel?

Summary

  • Connect your IDE or terminal with databricks ssh connect, then run the agent inside that remote session, so it works on workspace files with full workspace context and runs code on Databricks compute.
  • Agents built into a supported IDE such as Cursor work through the tunnel's IDE window. Terminal agents such as Claude Code can be installed in the session while the tunnel is running.
  • For long agent tasks, start the tunnel with --keep-detached-processes and run the agent in tmux, so it keeps working after you disconnect. The compute keeps running and costs accrue until it finishes.
  • The SSH tunnel is in Beta and is positioned for IDE-driven development. For agent loops or untrusted code in a lightweight sandboxed environment, the docs point to Databricks Sandbox.
  • Genie Code CLI doesn't support SSH tunnel sessions; run it on your local machine.

How can I use coding agents from the Databricks SSH tunnel?

Open an SSH tunnel session on Databricks compute, then run the agent inside it. Once your IDE window or terminal is attached, the agent reads and edits workspace files directly, and the code it runs executes on Databricks serverless compute, AI Runtime or your dedicated cluster. The Databricks launch blog says agents in the tunnel "have full workspace context and work with Databricks more effectively." The SSH tunnel is in Beta.

Ways to run a coding agent with Databricks compute

Approach Where the agent works Best for
IDE agent over the tunnel (--ide cursor or --ide vscode) In the IDE window attached to remote compute, on workspace files Interactive, human-in-the-loop coding
Terminal agent installed in the SSH session On Databricks compute Agents you drive from a shell, including long-running tasks
Databricks Sandbox (Beta) Isolated lightweight serverless compute Agent loops and untrusted, AI-written code
Genie Code CLI (Beta) Your local machine only A Databricks-tuned agent; not supported in SSH tunnel sessions

What to check before you point an agent at the tunnel

  • Identity. Authentication uses the Databricks CLI and your configured workspace profile, so the session is tied to the profile you connect with.
  • Network egress. The agent still calls its own model service. The docs say outside services are reachable "as long as your cluster networking allows outbound connections."
  • Persistence. Files in /home, /root and other local paths are lost on restart. Keep the project under /Workspace or /Volumes, and expect to reinstall a terminal agent after a restart (on classic compute, an init script can install tools at startup).
  • Isolation. The tunnel gives the agent your real compute and your real files. If the code is untrusted, use a sandbox.

How Databricks supports coding agents in the SSH tunnel

Connect and open the project. With Databricks CLI 1.5.0 or above, start a session from your local machine:

databricks ssh connect --ide cursor

Use --ide vscode for Visual Studio Code, omit --ide for a terminal, or pass --cluster <cluster-id> for a dedicated cluster. The session opens in an ephemeral directory, so open /Workspace/Users/<your-username> before starting the agent. In the Databricks SSH tunnel demo, the IDE's agent lists and edits workspace files directly, and the changes show up in the workspace UI.
Add the agent. The blog says Cursor works out of the box, "while other agents like Claude Code can be installed when the SSH tunnel is running." Install a terminal agent inside the remote session by following that agent's own instructions, then launch it from your project folder. For agents that ship as IDE extensions, the SSH tunnel docs note that Visual Studio Code doesn't install local extensions on remote hosts by default. Enable them on the remote host, or list them in remote.SSH.defaultExtensions.
Give the agent working Spark code. Python files in the session don't define spark or dbutils. An agent writing scripts for serverless compute should start a session explicitly:

from databricks.connect import DatabricksSession
spark = DatabricksSession.builder.serverless().profile("DEFAULT").getOrCreate()

Keep long tasks alive. By default, shutting down the tunnel stops every process the session started, even ones detached with tmux, setsid or nohup. To let an agent keep working after you disconnect, set the flag on the connection that starts the tunnel:

databricks ssh connect --keep-detached-processes

Reconnect later and reattach with tmux attach. The tunnel still stops at the maximum lifetime set by --server-timeout, a classic cluster won't auto-terminate while detached work runs, and an idle tmux session counts as running. Close it when the agent is done.
Know when to switch. The SSH tunnel docs say the tunnel "is for IDE-driven development" and point coding agents that need "a lightweight, sandboxed environment" to Databricks Sandbox. Sandbox keeps a persistent home directory, and, if Unity Gateway is configured, sets up common coding harnesses to use it on first connect.

FAQs

Can I run Genie Code CLI inside the SSH tunnel?

No. The Genie Code CLI docs state it doesn't support SSH tunnel sessions. Run it on your local machine, where it works from any IDE's integrated terminal.

What does the agent authenticate with?

Authentication uses the Databricks CLI and your configured workspace profile. Unity Catalog must be enabled to use the tunnel.

What happens to an agent running when I close my laptop?

Without --keep-detached-processes, the tunnel stops the agent's processes when it shuts down, by default 10 minutes after the last client disconnects. With the flag, detached processes keep running until they exit or the server timeout hits.

Should I use the SSH tunnel or Databricks Sandbox for agents?

Use the tunnel when the agent needs your compute environment and workspace files. Use Sandbox for isolated agent loops and untrusted code that doesn't need Spark.

The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.