Bash / shell
Lets your agent run shell commands and act on the output. The two SDKs expose different tools here:
- TypeScript
bashspawns a persistentbashprocess on the host. Shell state (variables, working directory, exported functions) persists across invocations within the same session, so the agent can build up context incrementally. Sessions can be restarted to clear state. - Python
shell(and TypeScript’smakeShell) routes each command through the agent’s Sandbox and is stateless: every call runs in a fresh shell, so variables and the working directory do not carry over. The sandbox decides the interpreter (shlocally and in Docker, the remote login shell over SSH), so use portable POSIX syntax.
Supported in: Node.js on Unix/Linux/macOS (TypeScript), all platforms (Python).
Example - File Operations:
import { Agent } from '@strands-agents/sdk'import { bash } from '@strands-agents/sdk/vended-tools/bash'
const agent = new Agent({ tools: [bash],})
// List files and create a new fileawait agent.invoke('List all files in the current directory')await agent.invoke('Create a new file called notes.txt with "Hello World"')from strands import Agentfrom strands.vended_tools import shell
agent = Agent(tools=[shell])agent("List all Python files in the current directory and count them")Example - Session Persistence (TypeScript):
import { Agent } from '@strands-agents/sdk'import { bash } from '@strands-agents/sdk/vended-tools/bash'
const agent = new Agent({ tools: [bash],})
// Variables persist across invocations within the same sessionawait agent.invoke('Run: export MY_VAR="hello"')await agent.invoke('Run: echo $MY_VAR') // Will show "hello"
// Restart session to clear stateawait agent.invoke('Restart the bash session')await agent.invoke('Run: echo $MY_VAR') // Variable will be emptyFull API reference: shell, bash (TypeScript only)