Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 79 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# Strands CLI
# Strands Agent Builder

> When terminal meets intelligence: AI at your fingertips.

A minimalist Strands Agents-powered CLI assistant for your terminal. Strands brings the power of Claude 3.7 Sonnet to your command line with advanced tool integration and knowledge base capabilities.
An interactive Strands agent toolkit designed to help you build, test, and extend your own custom AI agents and tools. With the Strands Agent Builder, you can create specialized agents, develop custom tools, and compose complex AI workflows—all from your terminal.

## Quick Start

```bash
# Install
pipx install strands-agents-builder

# Run interactive mode
# Run interactive mode for agent development
strands

# One-off query
strands "What's the capital of France?"
# Build a custom tool and use it immediately
strands "Create a tool named sentiment_analyzer that analyzes text sentiment and test it with some examples"

# Pipe content
cat document.txt | strands "Summarize this"
# Pipe content to build an agent based on specifications
cat agent-spec.txt | strands "Build a specialized agent based on these specifications"

# Use with knowledge base
strands --kb YOUR_KB_ID "Tell me about our project"
# Use with knowledge base to extend existing tools
strands --kb YOUR_KB_ID "Load my previous calculator tool and enhance it with scientific functions"
```

## Features

- 🏗️ Create and test custom tools with instant hot-reloading
- 🤖 Build specialized agents with focused capabilities
- 🔄 Extend existing tools and enhance their functionality
- 💬 Interactive command-line interface with rich output
- 🔍 One-off queries via arguments or pipes
- 🛠️ Powerful integrated tools (12+ tools including shell, editor, HTTP, Python)
- 🧠 Knowledge base integration for memory and context
- 🎮 Customizable system prompt
- 🧠 Knowledge base integration for persisting and loading tools
- 🎮 Customizable system prompt for specialized agents
- 🪄 Nested agent capabilities with tool delegation
- 🔧 Dynamic tool loading for extending functionality
- 🖥️ Environment variable management and customization
Expand All @@ -53,39 +53,87 @@ Strands comes with a comprehensive set of built-in tools:

## Knowledge Base Integration

Strands can leverage Amazon Bedrock Knowledge Bases to retrieve information and remember conversations.
Strands Agent Builder leverages Amazon Bedrock Knowledge Bases to store and retrieve custom tools, agent configurations, and development history.

```bash
# Specify knowledge base via command line
strands --kb YOUR_KB_ID "What does our API do?"
# Load and extend tools from your knowledge base
strands --kb YOUR_KB_ID "Load my data_visualizer tool and add 3D plotting capabilities"

# Or set a default knowledge base via environment variable
export STRANDS_KNOWLEDGE_BASE_ID="YOUR_KB_ID"
strands "What were our key decisions last week?"
strands "Find my most recent agent configuration and make it more efficient"
```

Features:
- 🔄 Automatic retrieval of relevant information before answering queries
- 💾 Conversation storage for building persistent memory
- 📝 Every exchange is stored with proper formatting for future reference
- 🔍 Contextual awareness across multiple conversations
- 🔄 Retrieve previously created tools and agent configurations
- 💾 Persistent storage for your custom tools and agents
- 🛠️ Ability to iteratively improve tools across sessions
- 🔍 Find and extend tools built in previous sessions

## Nested Agent Capabilities

Use the `strands` tool to create specialized sub-agents with their own tools and system prompts:
Use the `strands` tool to prototype and test specialized sub-agents with their own tools and system prompts:

```python
# Basic usage
agent.tool.strand(query="List files in the current directory")
# Create a specialized data analysis agent
agent.tool.strand(
query="Build and test a data analysis agent",
tool_names=["python_repl", "editor", "http_request"],
system_prompt="You're an AI specialized in data analysis. Your task is to build tools for data processing and visualization."
)

# With specific tools
# Create a tool-building agent focused on web automation
agent.tool.strand(
query="Analyze this Python code",
tool_names=["python_repl", "editor"],
system_prompt="You are an expert Python developer specializing in code optimization."
query="Create a set of web automation tools for browser testing",
tool_names=["editor", "python_repl", "shell"],
system_prompt="You're an expert in creating web automation tools. Your specialty is developing reliable browser testing utilities."
)
```

## Model Configuration

### Optimized Defaults

Strands comes with optimized, maxed-out configuration settings for the Bedrock model provider:

```json
{
"model_id": "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
"max_tokens": 64000,
"boto_client_config": {
"read_timeout": 900,
"connect_timeout": 900,
"retries": {
"max_attempts": 3,
"mode": "adaptive"
}
},
"additional_request_fields": {
"thinking": {
"type": "enabled",
"budget_tokens": 2048
}
}
}
```

These settings provide:
- Claude 3.7 Sonnet (latest high-performance model)
- Maximum token output (64,000 tokens)
- Extended timeouts (15 minutes) for complex operations
- Automatic retries with adaptive backoff
- Enabled thinking capability with 2,048 token budget for recursive reasoning

You can customize these values using environment variables:

```bash
# Maximum tokens for responses
export STRANDS_MAX_TOKENS=32000

# Budget for agent thinking/reasoning
export STRANDS_BUDGET_TOKENS=1024
```

## Custom Model Provider

You can configure strands to use a different model provider with specific settings by passing in the following arguments:
Expand All @@ -100,11 +148,7 @@ As an example, if you wanted to use the packaged Ollama provider with a specific
strands --model-provider ollama --model-config '{"model_id": <ID>}'
```

Strands is packaged with the following providers:
| Name | Config |
| ---- | ------ |
| `bedrock` | [reference](<LINK>) |
| `ollama` | [reference](<LINK>) |
Strands Agent Builder is packaged with `bedrock` and `ollama`.

If you have implemented a custom model provider ([instructions](<LINK>)) and would like to use it with strands, create a python module under the directory "$CWD/.models" and expose an `instance` function that returns an instance of your provider. As an example, assume you have:

Expand All @@ -122,7 +166,7 @@ You can then use it with strands by running:
$ strands --model-provider custom_model --model-config <JSON|FILE>
```

## Custom Systm Prompts
## Custom System Prompts

```bash
# Via environment variable
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ build-backend = "hatchling.build"

[project]
name = "strands-agents-builder"
version = "0.1.0"
description = "A minimal Strands Agents CLI"
version = "0.1.1"
description = "An example Strands agent demonstrating streaming, tool use, and interactivity from your terminal. This agent builder can help you to build your own agents and tools."
readme = "README.md"
requires-python = ">=3.10"
license = {text = "Apache-2.0"}
Expand Down
2 changes: 1 addition & 1 deletion src/strands_agents_builder/strands.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

# Custom tools, handlers, utils
from tools import (
strand,
store_in_kb,
strand,
welcome,
)

Expand Down
23 changes: 23 additions & 0 deletions src/strands_agents_builder/utils/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,30 @@

import importlib
import json
import os
import pathlib
from typing import Any

from botocore.config import Config
from strands.types.models import Model

# Default model configuration
DEFAULT_MODEL_CONFIG = {
"model_id": "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
"max_tokens": int(os.getenv("STRANDS_MAX_TOKENS", "64000")),
"boto_client_config": Config(
read_timeout=900,
connect_timeout=900,
retries=dict(max_attempts=3, mode="adaptive"),
),
"additional_request_fields": {
"thinking": {
"type": "enabled",
"budget_tokens": int(os.getenv("STRANDS_BUDGET_TOKENS", "2048")),
}
},
}


def load_path(name: str) -> pathlib.Path:
"""Locate the model provider module file path.
Expand Down Expand Up @@ -37,10 +56,14 @@ def load_config(config: str) -> dict[str, Any]:

Args:
config: A JSON string or path to a JSON file containing model configuration.
If empty string or '{}', the default config is used.

Returns:
The parsed configuration.
"""
if not config or config == "{}":
return DEFAULT_MODEL_CONFIG

if config.endswith(".json"):
with open(config) as fp:
return json.load(fp)
Expand Down
2 changes: 1 addition & 1 deletion tools/rich_interface.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import textwrap
from typing import Any

from strands.types.tools import ToolResult, ToolUse
from rich.console import Console
from rich.markdown import Markdown
from rich.panel import Panel
Expand All @@ -10,6 +9,7 @@
from rich.table import Table
from rich.text import Text
from rich.tree import Tree
from strands.types.tools import ToolResult, ToolUse

TOOL_SPEC = {
"name": "rich_interface",
Expand Down