Metadata-Version: 2.4
Name: logosai-forge
Version: 0.2.12
Summary: AI Agent Generation Library — Agents Building Agents
Author: LogosAI Team
License: Proprietary (pre-publication)
Project-URL: Homepage, https://github.com/maior/logosai-forge
Keywords: ai,agent,code-generation,agentic,logosai
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: google-generativeai>=0.8.0
Requires-Dist: loguru>=0.7.0
Requires-Dist: aiohttp>=3.9.0
Provides-Extra: logosai
Requires-Dist: logosai>=0.7.0; extra == "logosai"

# logosai-forge

**FORGE: An AI Agent Code Builder** — agents that create, fix, and evolve other agents.

15 agentic AI agents collaborate to autonomously generate, improve, enhance, and self-evolve agent code.

## Installation

```bash
pip install logosai-forge
```

## Quick Start

```python
import asyncio
from logosai_forge import ForgeClient

async def main():
    forge = ForgeClient()

    # Generate a new agent
    result = await forge.create_agent(
        "Calculate BMI from weight and height",
        test_cases=[{
            "input": {"weight_kg": 70, "height_m": 1.75},
            "expected": {"bmi": 22.9, "category": "normal"}
        }]
    )
    print(result.code)

    # Fix a broken agent
    result = await forge.improve_agent(agent_code, {
        "error_type": "logic_error",
        "error_message": "Condition is inverted — score>700 should approve",
        "test_input": {"credit_score": 750},
        "expected_output": {"decision": "approved"},
        "actual_output": {"decision": "denied"},
    })
    print(result.changes)

    # Add missing functions
    result = await forge.enhance_agent(
        existing_code,
        "Add multiply and divide methods"
    )
    print(result.added_functions)  # ['_multiply', '_divide']

asyncio.run(main())
```

## Features

| Method | Purpose | Example |
|--------|---------|---------|
| `create_agent()` | Generate new agent from query | "Calculate shipping cost" |
| `improve_agent()` | Fix bugs from failure feedback | Inverted condition, wrong formula |
| `enhance_agent()` | Add missing logic/functions | "Add caching", "Add error handling" |

### ACP-Compliant Code Generation

Generated agents automatically follow the ACP Agent Interface Specification:
- `process(query, context)` with query str/dict normalization
- `AgentResponse` with `content["answer"]` (string)
- File creation agents return `file_path` + `file_name`
- Search agents return `files` list with absolute paths
- Uses python-pptx, openpyxl, subprocess (mdfind, pdfgrep) when appropriate

### Function Slice Architecture

Agents are built by **combining reusable function slices** (174 slices), not writing entire code from scratch.

`improve_agent()` works at function granularity:
1. Extract functions (AST-based, handles any code structure)
2. StrategyAgent checks 174 slices — reuse if matched, LLM if not
3. Regenerate only the broken function
4. Replace in original code (other functions untouched)
5. ErrorHealerAgent heals syntax (3 experts)
6. Validate through multiple execution paths (best-match)
7. New LLM-generated functions auto-registered to slice library (Self-Growing)

Supports large agents (15KB+) with size-based strategy and dynamic timeouts.

### Persistent Memory & Observability

- Learned patterns survive server restarts (SQLite-backed)
- All reasoning traces persisted and queryable (agent, time, success)
- Configuration via YAML (`config/agentic_pipeline.yaml`) + env var overrides
- Tool Registry for LLM/library dependency injection

## Setup

### Google API Key (required)

FORGE uses Gemini LLM for code generation. A Google API Key is required.

```bash
export GOOGLE_API_KEY="your-google-api-key-here"
```

Get your API key: https://aistudio.google.com/apikey

## Requirements

- Python 3.10+
- Google API Key (`GOOGLE_API_KEY` environment variable)
- LogosAI framework (optional, for agent execution)

## License

Source code will be open-sourced after paper publication.
Part of the [LogosAI](https://github.com/maior) ecosystem.
