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
- Switching models
- Agent language strategies
- Capabilities
- Dependency injection
- Multi-agent
- Safety patterns
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bdee1419f8d0912a7f103ba011999d6857144715a4c3bc2ebbbb93d91a75cd1
|
|
| MD5 |
3d8951251ae2a3d95a5095b3c3e2f398
|
|
| BLAKE2b-256 |
647cac7e86c3683e7ac1aee0580cb994878ca0034cd2beb85f17b5931e480e84
|
Provenance
The following attestation bundles were made for agent_patterns_py-0.2.0.tar.gz:
Publisher:
publish.yml on moiz-09x/agent-patterns
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_patterns_py-0.2.0.tar.gz -
Subject digest:
4bdee1419f8d0912a7f103ba011999d6857144715a4c3bc2ebbbb93d91a75cd1 - Sigstore transparency entry: 1280104983
- Sigstore integration time:
-
Permalink:
moiz-09x/agent-patterns@57e5da3b38714fcbd1f18625510f41dca8405769 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/moiz-09x
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@57e5da3b38714fcbd1f18625510f41dca8405769 -
Trigger Event:
release
-
Statement type:
File details
Details for the file agent_patterns_py-0.2.0-py3-none-any.whl.
File metadata
- Download URL: agent_patterns_py-0.2.0-py3-none-any.whl
- Upload date:
- Size: 33.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87a1cbe1698bead2ee95896631483ebd779f32b28fa84d248891eeba3593ed62
|
|
| MD5 |
0498b5ee031fb5d2db1fa01329db9ef5
|
|
| BLAKE2b-256 |
e45cbba2f5837d98134f46f22fcf49d657d242e15e29da7f6aac3c2d58f3929c
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_patterns_py-0.2.0-py3-none-any.whl -
Subject digest:
87a1cbe1698bead2ee95896631483ebd779f32b28fa84d248891eeba3593ed62 - Sigstore transparency entry: 1280104991
- Sigstore integration time:
-
Permalink:
moiz-09x/agent-patterns@57e5da3b38714fcbd1f18625510f41dca8405769 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/moiz-09x
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@57e5da3b38714fcbd1f18625510f41dca8405769 -
Trigger Event:
release
-
Statement type: