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.1.1.tar.gz (191.2 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.1.1-py3-none-any.whl (32.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agent_patterns_py-0.1.1.tar.gz
  • Upload date:
  • Size: 191.2 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.1.1.tar.gz
Algorithm Hash digest
SHA256 28780adb2f4d297f326a00488f0ba961b18310d9aa7aa42f1972a57cdf1baa97
MD5 e8d0c7e7b7522ba15f6915660733173a
BLAKE2b-256 aeaeb8135f01d14ead49a0235daee4e826569b0c57a6c6cbaa7750d0d0bd2b92

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_patterns_py-0.1.1.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.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_patterns_py-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b7f33765303cc433b9b51463cacbf6b510ce3e8ce816b847670cdaeddb9e0156
MD5 bb155b5089437eceb923183a6d92744c
BLAKE2b-256 592aefec3efe07a487da232dacab6f5ab43de1739509a8ca9ee0f22c84a603b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_patterns_py-0.1.1-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