Skip to main content

A lightweight agent framework for Amazon Bedrock

Project description

MinimalAgent

A lightweight agent framework for building agentic applications with Amazon Bedrock.

Installation

pip install minimalagent

Quick Start

from minimalagent import Agent, tool

@tool
def get_weather(location: str):
    """Get weather for a location.
    
    Args:
        location: City name to get weather for
        
    Returns:
        Weather data dictionary
    """
    # Your implementation here
    return {"temperature": 22, "condition": "sunny"}

# Create agent
agent = Agent(tools=[get_weather])

# Run a query
response, reasoning = agent.run("What's the weather in San Francisco?")
print(response)

Key Features

  • Simple API: Intuitive design with minimal boilerplate
  • Tool-first approach: Easy tool creation with docstring parsing
  • Built-in session memory: Persistent conversations via DynamoDB
  • Step-by-step reasoning: Visibility into the agent's thought process

Core Concepts

Tools

Tools give your agent capabilities. Simply decorate functions with @tool:

@tool
def search_database(query: str, limit: int = 10) -> list:
    """Search the database for records matching the query."""
    # Your implementation here
    return [{"id": 1, "name": query}]

Session Management

Enable persistent conversations across multiple interactions:

# Create an agent with session support
agent = Agent(use_session_memory=True)

# Use a consistent session ID for the same conversation
response1 = agent.run("Find information about electric cars", session_id="user123")
response2 = agent.run("What about hybrid models?", session_id="user123")  # Remembers context

Reasoning Display

Control the visibility of the agent's thinking process:

# Colorized reasoning in the terminal is enabled by default
agent = Agent(tools=[get_weather])  # show_reasoning=True is the default

# Explicitly enable reasoning display
agent_with_display = Agent(
    tools=[get_weather],
    show_reasoning=True
)

# Hide reasoning output for production use
agent_without_display = Agent(
    tools=[get_weather],
    show_reasoning=False, 
    log_level="WARNING"  # Only log warnings and errors
)

Reasoning Process

Access the agent's step-by-step thinking programmatically:

response, reasoning = agent.run("Calculate 25 * 4 + 10")

# Access reasoning data
print(f"Query: {reasoning.query}")
print(f"Steps: {reasoning.total_steps}")
for step in reasoning.steps:
    print(f"Step {step.step_number} thinking: {step.thinking}")

Documentation

For more detailed documentation, visit https://niklas-palm.github.io/minimalagent/

AWS Setup

MinimalAgent requires AWS credentials for accessing Amazon Bedrock and DynamoDB.

Option 1: AWS CLI Configuration (Recommended)

  1. Install and configure the AWS CLI:
    aws configure
    

Option 2: Environment Variables

export AWS_ACCESS_KEY_ID=your_access_key_id
export AWS_SECRET_ACCESS_KEY=your_secret_access_key
export AWS_REGION=us-west-2

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minimalagent-0.2.3.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minimalagent-0.2.3-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file minimalagent-0.2.3.tar.gz.

File metadata

  • Download URL: minimalagent-0.2.3.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for minimalagent-0.2.3.tar.gz
Algorithm Hash digest
SHA256 09ae9124a1e08650b3de5ef664ab037fe90f2def20ff4a33e926ead8b2a2071c
MD5 e95a91b2c8eae0598faa20ae742daf3c
BLAKE2b-256 22e4b710a539a06846ee7cf0a3daaf6da82d63b00c5a3bba69dd254924cfdd51

See more details on using hashes here.

File details

Details for the file minimalagent-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: minimalagent-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for minimalagent-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2f1f3e956ad05bab4efa26bed35396101e64fa2b13171b275a2244b7bb040501
MD5 b279bae96110a9bfbb8282a996d207b2
BLAKE2b-256 dec3b7f0b331ad963a223fda5adae85fa8c444e08b25c2b2905cf9f9dd91fd21

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page