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+
requestspython-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
history is optional. If omitted, the Agent starts with an empty history and keeps appending records across later run() calls. Stored history includes user messages, assistant messages, tool calls, and tool results. The history is available at agent.history and is truncated from the front with history_window (default: 20).
agent = Agent(
provider=provider,
model="deepseek-v3.2",
system_prompt="You are helpful.",
history_window=20,
)
agent.run("First question")
agent.run("Follow-up question")
print(len(agent.history)) # <= 20
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
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 crowact-0.1.3.tar.gz.
File metadata
- Download URL: crowact-0.1.3.tar.gz
- Upload date:
- Size: 7.9 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00324b84c5c111f55ed6dd95c991c85c703bf98c6036a9a630c8dc3e8b907cc7
|
|
| MD5 |
7ceab114d715ff70427269a3966b75f0
|
|
| BLAKE2b-256 |
3894c169dece8209540e08333a22292f4a317826c727c373e305d5c67e1390f4
|
File details
Details for the file crowact-0.1.3-py3-none-any.whl.
File metadata
- Download URL: crowact-0.1.3-py3-none-any.whl
- Upload date:
- Size: 9.7 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d09b78e9d1c9345b46b84a23fc4c4d3e887bce1d0456b87ee4a4414212cc3bc8
|
|
| MD5 |
60f029568168fe9017b40dbf85cc2ecd
|
|
| BLAKE2b-256 |
5d5a8b826c5906a92eba67d5b6e5cdb3fb09bb86fa88dc7628d85916d1ff21cd
|