Skip to content

jaeyow/ai-python-coding-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Python Coding Agent

An intelligent Python code generation system featuring two distinct implementation approaches, each demonstrating different architectural patterns for AI-driven development workflows.

🎯 Project Overview

This project showcases two complementary approaches to AI-powered code generation:

πŸ”„ 01_ai_workflow - Structured Workflow Approach

A graph-based workflow system built with Apache Burr that follows a predefined state machine pattern. The workflow is explicitly structured with clear transitions and deterministic paths through code generation, validation, and improvement cycles.

Key Characteristics:

  • Predefined workflow graph with explicit state transitions
  • Deterministic flow through generation β†’ validation β†’ improvement
  • Structured retry logic with configurable thresholds
  • Comprehensive quality gates enforced at each step
  • Workflow visualisation and state tracking

πŸ€– 02_ai_agent - AI-Driven Agent Approach

A model-driven agent system built with Strands SDK where the AI foundation model dynamically determines the workflow flow. The agent autonomously decides when to generate code, validate results, and iterate based on contextual understanding.

Key Characteristics:

  • AI-driven decision making with dynamic workflow paths
  • Contextual flow control determined by the foundation model
  • Adaptive iteration strategies based on real-time assessment
  • Intelligent tool orchestration guided by AI reasoning
  • Emergent workflow patterns that adapt to task complexity

πŸš€ Quick Start

Prerequisites

# System Requirements
# - Python >= 3.12
# - AWS Account with Bedrock access
# - Claude 3.5 Sonnet model enabled

# Project Setup
git clone <repository-url>
cd ai-python-coding-agent

Environment Setup

# Initialize project with uv
uv init

# Configure AWS credentials
aws configure sso
aws sso login

# Install dependencies
uv sync

# Activate virtual environment
source .venv/bin/activate

Choose Your Implementation

πŸ”„ Structured Workflow (Apache Burr)

cd 01_ai_workflow

# Run predefined tasks
uv run 01_ai_workflow.py simple    # Basic factorial function
uv run 01_ai_workflow.py moderate  # CSV analysis with statistics
uv run 01_ai_workflow.py complex   # Multi-threaded web scraper
uv run 01_ai_workflow.py all       # All tasks sequentially

# Test the workflow framework
uv run 00_test.py

πŸ€– AI-Driven Agent (Strands SDK)

cd 02_ai_agent

# Run interactive agent sessions
uv run ai_agent_strands.py

# Test with predefined scenarios
uv run 02_ai_agent_test.py

πŸ“‹ Implementation Comparison

Feature 01_ai_workflow (Burr) 02_ai_agent (Strands)
Architecture Graph-based workflow Agent-driven system
Flow Control Predefined transitions AI-determined paths
Decision Making Rule-based logic Model-driven reasoning
Retry Strategy Threshold-based Contextual assessment
Workflow Visibility Visual state machine Agent reasoning logs
Predictability Deterministic paths Adaptive responses
Customisation Modify graph structure Configure agent behaviour
Best For Structured processes Dynamic problem solving

πŸ› οΈ Technology Stack

Core Dependencies

  • Python 3.12+ - Modern Python with latest features
  • AWS Bedrock - Claude 3.5 Sonnet foundation model
  • Instructor - Structured output from language models
  • Pydantic - Data validation and type safety

Framework-Specific

  • Apache Burr (01_ai_workflow) - Workflow orchestration and state management
  • Strands SDK (02_ai_agent) - Agent framework and tool orchestration

Development Tools

  • uv - Fast Python package manager
  • pytest - Testing framework
  • boto3 - AWS SDK for Python

πŸ“š Documentation

Each implementation includes comprehensive documentation:

Detailed guide covering:

  • Apache Burr workflow architecture
  • State machine design patterns
  • Quality threshold configuration
  • Workflow visualisation
  • Performance optimisation
  • Custom task creation

Complete reference including:

  • Strands SDK agent architecture
  • AI-driven tool orchestration
  • Iterative improvement patterns
  • Session management
  • Agent reasoning and decision making
  • Advanced configuration options

βš™οΈ Configuration

AWS Setup

# Configure AWS SSO (recommended)
aws configure sso --profile your-profile-name
aws sso login --profile your-profile-name

# Set environment variables
export AWS_PROFILE=your-profile-name
export AWS_REGION=us-east-1  # Your preferred region

Environment Variables

Create a .env file in the project root:

# AWS Configuration
AWS_REGION=us-east-1
AWS_PROFILE=your-profile-name

# Model Configuration
MODEL=anthropic.claude-3-5-sonnet-20241022-v2:0

# Optional: Workflow Configuration
MAX_RETRIES=5
WARNING_THRESHOLD=5
ENABLE_CODE_EXECUTION=true

🎯 Use Cases

When to Use 01_ai_workflow (Structured Workflow)

  • Standardised processes requiring consistent quality gates
  • Regulatory compliance with auditable workflow steps
  • Team environments where workflow transparency is crucial
  • Production systems needing predictable execution paths
  • Performance-critical applications requiring optimised flows

When to Use 02_ai_agent (AI-Driven Agent)

  • Research and exploration with unknown problem complexity
  • Dynamic requirements that change during execution
  • Creative problem solving requiring adaptive strategies
  • Prototype development with evolving specifications
  • Complex reasoning tasks benefiting from AI autonomy

πŸ“Š Performance Benchmarks

Workflow Implementation (01_ai_workflow)

Task Type Avg Duration Token Usage Success Rate
Simple 30s 1,500 95%
Moderate 90s 4,500 85%
Complex 300s 12,000 75%

Agent Implementation (02_ai_agent)

Task Type Avg Duration Token Usage Success Rate
Simple 45s 2,000 90%
Moderate 120s 6,000 80%
Complex 400s 15,000 70%

Note: Agent implementation typically uses more tokens due to reasoning overhead but provides more adaptive solutions.

πŸ” Troubleshooting

Common Setup Issues

  1. AWS Authentication

    # Verify AWS configuration
    aws sts get-caller-identity
    aws bedrock list-foundation-models --region us-east-1
  2. Python Environment

    # Check Python version
    python --version  # Should be 3.12+
    
    # Verify dependencies
    uv tree
  3. Model Access

    # Test Bedrock access
    aws bedrock get-foundation-model \
      --model-id anthropic.claude-3-5-sonnet-20241022-v2:0 \
      --region us-east-1

Getting Help

Development Guidelines

  • Workflow contributions: Focus on graph structure, state management, and deterministic flows
  • Agent contributions: Enhance reasoning capabilities, tool orchestration, and adaptive behaviours
  • Shared components: Improve AWS integration, model interactions, and quality validation

Choose your approach: Structured workflows or AI-driven agents - both paths lead to intelligent code generation! πŸš€

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages