ConnectOnionConnectOnion

bash

Execute bash commands from an agent. Returns stdout + stderr as a string. Unix/Mac only.

The simplest way to give an agent shell access: from connectonion import bash and pass it as a tool.

Quick Start

main.py
1from connectonion import Agent, bash 2 3agent = Agent("coder", tools=[bash]) 4 5agent.input("run the tests and show failures") 6agent.input("install httpx and show the installed version") 7agent.input("check git log for last 5 commits")

API Reference

main.py
1bash(command, description, cwd=".", timeout=120)
ParameterTypeDefaultDescription
commandstrrequiredBash command to run
descriptionstrrequiredWhat the command does (shown to user)
cwdstr"."Working directory
timeoutint120Seconds before timeout (max 600)

Examples

main.py
1from connectonion import bash 2 3# Basic commands 4bash("git status", "Check git status") 5bash("python --version", "Check Python version") 6 7# Working directory 8bash("npm install", "Install packages", cwd="/path/to/project") 9bash("pytest -v", "Run tests", cwd="./my-module") 10 11# Longer timeout 12bash("npm run build", "Build project", timeout=300) 13 14# Direct call — returns output string 15result = bash("git log --oneline -5", "Recent commits") 16print(result)

Combined with FileTools

A common pair — FileTools for reading/editing, bash for running:

main.py
1from connectonion import Agent, bash 2from connectonion.useful_tools.file_tools import FileTools 3 4agent = Agent("coder", tools=[FileTools(), bash]) 5 6agent.input("read main.py, fix the import error, then run it to verify")

Notes

• Output truncated at 10,000 characters to prevent token overflow

• stdout and stderr are merged in the returned string

• Non-zero exit codes included in output (Exit code: 1)

• Unix/Mac only — use Shell for cross-platform

Enjoying ConnectOnion?

⭐ Star us on GitHub = ☕ Coffee chat with our founder. We love meeting builders.