Skip to main content

ACE-ADK (Agentic Context Engineering – Agent Development Kit)

A self-improving AI agent system that learns through iterative cycles of generation, reflection, and curation. Built with Google ADK and Gemini 2.5 Flash, ACE-ADK maintains a dynamic knowledge playbook that evolves with each interaction.

Python Google ADK License

Overview

ACE-ADK implements an "Agentic Context Engineering" approach where agents continuously improve their performance by:

  • Learning from mistakes: Identifying what works and what doesn't
  • Building knowledge: Maintaining a structured playbook of proven strategies
  • Adapting responses: Applying learned insights to future queries
  • Self-reflection: Analyzing output quality and updating strategies

Key Features

  • Self-Improving Agent System: Learns and evolves with each interaction
  • Dynamic Knowledge Playbook: Automatically builds and maintains strategy repository
  • Transparent Reasoning: Shows step-by-step thought process with bullet references
  • Quality Tracking: Tags strategies as helpful, harmful, or neutral
  • Error Handling: Robust validation and graceful failure recovery
  • Modern UI: Clean, professional web interface with real-time updates
  • Prominent Answer Display: Clear formatting of final answers and cycle summaries

Quick Start

Prerequisites

  • Python 3.11 or higher
  • Google API Key (for Gemini models)
  • pip or uv package manager

Installation

  1. Clone the repository
git clone https://github.com/jahidulzaid/agentic-context-engineering.git
cd agentic-context-engineering
  1. Install dependencies

Using pip:

pip install google-adk fastapi uvicorn

Using uv:

uv sync
  1. Configure environment
cp .env.example .env
# Edit .env and add your GOOGLE_API_KEY
  1. Run the application
python main.py
  1. Access the interface
  • Web Interface: http://localhost:8080
  • API Documentation: http://localhost:8080/docs
  • Interactive API: http://localhost:8080/redoc

Architecture

Agent Workflow

StateInitializer → Generator → FinalAnswerDisplay → Reflector → Curator → CycleSummary

Core Components

1. Generator Agent

  • Generates answers using the current playbook
  • Shows step-by-step reasoning
  • References specific playbook strategies
  • Displays final answer prominently

2. Reflector Agent

  • Analyzes generator output quality
  • Identifies errors and patterns
  • Tags playbook bullets as helpful/harmful/neutral
  • Provides key insights for improvement

3. Curator Agent

  • Updates the playbook based on reflections
  • Adds new strategies
  • Modifies existing bullets
  • Removes outdated information
  • Limited to 3 operations per cycle for stability

4. Cycle Summary

  • Displays complete cycle statistics
  • Shows playbook evolution metrics
  • Provides answer recap
  • Tracks tag distributions

Data Flow

graph TD
    A[User Query] --> B[StateInitializer]
    B --> C[Generator]
    C --> D[Final Answer Display]
    D --> E[Reflector]
    E --> F[Tag Bullets]
    F --> G[Curator]
    G --> H[Playbook Updater]
    H --> I[Cycle Summary]
    I --> J[Display Results]
    
    K[Playbook State] -.-> C
    E -.-> K
    H -.-> K

Project Structure

agentic-context-engineering/
├── main.py                          # Application entry point
├── config.py                        # Configuration settings
├── pyproject.toml                   # Dependencies
├── .env.example                     # Environment template
├── agents/
│   └── ace_agent/
│       ├── __init__.py
│       ├── agent.py                 # Main agent orchestration
│       ├── schemas/
│       │   ├── __init__.py
│       │   ├── playbook.py          # Playbook data structures
│       │   └── delta.py             # Change operation schemas
│       └── sub_agents/
│           ├── __init__.py
│           ├── generator.py         # Answer generation
│           ├── reflector.py         # Quality analysis
│           └── curator.py           # Playbook updates
└── .gitignore                       # Git ignore patterns

Configuration

Environment Variables (.env)

# Required: Google AI API Key
GOOGLE_API_KEY=your-google-api-key-here

# Optional: Vertex AI Configuration
GOOGLE_GENAI_USE_VERTEXAI=False
GOOGLE_CLOUD_PROJECT=your-project-id
GOOGLE_CLOUD_REGION=us-central1

Application Settings (config.py)

class Config(BaseModel):
    # Model configuration
    generator_model: str = "gemini-2.5-flash"
    reflector_model: str = "gemini-2.5-flash"
    curator_model: str = "gemini-2.5-flash"
    
    # Server configuration
    server_host: str = "0.0.0.0"
    server_port: int = 8080

Usage Examples

Basic Interaction

  1. Open http://localhost:8080
  2. Enter your question in the chat interface
  3. Watch the agent process through all stages
  4. See the final answer displayed prominently
  5. Review the cycle summary for insights

Example Query Flow

User: "What is 2 + 2?"

Generator Output:

╔══════════════════════════════════════════════════════════════╗
║                      FINAL ANSWER                            ║
╚══════════════════════════════════════════════════════════════╝

2 + 2 equals 4.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Reasoning Steps: 2
Playbook Bullets Used: 0

Cycle Summary:


PLAYBOOK STATUS
Sections: 1
Total Bullets: 2
Helpful Tags: 1
Harmful Tags: 0
Neutral Tags: 1

Data Models

Playbook Structure

class Bullet:
    id: str                  # Unique identifier
    section: str             # Category/section
    content: str             # Strategy description
    helpful: int             # Helpful tag count
    harmful: int             # Harmful tag count
    neutral: int             # Neutral tag count
    created_at: str          # ISO timestamp
    updated_at: str          # ISO timestamp

class Playbook:
    bullets: Dict[str, Bullet]
    sections: Dict[str, List[str]]
    next_id: int

Delta Operations

class DeltaOperation:
    type: Literal["ADD", "UPDATE", "REMOVE"]
    section: str
    content: Optional[str]
    bullet_id: Optional[str]

class DeltaBatch:
    reasoning: str
    operations: List[DeltaOperation]  # Max 3 per cycle

Advanced Features

Output Limiting

  • Generator: Limited reasoning depth for efficiency
  • Curator: Max 3 operations per cycle to prevent overflow
  • Prompts: Strict character limits (80-100 chars) for stability

Error Handling

  • Graceful JSON parsing failures
  • Malformed curator output recovery
  • Operation count enforcement
  • Clear error messages to users

Playbook Management

  • Automatic ID generation
  • Section organization
  • Tag statistics tracking
  • Serialization/deserialization
  • Prompt-ready formatting

Troubleshooting

Common Issues

1. Import Errors

pip install --upgrade google-adk fastapi uvicorn

2. API Key Issues

  • Verify .env file exists
  • Check GOOGLE_API_KEY is set correctly
  • Ensure no extra quotes or spaces

3. Port Already in Use

# Change port in config.py
server_port: int = 8081

4. JSON Validation Errors

  • These are handled gracefully
  • Check logs for LLM output issues
  • May need to adjust prompt limits

Development

Running in Development Mode

# Enable hot reload
uvicorn main:app --reload --port 8080

Running Tests

pytest tests/

Code Style

ruff check .
ruff format .

Performance Optimization

  • Token Limits: Strict output controls prevent runaway generation
  • Caching: Playbook state persists across sessions
  • Batching: Operations grouped for efficiency
  • Model Selection: Uses efficient Gemini 2.5 Flash by default

Roadmap

  • Persistent playbook storage (JSON/SQLite)
  • Multi-user session support
  • Playbook versioning and rollback
  • Advanced analytics dashboard
  • Custom model provider support
  • Evaluation metrics tracking
  • Export/import playbook functionality

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built with Google ADK
  • Powered by Gemini 2.5 Flash
  • Inspired by Agentic Context Engineering research

Support


JahidulZaid

Metadata

Release files for ace-adk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ace-adk 0.1.0
File Size Uploaded Provenance Actions
ace_adk-0.1.0.tar.gz 102.4 kB Without provenance Details for ace_adk-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ace-adk 0.1.0
File Interpreter ABI Platform Actions
ace_adk-0.1.0-py3-none-any.whl Python 3 none any Details for ace_adk-0.1.0-py3-none-any.whl

Total release size: 119.6 kB

Release files / ace_adk-0.1.0.tar.gz

Download URL ace_adk-0.1.0.tar.gz
Size 102.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b4edbf1f7fb0b52d6265b9bf6e9e8f448134380e1961005cde434e0270a34320
BLAKE2b-256 checksum
How to use checksums
ef2f049c5c7578442be98e9890c9ac23cdd2049e174f3f54bdc7226fbcbef43b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / ace_adk-0.1.0-py3-none-any.whl

Download URL ace_adk-0.1.0-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
858f0891223703d8e9e1c28b8bbe3e4ab6ccda6d80caedeb7e84e93f048ea356
BLAKE2b-256 checksum
How to use checksums
836949f276fb54b7e517a098f38dcfc6113673bab3837de8476b8e5e8463dddd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for ace-adk 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page