Skip to content

eficode/diy-bedrock-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

AWS Bedrock Code-Editing Agent

A simple code-editing agent built with AWS Bedrock and Anthropic Claude, following the pattern from ampcode.com/how-to-build-an-agent.

Architecture

The agent implements a simple loop:

  1. User sends a message
  2. Agent forwards to Claude via AWS Bedrock
  3. Claude decides if it needs tools
  4. Agent executes requested tools locally
  5. Tool results are sent back to Claude
  6. Repeat until Claude provides final answer

Available Tools

  • read_file: Read contents of a file
  • list_files: List files in a directory
  • edit_file: Edit a file by replacing text

Setup

  1. Install dependencies:

    pip install -r requirements.txt
  2. Set AWS credentials:

    export AWS_BEARER_TOKEN_BEDROCK=your-token
    export AWS_REGION=us-east-1  # optional, defaults to us-east-1
  3. Run the agent:

    # Use default model (Claude Sonnet 4.5)
    python bedrock_agent.py
    
    # Or specify a model ID
    python bedrock_agent.py anthropic.claude-haiku-4-5-20251001-v1:0
    
    # Or set via environment variable
    export BEDROCK_MODEL_ID=anthropic.claude-opus-4-5-20251101-v1:0
    python bedrock_agent.py

Example Usage

Sinä: What files are in the current directory?

[TYÖKALU] Käytetään: list_files
       Parametrit: {
  "path": "."
}

Agentti: The current directory contains:
[FILE] bedrock_agent.py
[FILE] example.py
[FILE] requirements.txt
[FILE] README_AGENT.md
Sinä: What's in example.py?

[TYÖKALU] Käytetään: read_file
       Parametrit: {
  "path": "example.py"
}

Agentti: The example.py file contains a simple Python script with...
Sinä: Change the hello_world function to print "Hello, Agent!" instead

[TYÖKALU] Käytetään: read_file
       Parametrit: {
  "path": "example.py"
}
[TYÖKALU] Käytetään: edit_file
       Parametrit: {
  "path": "example.py",
  "old_str": "print(\"Hello, World!\")",
  "new_str": "print(\"Hello, Agent!\")"
}

Agentti: I've successfully updated the hello_world function...

Model

Uses anthropic.claude-sonnet-4-5-20250929-v1:0 (Claude Sonnet 4.5) by default. Available Anthropic models on Bedrock:

  • anthropic.claude-opus-4-5-20251101-v1:0 (Claude Opus 4.5 - most capable)
  • anthropic.claude-sonnet-4-5-20250929-v1:0 (Claude Sonnet 4.5 - balanced)
  • anthropic.claude-haiku-4-5-20251001-v1:0 (Claude Haiku 4.5 - fastest)
  • anthropic.claude-sonnet-4-20250514-v1:0 (Claude Sonnet 4)
  • anthropic.claude-3-7-sonnet-20250219-v1:0 (Claude 3.7 Sonnet)

Key Insight

Claude autonomously decides when tools are helpful. You don't need to explicitly tell it to use tools - it understands tool utility through its training.

About

A minimal GenAI coding agent in Python. Demonstrates the inner loop concept and tool use.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages