Skip to content

About

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

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

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-sonnet-4-5-20250929-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 eu.anthropic.claude-sonnet-4-5-20250929-v1:0 by default, invoked via a cross-region inference profile.

Newer Claude models on Bedrock require invocation via an inference profile ID (prefixed eu./us./global.) rather than the bare model ID — a bare model ID fails with "on-demand throughput isn't supported." Model availability can vary by AWS account, so if you hit a ValidationException on invoke, check which models and inference profiles your account actually has access to:

aws bedrock list-foundation-models --region "$AWS_REGION" --by-provider anthropic
aws bedrock list-inference-profiles --region "$AWS_REGION"

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

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages