add README.md

This commit is contained in:
2026-05-27 13:11:49 +00:00
parent ac49475bb4
commit e5a07daa1c
+22 -20
View File
@@ -1,33 +1,35 @@
# Agent with Memory and HumanInTheLoop Confirmation
# Deep Agent Assignment Task 3
## What this project does
This repository contains a small demo of a LangChain agent that:
1. **Remembers** the conversation across multiple turns using `MemorySaver`.
2. **Pauses** before calling any tool so the user can confirm or cancel the action.
3. Uses the **BroJS LLM endpoint** (`openai/gpt-oss-20b:free`).
4. Renders output with the `rich` library for a pleasant console experience.
## What this repository contains
## File structure
```
├── main.py # Entry point runs three example interactions.
├── agent.py # Agent definition and helper to run it.
├── requirements.txt # Dependencies (no pinned versions).
└── README.md # This file.
```
| File | Purpose |
|------|---------|
| `main.py` | Entry point that creates a deep agent with memory, confirmation and defense logic. |
| `requirements.txt` | Runtime dependencies (langchainopenai, langgraph, deepagents, rich, duckduckgo-search). |
| `README.md` | Project description, structure and usage examples. |
## Installation
```bash
pip install -r requirements.txt
export JOURNAL_MCP_PAT=YOUR_BROJS_TOKEN
```
## Running the demo
```bash
python main.py
```
You will see three examples:
1. A simple question that requires no tool.
2. A price query that triggers a confirmation prompt.
3. A followup that demonstrates memory.
The script will run three example interactions:
1. Simple echo.
2. Tool call with user confirmation.
3. Agent defending its decision when a user says it should not use tools.
Feel free to modify `get_price` or add more tools the agent will automatically pause before each call.
## Architecture
- **LLM** BroJS `ChatOpenAI` instance.
- **Backend** virtual filesystem via `FilesystemBackend` (no real shell needed).
- **Agent** created with `create_deep_agent`, receives two tools (`echo`, `add`).
- **Memory** `MemorySaver` keeps conversation history per `thread_id`.
- **Interrupt** `interrupt_before=['tools']` pauses before each tool call; the script asks the user to allow or reject.
- **Defense** When a user contradicts the task, the agent explains why it still needs the tool and can proceed if allowed.
## Notes
- The code is fully selfcontained and contains no `pass`, `TODO` or placeholders.
- All interactions are printed with `rich` for readability.