Skip to main content

Create OpenAI API Compatible, Task driven agents.

Project description

amok

Currently WIP.

Python framework to create "Agents" of certain types.

The name is a play on the image of LLMs as little minions running amok.

Details.

There are currently the below types of agents:

  1. Action Agent - An agent that can perform actions based on given commands and input.
  2. Option Agent - An agent that can selects options based on given commands and input.

You can create your own agent type by sub-classing the BaseAgent.

API Modes

amok now supports both OpenAI-compatible request styles:

  1. chat.completions (default)
  2. responses

Set api_mode in your settings/config:

api_mode = "responses"

Tool Calling

You can provide tool schemas and tool behavior controls in agent settings:

api_mode = "responses"
tool_choice = "auto"
parallel_tool_calls = true

[[tools]]
type = "function"
name = "lookup_weather"
description = "Get weather by city"
parameters = { type = "object", properties = { city = { type = "string" } }, required = ["city"] }

Tool Schema By api_mode

Function tools use different native wire formats per API mode:

  • chat.completions expects a nested function object.
  • responses expects top-level name/description/parameters.

amok accepts either shape and normalizes to the correct wire format for the selected api_mode.

chat.completions native shape:

[[tools]]
type = "function"
function = { name = "lookup_weather", description = "Get weather by city", parameters = { type = "object", properties = { city = { type = "string" } }, required = ["city"] } }

responses native shape:

[[tools]]
type = "function"
name = "lookup_weather"
description = "Get weather by city"
parameters = { type = "object", properties = { city = { type = "string" } }, required = ["city"] }

Tool Control Fields

  • tool_choice is forwarded as-is to the underlying API.
  • parallel_tool_calls is forwarded as-is when not None.
  • If tools is empty, tool calling is disabled.

Returned Tool Calls

Tool calls are returned in AgentResponse.tool_calls as normalized dictionaries.

Normalized keys you may receive:

  • id
  • type
  • name
  • arguments
  • call_id (responses API)
  • status (responses API)

Expected Flow

  1. Call agent.run(body) with tools configured.
  2. If response.tool_calls is non-empty, execute those tools in your app.
  3. Send tool outputs back to your model endpoint (for responses-style tool loop).
  4. Use the follow-up model output as the final user-visible answer.

Create Agent from a Config File.

You can easily spin up agents from a config file.

The currently supported config file formats are yaml, json, and toml.

The fields in the config file are based on the Agent Options class for your agent type.

Example

config.toml

base_url = "http://localhost:1234/v1"
model = "google/gemma-3-12b"
temperature = 0.1
max_tokens = 4000
description = "Parse messages to extract the username from them, if present."
commands = [
    "You will parse the body of the message to extract the username.",
    "ONLY reply with the username, nothing else.",
    "No other information is needed. No formatting, no explanations, nothing else!",
    "You need to be > 99% sure about your answer.",
    "Reply with 'NO_RESULT' in case no username is given or you arent sure.",
]

Python Code

from amok import ActionAgent
uname_agent = ActionAgent.from_cfg("./config.toml")

Development

  1. Create a virtual environment (recommended):
    python3.12 -m venv .venv
    source .venv/bin/activate
    
  2. Install dependencies:
    pip install -e .
    

Requirements

  • Python 3.12 or newer is required.

Running Tests

To Run tests, install pytest and pytest-cov first.

# With Pytest configured in the pyproject.toml, you can run:
pytest .

# Optional
pytest --cov=amok --cov-report=term-missing tests

Running Linters

black .

ruff check

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

amok-0.2.1.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

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

amok-0.2.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file amok-0.2.1.tar.gz.

File metadata

  • Download URL: amok-0.2.1.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for amok-0.2.1.tar.gz
Algorithm Hash digest
SHA256 cdcd6861fc74418f299044d4117347e44778d8fea5b842e4bfcd8df2c92f35e1
MD5 9d7dd6b4228721cbf00325dff1b78be5
BLAKE2b-256 480a686379abc8f19a1a68d5a23153827eb646178bfe7f556b9dc282c24d1976

See more details on using hashes here.

Provenance

The following attestation bundles were made for amok-0.2.1.tar.gz:

Publisher: publish.yml on rapidclock/amok

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

File details

Details for the file amok-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: amok-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for amok-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 64bfc307d0e12ca8a4496e2f41bfccefeafeb26c4d102e06fb73a70ae32e62ab
MD5 ecad5082c4c9241410ecdd7304f0ec62
BLAKE2b-256 750e1ce590061a3b5f814d804b0342615cf843f39915124b1d056d99ce40ec70

See more details on using hashes here.

Provenance

The following attestation bundles were made for amok-0.2.1-py3-none-any.whl:

Publisher: publish.yml on rapidclock/amok

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