Skip to main content

ReAct plan-execute agent with memory

Project description

my-react-agent

A ReAct (Reason + Act) agent with explicit traceability, confidence gating, memory/evidence and pluggable tools.

This project implements a ReAct-style agent that decomposes a user question into step plans, executes each step via actions/tools, evaluates step quality and then synthesises a final answer only from collected observations and evidence.

Key features:

  • Plan → Execute → Finalise pipeline with step-by-step traceability (transcript + evidence per step)
  • Modular actions + handlers (add new behaviour without touching core orchestration)
  • Pluggable tools via a single execution boundary (ToolExecutor)
  • Memory + evidence-first design (QueryMemory + ConversationMemory, structured Evidence)
  • Robustness hooks: per-step confidence assessment + retry loops

License

MIT

Requirements

  • Python 3.10+
  • Ollama (local LLM runtime)

From PIP

pip install my-react-agent

From Source

pip install git+https://git01lab.cs.univie.ac.at/zhaniyaa77/my-react-agent.git

Install Ollama

Download and install Ollama:

Pull a model (example used below: llama3):

ollama pull llama3

Usage

import os

from my_react_agent.agent_heart.react_agent import ReActAgent
from my_react_agent.llm_adapters.ollama_llama3_llm import OllamaLlama3LLM

from my_react_agent.agent_core.agent_actions import (
    AnswerByItselfAction,
    ClarifyAction,
    UseToolAction,
    StopAction,
)
from my_react_agent.agent_core.agent_actions.need_context_action import NeedContextAction

from my_react_agent.agent_memory.llm_entity_extractor import LLMEntityExtractor


def main() -> None:
    # LLM roles (all backed by Ollama)
    planner_llm = OllamaLlama3LLM(model="llama3")
    summariser_llm = OllamaLlama3LLM(model="llama3")
    confidence_llm = OllamaLlama3LLM(model="llama3")

    # Entity extractor used by the NEED_CONTEXT mechanism
    entity_extractor = LLMEntityExtractor(summariser_llm)

    # Minimal tool set: empty dict works if you don't use tools
    # If your package includes tools and you want them, you can create them here.
    tools = {}

    step_actions = [
        NeedContextAction(),
        AnswerByItselfAction(),
        ClarifyAction(),
        UseToolAction(),
        StopAction(),
    ]

    low_conf_actions = [
        NeedContextAction(),
        UseToolAction(),
        AnswerByItselfAction(),
        StopAction(),
        ClarifyAction(),
    ]

    agent = ReActAgent(
        planner_llm=planner_llm,
        summariser_llm=summariser_llm,
        confidence_llm=confidence_llm,
        entity_extractor=entity_extractor,
        tools=tools,
        max_steps=6,
        step_actions=step_actions,
        low_conf_actions=low_conf_actions,
    )

    answer = agent.handle("Explain what a ReAct agent is in 2 sentences.")
    print(answer)
if __name__ == "__main__":
    main()

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

my_react_agent-1.1.3.tar.gz (54.0 kB view details)

Uploaded Source

Built Distribution

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

my_react_agent-1.1.3-py3-none-any.whl (74.6 kB view details)

Uploaded Python 3

File details

Details for the file my_react_agent-1.1.3.tar.gz.

File metadata

  • Download URL: my_react_agent-1.1.3.tar.gz
  • Upload date:
  • Size: 54.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for my_react_agent-1.1.3.tar.gz
Algorithm Hash digest
SHA256 6ffc474d21102c77b41ee500b7d1ac5fba668576ff41fe84046f9a1a14d3c712
MD5 e2d6cc4c41af40e55117eaecc30597fa
BLAKE2b-256 2cb936e0a674dbd6efe758c8e000526200a63471d87df192db6e743f69efc612

See more details on using hashes here.

File details

Details for the file my_react_agent-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: my_react_agent-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 74.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for my_react_agent-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0a6b895d45112a98b2e162603694b89448d08439aa7833362d8896451ad74b5c
MD5 780c95f24ee5c3459c117c936192c375
BLAKE2b-256 7ece91b7e524e34b5f7d283493bd12a3c409b566531b9785ccfd24cbb45bc1b3

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