Update docs: fast tools, routecheck service, commute tool
- Request flow: add fast_tool_runner.run_matching() to pre-flight gather - New Fast Tools section: WeatherTool + CommuteTool table, extension guide - New routecheck section: captcha UI, internal API, proxy requirements - Services table: add routecheck:8090 - Files tree: add fast_tools.py, routecheck/, updated .env note Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
30
CLAUDE.md
30
CLAUDE.md
@@ -46,10 +46,12 @@ Channel adapter → POST /message {text, session_id, channel, user_id}
|
||||
→ 202 Accepted (immediate)
|
||||
→ background: run_agent_task()
|
||||
→ asyncio.gather(
|
||||
_fetch_urls_from_message() ← Crawl4AI, concurrent
|
||||
_retrieve_memories() ← openmemory search, concurrent
|
||||
_fetch_urls_from_message() ← Crawl4AI, concurrent
|
||||
_retrieve_memories() ← openmemory search, concurrent
|
||||
_fast_tool_runner.run_matching() ← FastTools (weather, commute), concurrent
|
||||
)
|
||||
→ router.route() → tier decision (light/medium/complex)
|
||||
fast tool match → force medium
|
||||
if URL content fetched → upgrade light→medium
|
||||
→ invoke agent for tier via Bifrost (url_context + memories in system prompt)
|
||||
deepagents:8000 → bifrost:8080/v1 → ollama:11436
|
||||
@@ -112,6 +114,7 @@ Session IDs: `tg-<chat_id>` for Telegram, `cli-<username>` for CLI. Conversation
|
||||
| `openmemory` | 8765 | FastMCP server + mem0 memory tools (Qdrant-backed) |
|
||||
| `grammy` | 3001 | grammY Telegram bot + `/send` HTTP endpoint |
|
||||
| `crawl4ai` | 11235 | JS-rendered page fetching |
|
||||
| `routecheck` | 8090 | Local routing web service — image captcha UI + Yandex Routing API backend |
|
||||
| `cli` | — | Interactive CLI container (`profiles: [tools]`), Rich streaming display |
|
||||
|
||||
External (from `openai/` stack, host ports):
|
||||
@@ -134,6 +137,25 @@ Crawl4AI is embedded at all levels of the pipeline:
|
||||
|
||||
MCP tools from openmemory (`add_memory`, `search_memory`, `get_all_memories`) are **excluded** from agent tools — memory management is handled outside the agent loop.
|
||||
|
||||
### Fast Tools (`fast_tools.py`)
|
||||
|
||||
Pre-flight tools that run before the LLM in the `asyncio.gather` alongside URL fetch and memory retrieval. Each tool has a regex `matches()` classifier and an async `run()` that returns a context string injected into the system prompt. The router uses `FastToolRunner.any_matches()` to force medium tier when a tool matches.
|
||||
|
||||
| Tool | Trigger | Data source |
|
||||
|------|---------|-------------|
|
||||
| `WeatherTool` | weather/forecast/temperature keywords | SearXNG query `"погода Балашиха сейчас"` — Russian sources return °C |
|
||||
| `CommuteTool` | commute/traffic/arrival time keywords | `routecheck:8090/api/route` — Yandex Routing API, Balashikha→Moscow center |
|
||||
|
||||
To add a new fast tool: subclass `FastTool` in `fast_tools.py`, add an instance to `_fast_tool_runner` in `agent.py`.
|
||||
|
||||
### `routecheck` service (`routecheck/app.py`)
|
||||
|
||||
Local web service that exposes Yandex Routing API behind an image captcha. Two access paths:
|
||||
- **Web UI** (`localhost:8090`): solve PIL-generated arithmetic captcha → query any two lat/lon points
|
||||
- **Internal API**: `GET /api/route?from=lat,lon&to=lat,lon&token=ROUTECHECK_TOKEN` — bypasses captcha, used by `CommuteTool`
|
||||
|
||||
Requires `.env`: `YANDEX_ROUTING_KEY` (free tier from `developer.tech.yandex.ru`) and `ROUTECHECK_TOKEN`. The container routes Yandex API calls through the host HTTPS proxy (`host.docker.internal:56928`).
|
||||
|
||||
### Medium vs Complex agent
|
||||
|
||||
| Agent | Builder | Speed | Use case |
|
||||
@@ -143,7 +165,9 @@ MCP tools from openmemory (`add_memory`, `search_memory`, `get_all_memories`) ar
|
||||
|
||||
### Key files
|
||||
|
||||
- `agent.py` — FastAPI app, lifespan wiring, `run_agent_task()`, Crawl4AI pre-fetch, memory pipeline, all endpoints
|
||||
- `agent.py` — FastAPI app, lifespan wiring, `run_agent_task()`, Crawl4AI pre-fetch, fast tools, memory pipeline, all endpoints
|
||||
- `fast_tools.py` — `FastTool` base class, `FastToolRunner`, `WeatherTool`, `CommuteTool`
|
||||
- `routecheck/app.py` — captcha UI + `/api/route` Yandex proxy
|
||||
- `bifrost-config.json` — Bifrost provider config (Ollama GPU, retries, timeouts)
|
||||
- `channels.py` — channel registry and `deliver()` dispatcher
|
||||
- `router.py` — `Router` class: regex + LLM classification, light-tier reply generation
|
||||
|
||||
Reference in New Issue
Block a user