Agent application that enable easy plugin with more tools.
Aurora combines LangChain, LangGraph, and OpenRouter to drive large models, blending conversational abilities with tool usage. It supports both a CLI and a Web UI, and includes built-in tools for web search/scraping, time, file writing, and Gmail (OAuth). The project also provides structured trace logging.
- Language/runtime: Python >= 3.13
- Core dependencies: langchain, langgraph, langchain-openai (used via OpenRouter), fastapi, aiohttp, google-api-python-client, bs4, python-dotenv
- Interfaces:
- CLI: interactive command-line agent (
python -m CLI.main) - Web: FastAPI + Jinja (
python -m Web.mainoruvicorn Web.main:app)
- CLI: interactive command-line agent (
- Multi-node agent graph (LangGraph):
- router: decides whether to answer directly, call a tool, plan, or send to the critic
- planner: produces an action plan and steps
- executor: executes tool calls (DuckDuckGo search/enrichment, website visit/crawl, time, file write, Gmail tools, etc.)
- critic: final review and answer composition
- Toolset (LangChain Tools):
- Time:
getCurrentTime - Web search & browsing:
ddg_html_search,ddg_html_search_enrich,visit_website,visit_websites_batch,crawl_website - File operations:
create_file,write_file,replace_in_file,read_file,pwd,ls,cp - Gmail (OAuth):
add_account,list_email_accounts,email_fetch_unread,email_send, draft APIs, etc.
- Time:
- Observability: Trace log (default
aurora_trace.log) - Persistence (Web): conversation histories stored in
Web/chats/*.json
- Install dependencies (recommended:
uvtool)
uv sync # installs dependencies from pyproject.toml / uv.lock- Configure environment variables
Copy .env.sample to .env and set the required values:
-
OpenRouter (required):
OPENROUTER_API_KEY— your OpenRouter API keyOPENAI_BASE_URL— e.g.https://openrouter.ai/api/v1
-
Models (required):
ROUTER_MODEL,PLANNER_MODEL,EXECUTOR_MODEL,CRITIC_MODEL(these are model identifiers used via OpenRouter or another compatible gateway)
-
Optional:
- Temperature controls:
ROUTER_TEMP,PLANNER_TEMP,EXECUTOR_TEMP,CRITIC_TEMP(default0.0) - Prompts:
SYSTEM_PROMPT,ROUTER_SYSTEM_PROMPT,PLANNER_SYSTEM_PROMPT,EXECUTOR_SYSTEM_PROMPT,CRITIC_SYSTEM_PROMPT - Router behavior switches:
ROUTER_FORCE_PLANNER,ROUTER_FORCE_CRITIC(set to truthy values like1,true,yes) - Trace log file:
TRACE_LOG_FILE(defaultaurora_trace.log) - Gmail-related settings (if using Gmail tools):
GOOGLE_CREDENTIALS_PATH,TOKEN_PATH,EMAIL_ACCOUNTS_PATH
Note: the model initialization will validate required environment variables and exit with the missing key name if any are absent.
- Run
- Temperature controls:
-
CLI mode:
python -m CLI.mainExample: "Search for three articles about LangGraph and summarize them." The agent will call search/visit tools when needed.
-
Web mode:
# Option A python -m Web.main # Option B (using uvicorn) uvicorn Web.main:app --host 0.0.0.0 --port 8000 --reload
Open http://localhost:8000. Conversation history is saved under
Web/chats/*.json.
Required:
-
OPENROUTER_API_KEY— OpenRouter API key -
OPENAI_BASE_URL— e.g.https://openrouter.ai/api/v1 -
ROUTER_MODEL,PLANNER_MODEL,EXECUTOR_MODEL,CRITIC_MODEL— model names/IDsOptional:
-
ROUTER_TEMP,PLANNER_TEMP,EXECUTOR_TEMP,CRITIC_TEMP— float temperatures (default0.0) -
Prompt variables:
SYSTEM_PROMPT,ROUTER_SYSTEM_PROMPT,PLANNER_SYSTEM_PROMPT,EXECUTOR_SYSTEM_PROMPT,CRITIC_SYSTEM_PROMPT -
TRACE_LOG_FILE— trace log file path (defaultaurora_trace.log) -
Router overrides:
ROUTER_FORCE_PLANNER,ROUTER_FORCE_CRITIC -
Gmail:
GOOGLE_CREDENTIALS_PATH,TOKEN_PATH,EMAIL_ACCOUNTS_PATH
- In Google Cloud Console create an OAuth client (Desktop app) and download the client credentials JSON (e.g.
client_secrets.json). - Set
GOOGLE_CREDENTIALS_PATHto the credentials file path andTOKEN_PATHto a directory where tokens will be stored. The first authorization will open a browser for login. - You can register and use accounts via CLI or Web tools, for example:
add_account(provider="gmail", name="me", email="you@example.com")
Token files are saved using the convention {account_name}_gmail.json (for example me_gmail.json).
All tools are exposed as LangChain Tools and aim for stable, readable return structures.
- Time:
getCurrentTime()-> str - Web:
ddg_html_search(query, max_results=10, country="us-en", site=None)-> List[dict]ddg_html_search_enrich(query, max_results=10, country="us-en", enrich_limit=5, site=None)-> List[dict]visit_website(url, max_chars=8000, timeout_sec=20)-> dictvisit_websites_batch(urls, max_chars=8000, timeout_sec=20, concurrency=10)-> List[dict]crawl_website(start_url, max_pages=5, same_domain=True, max_depth=2, max_chars=2000, timeout_sec=20)-> List[dict]
- Files:
create_file,write_file,replace_in_file,read_file,pwd,ls,cp - Gmail: add/list accounts, fetch/send emails, manage drafts, mark/read/delete messages
-
Model management:
core/models/LLM.py- Uses langchain-openai's ChatOpenAI adapter with OpenRouter
base_urlto support multiple providers. - Models are separated by role (router/planner/executor/critic); temperature and prompts are independently configurable.
- Uses langchain-openai's ChatOpenAI adapter with OpenRouter
-
Nodes and edges:
core/nodes.py,core/edges.py- Nodes produce messages or tool calls using role-specific system prompts + LLM invocation.
- Executor safely parses and runs tool calls synchronously to avoid event loop nesting issues.
- Edges use a StateGraph(MessagesState);
router_decisiondetermines flow (executor/planner/critic/END).
-
Engine:
core/engine.py- Assembles LLM, tools, and graph, and provides
Engine.run(user_input, history). - Recursive depth protection: if LangGraph hits the default 25-layer limit, the engine will prompt whether to continue/pause/stop and logs the event.
- Assembles LLM, tools, and graph, and provides
-
Observability:
core/observability/tracing.py— JSON-lines structured trace logs (defaultaurora_trace.log). -
Configuration:
core/Config.py(reads.env).
- Add new tools by following the
@toolimplementations inCurrentTimeTools,WebSearchTools,WriteFileTools, orEmailTools. Export tools to the CLI/Web tool list to make them available to the agent. - Customize prompts, models, and temperatures via
.envwithout code changes. - For debugging, use
ROUTER_FORCE_PLANNER/ROUTER_FORCE_CRITICto force routing behavior.
- Application exits with "Missing required API config": verify
.envcontainsOPENROUTER_API_KEY,OPENAI_BASE_URL, and the four model names. - Event loop errors from tool calls: the executor attempts to run calls synchronously; if you still see errors, attach
aurora_trace.logwhen reporting. - Web search timeouts or network errors: retry or increase
timeout_sec. For certificate issues, check system/root certificates and network settings. - Gmail OAuth issues: first run opens a browser for authorization. If
GOOGLE_CREDENTIALS_PATHis incorrect, a FileNotFoundError is raised. - Recursive depth prompts appear when conversations or tool chains get long — follow the prompt to continue or stop.