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.1.tar.gz (70.8 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.1-py3-none-any.whl (96.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for my_react_agent-1.1.1.tar.gz
Algorithm Hash digest
SHA256 727a6d965343a62101f5c554477d722fcd3318088648fd64f91abebf7a71112c
MD5 170c91ea55b98a7aae8a2e6779d0a22b
BLAKE2b-256 8296d931c928ccd97a7808af5a9ff5b9c319edff4da2fe0cd0129d443a4c781a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for my_react_agent-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2ccf0561d40da1c1fdedc889d295522dc51f8a81f749eaf3e9117cbc67533ea
MD5 8985c7b6ae347e2dfdd47d8ba55819ca
BLAKE2b-256 44a7cfa1aaa18a0ac415a50bce70242d17d32e0660211a3c0005f1af1f316ffa

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