How amirmasoudcs/react-agent works
ReAct-Agent is a local Ollama-backed assistant exposed through a FastAPI web API and a command-line interface. In the web workflow, a user submits a message through the React chat; the backend runs the ReAct loop, optionally invokes tools, and streams a response while conversation state is persisted. Session management, title generation, and context summarization support conversation continuity. The README also documents configurable model settings and several research and utility tools. Some backend API wiring is supported by the source index rather than a complete excerpt, so unsampled details are not expanded.
Main entry points: api.py HTTP API · agent.py ReAct loop · registry.py Tool registry · client.py Ollama client
Components 23
Web interface
- Chat UI
frontend/src/App.jsx - Chat interaction
frontend/src/hooks/useChat.js - Session controls
frontend/src/hooks/useSessions.js - Messages and activity
frontend/src/components/MessageList.jsx - Model settings
frontend/src/components/SettingsModal.jsx
Agent runtime
- HTTP API
api.py - Command-line interface
main.py - ReAct loop
agent.py - Ollama client
llm/client.py - ReAct response parser
utils/react_parser.py - System prompt
prompts/system_prompt.py
Conversation state
- Context compaction
utils/context_manager.py - Session title generation
utils/session_title.py - Session storage
utils/session_manager.py
Agent tools
- Calculator
tools/calculator.py - Date and time
tools/datetime.py - Weather lookup
tools/weather.py - Web search
tools/web_search.py - Wikipedia search
tools/wikipedia_search.py - Tool registry
tools/registry.py
Other components
- User
- Ollama service
- External search and weather services
Connections 34
- User → Chat UI: submits message
frontend/src/App.jsx - Chat UI → Chat interaction: delegates chat
frontend/src/App.jsx - Chat interaction → HTTP API: sends requests
frontend/src/hooks/useChat.js - HTTP API → ReAct loop: runs agent
api.py - ReAct loop → Ollama client: requests completion
agent.py - Ollama client → Ollama service: calls model
llm/client.py - ReAct loop → ReAct response parser: parses response
agent.py - ReAct loop → System prompt: builds prompt
agent.py - ReAct loop → Tool registry: dispatches tools
agent.py - Tool registry → Calculator: registers tool
- Tool registry → Date and time: registers tool
- Tool registry → Weather lookup: registers tool
- Tool registry → Web search: registers tool
- Tool registry → Wikipedia search: registers tool
- Weather lookup → External search and weather services: looks up weather
- Web search → External search and weather services: searches web
- Wikipedia search → External search and weather services: queries Wikipedia
tools/wikipedia_search.py - ReAct loop → Context compaction: builds context
agent.py - Context compaction → Ollama client: summarizes history
utils/context_manager.py - Context compaction → Session storage: loads and saves summary
- HTTP API → Session storage: manages sessions
api.py - HTTP API → Session title generation: generates titles
api.py - Session title generation → Ollama client: requests title
utils/session_title.py - Session title generation → Session storage: checks names
utils/session_title.py - Command-line interface → ReAct loop: runs agent
main.py - Command-line interface → Session storage: manages sessions
main.py - Command-line interface → Context compaction: configures context
main.py - HTTP API → Ollama client: streams responses
api.py - HTTP API → Chat interaction: streams responses
- Chat interaction → Messages and activity: renders activity
frontend/src/App.jsx - Chat UI → Session controls: loads sessions
frontend/src/App.jsx - Session controls → HTTP API: manages sessions
- Chat UI → Model settings: opens settings
frontend/src/App.jsx - Model settings → HTTP API: configures model