Skip to main content

AI Agent Generation Library — Agents Building Agents

Project description

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

pip install logosai-forge

Quick Start

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 with a dedicated repair pipeline:

  1. Extract functions (AST-based, sync + async)
  2. Diagnose: LLM identifies broken function + root cause
  3. Repair: _repair_function() fixes in-place (preserves original signature, not regenerate)
  4. Replace in original code (other functions untouched)
  5. Validate: quick execution check + full test case comparison
  6. Auto-register fixed version to function registry

E2E accuracy: create_agent 98%, improve_agent 100% (3-run average).

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

Domain Expert Review (v0.2.12)

Pipeline Stage 6.5 — after code assembly, a dynamically created domain expert reviews the generated code:

  • Automatic domain detection (finance, healthcare, legal, etc.)
  • Confidence gate: low confidence → expert feedback injected into retry loop
  • Enable/disable via YAML config (domain_review.enabled)

Function Intelligence

  • Telemetry: per-function call count, success rate, error types (SQLite)
  • Version Management: auto-increment versions, quality comparison, rollback
  • Composition Learning: tracks which functions work well together (function pairs)
  • Pattern-Based Generation: successful functions as reference for new domains
  • Quality Gate: success rate < 0.70 → blocked from library admission
  • Function Graph: unified ontology connecting templates, pairs, metrics, and type compatibility

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
  • Context Manager for priority-based LLM token fitting

Setup

Google API Key (required)

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

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 ecosystem.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logosai_forge-0.2.14-py3-none-any.whl (1.7 MB view details)

Uploaded Python 3

File details

Details for the file logosai_forge-0.2.14-py3-none-any.whl.

File metadata

  • Download URL: logosai_forge-0.2.14-py3-none-any.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for logosai_forge-0.2.14-py3-none-any.whl
Algorithm Hash digest
SHA256 53d87a24617bfe95880a26bb81398a49716a420ea78fb590ff9649b6b7e479d1
MD5 803a49ea32067179b91fdada2af01475
BLAKE2b-256 0825348e7f71620e8a28ace0c60c4e92081ac2a3c82fa0281e45c61711c12e40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page