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.2.tar.gz (52.5 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.2-py3-none-any.whl (74.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: my_react_agent-1.1.2.tar.gz
  • Upload date:
  • Size: 52.5 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.2.tar.gz
Algorithm Hash digest
SHA256 15c6eb9b20b2341a4f991e2a0b4e70625af24c0aaf6b6cddc68263f252a89974
MD5 03e5e40fa1edf78d0e0928f1cdbee8c5
BLAKE2b-256 ae8bed4966cfa31b00a252098a9c145d08d851b778e5e63e9686cd5fd7cc9bde

See more details on using hashes here.

File details

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

File metadata

  • Download URL: my_react_agent-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 74.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c9a0d2e9ace5cfa4c28f65bd90e7a1cfeb56d76a6f8b50f8860bd0df3bf0160b
MD5 79a17301fab804faad843ac2b54f9662
BLAKE2b-256 fa2b9cd776cfb00e62497cccd441c55d2164b10715b53783653d8403277282f4

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