Skip to main content

A lightweight ReAct agent framework with tool calling, streaming chunks, and pluggable providers.

Project description

CrowAct

crowact is a lightweight ReAct agent framework with tool calling, streaming chunks, and pluggable providers.

Distribution name: crowact
Python import name: CrowAct

Requirements

  • Python 3.10+
  • requests
  • python-dotenv

Install

pip install crowact

For local development in this repository:

pip install -e .

Quick Start

from CrowAct import Agent, LLMProvider, load_prompt_from
from CrowAct.agent.tools import get_tools

TOOLS = get_tools("test_folder")


def main() -> None:
    provider = LLMProvider.from_anthropic_env("byte2.env")
    agent = Agent(
        provider=provider,
        model="deepseek-v3.2",
        system_prompt=load_prompt_from(["system.md", "rules.txt"]),
        tools=TOOLS,
    )

    question = (
        "Please use tools to calculate this step by step: "
        "first compute 1+19, then take the square root of the result, "
        "and finally add 100."
    )

    for chunk in agent.run(question, stream=True):
        print(chunk)

    print(agent.last_answer)


if __name__ == "__main__":
    main()

load_prompt_from(...) supports either a single file path or multiple file paths.

system_prompt = load_prompt_from("system.md")

system_prompt = load_prompt_from(["system.md", "rules.txt"])

Generated format:

system.md
----
file content

rules.txt
----
file content

Tool Files

get_tools(folder) loads every *.py file in the target folder and registers functions marked with the @tool(...) decorator.

Example folder:

test_folder/
  tool1.py
  tool2.py

Example tool:

from CrowAct.agent.tools import tool


@tool(
    description="Compute the square root of a number.",
    param_descriptions={"number": "The number to take the square root of"},
)
def sqrt_tool(number: float) -> float:
    return number ** 0.5

Agent Output

Agent.run(...) always returns an iterator of chunks.

Chunk types:

  • {"type": "text", "text": "..."}
  • {"type": "tool_use", "id": "...", "name": "...", "input": {...}}
  • {"type": "tool_result", "tool_use_id": "...", "content": "..."}

Behavior:

  • stream=True: text is yielded incrementally as streaming chunks.
  • stream=False: text is yielded as complete blocks, but the API remains iterator-based.

The final plain-text answer is stored in agent.last_answer.

History

You can pass prior conversation context through history.

agent = Agent(
    provider=provider,
    model="deepseek-v3.2",
    system_prompt="You are helpful.",
    history=[
        {"role": "user", "content": [{"type": "text", "text": "Previous question"}]},
        {"role": "assistant", "content": [{"type": "text", "text": "Previous answer"}]},
    ],
)

history is prepended to the current run, but it is not mutated after execution.

Provider Setup

Anthropic-style

provider = LLMProvider.from_anthropic_env(".env")

Expected environment variables:

ANTHROPIC_BASE_URL=https://your-endpoint
ANTHROPIC_API_KEY=your-api-key

Endpoint pattern:

  • .../v1/messages

OpenAI-style

provider = LLMProvider.from_openai_env(".env")

Expected environment variables:

OPENAI_BASE_URL=https://your-endpoint
OPENAI_API_KEY=your-api-key

Endpoint pattern:

  • .../chat/completions

Current Limitation

LLMProvider supports both anthropic and openai endpoint styles, but the request body and tool-calling flow are currently implemented around the Anthropic-style message format. If you use an OpenAI-compatible endpoint, confirm that it accepts the same request shape before relying on it.

Local Example

This repository includes:

License

Add a license before publishing to PyPI.

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

crowact-0.1.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

crowact-0.1.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: crowact-0.1.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for crowact-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5d4c964e658c2298ff8d1a954691e80e0598c06149e208c06714237d9f6351fd
MD5 8685d87312a2aac62f40094630b35a04
BLAKE2b-256 6a4dd65ddca813e4e21bd3b94a38f348c9506ef59b0fb1cf2d33fa519a101875

See more details on using hashes here.

File details

Details for the file crowact-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: crowact-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for crowact-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5caf1b659854d16e7d3a16076774693ae9c8e28ccfaba8fb0bd0a0fa8001327
MD5 85acde4f42ad354474694bae94a99865
BLAKE2b-256 ad7e16794eaf741b283f70fffd1ac75651ff49de9263b994231c751df7dab84c

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