Skip to main content

Production-ready boilerplate for common agentic AI patterns in Python

Project description

agent-patterns

A Python framework for building production-ready AI agents using the GAME pattern (Goals, Actions, Memory, Environment).


Install

pip install agent-patterns-py

Or clone to run the examples:

git clone https://github.com/abdul-moiz-cowlar/agent-patterns.git
cd agent-patterns
uv sync
cp .env.example .env  # add your API keys

Quick start

import os
from agent_patterns import (
    Agent, Goal,
    PythonEnvironment,
    AgentFunctionCallingActionLanguage,
    PythonActionRegistry,
    register_tool,
    make_generate_response,
)

@register_tool(tags=["files"])
def list_files() -> list:
    """List files in the current directory."""
    return os.listdir(".")

@register_tool(tags=["files"])
def read_file(name: str) -> str:
    """Read a file and return its contents."""
    with open(name) as f:
        return f.read()

@register_tool(tags=["system"], terminal=True)
def terminate(message: str) -> str:
    """End the session with a final message."""
    return message

agent = Agent(
    goals=[
        Goal(1, "Explore", "List and read files in the current directory."),
        Goal(2, "Terminate", "Call terminate with a summary when done."),
    ],
    agent_language=AgentFunctionCallingActionLanguage(),
    action_registry=PythonActionRegistry(tags=["files", "system"]),
    generate_response=make_generate_response("openai/gpt-4o"),
    environment=PythonEnvironment(),
)

memory = agent.run("What Python files are here and what do they do?")

Docs


License

MIT

Project details


Download files

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

Source Distribution

agent_patterns_py-0.2.0.tar.gz (193.5 kB view details)

Uploaded Source

Built Distribution

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

agent_patterns_py-0.2.0-py3-none-any.whl (33.6 kB view details)

Uploaded Python 3

File details

Details for the file agent_patterns_py-0.2.0.tar.gz.

File metadata

  • Download URL: agent_patterns_py-0.2.0.tar.gz
  • Upload date:
  • Size: 193.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agent_patterns_py-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4bdee1419f8d0912a7f103ba011999d6857144715a4c3bc2ebbbb93d91a75cd1
MD5 3d8951251ae2a3d95a5095b3c3e2f398
BLAKE2b-256 647cac7e86c3683e7ac1aee0580cb994878ca0034cd2beb85f17b5931e480e84

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_patterns_py-0.2.0.tar.gz:

Publisher: publish.yml on moiz-09x/agent-patterns

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agent_patterns_py-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_patterns_py-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87a1cbe1698bead2ee95896631483ebd779f32b28fa84d248891eeba3593ed62
MD5 0498b5ee031fb5d2db1fa01329db9ef5
BLAKE2b-256 e45cbba2f5837d98134f46f22fcf49d657d242e15e29da7f6aac3c2d58f3929c

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_patterns_py-0.2.0-py3-none-any.whl:

Publisher: publish.yml on moiz-09x/agent-patterns

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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