|
|
@@ -0,0 +1,110 @@
|
|
|
+# Todo 10 Tool Registry Management Plan
|
|
|
+
|
|
|
+**Status:** done
|
|
|
+
|
|
|
+## Result
|
|
|
+
|
|
|
+Implemented by subagent and committed as `43b0cc8 feat: add tool registry management`.
|
|
|
+
|
|
|
+Main-session verification:
|
|
|
+
|
|
|
+```bash
|
|
|
+uv run pytest tests/test_event_agent.py tests/test_debug_runtime.py tests/test_websocket_api.py
|
|
|
+uv run pytest
|
|
|
+```
|
|
|
+
|
|
|
+Results:
|
|
|
+
|
|
|
+- focused EventAgent/runtime/WebSocket tests: `20 passed, 1 warning in 0.26s`
|
|
|
+- full suite: `23 passed, 1 warning in 0.27s`
|
|
|
+
|
|
|
+## Goal
|
|
|
+
|
|
|
+Replace the single hardcoded EventAgent tool checkbox with a backend tool registry and UI-managed loaded tools.
|
|
|
+
|
|
|
+## Why
|
|
|
+
|
|
|
+The original requirement says the debug page must manage which tools are loaded in EventAgent. The MVP has only one hardcoded `handoff_note` checkbox and duplicated tool schema logic in runtime. This todo makes tools a backend-owned registry so UI and runtime share the same source of truth.
|
|
|
+
|
|
|
+## Scope
|
|
|
+
|
|
|
+This todo covers:
|
|
|
+
|
|
|
+- A backend registry for available EventAgent tools.
|
|
|
+- An API endpoint that lists available tools and their schema/description.
|
|
|
+- Runtime tool schema lookup through the registry.
|
|
|
+- EventAgent execution through registered handlers.
|
|
|
+- Static UI rendering tool checkboxes from the API.
|
|
|
+- Tests for listing tools, selected-tool behavior, and UI request payload.
|
|
|
+
|
|
|
+This todo does not cover:
|
|
|
+
|
|
|
+- User-authored Python tool plugins.
|
|
|
+- Persistent tool configuration.
|
|
|
+- Hot-reloading tools from files.
|
|
|
+- Adding tools beyond the existing `handoff_note`.
|
|
|
+
|
|
|
+## Files
|
|
|
+
|
|
|
+- Create: `src/agent_lab/application/tools.py`
|
|
|
+- Modify: `src/agent_lab/application/event_agent.py`
|
|
|
+- Modify: `src/agent_lab/application/runtime.py`
|
|
|
+- Modify: `src/agent_lab/presentation/web.py`
|
|
|
+- Modify: `src/agent_lab/presentation/static/index.html`
|
|
|
+- Modify: `src/agent_lab/presentation/static/app.js`
|
|
|
+- Modify/add tests in `tests/test_event_agent.py`, `tests/test_debug_runtime.py`, and `tests/test_websocket_api.py`.
|
|
|
+- Do not modify: `docs/plans/todos.md`.
|
|
|
+
|
|
|
+## Design
|
|
|
+
|
|
|
+Create a small registry in application layer:
|
|
|
+
|
|
|
+- `ToolDefinition`: name, description, parameters, handler.
|
|
|
+- `ToolRegistry.available_tools()`: returns serializable public tool metadata.
|
|
|
+- `ToolRegistry.chat_tools(enabled_names)`: returns OpenAI-compatible tool definitions for selected names.
|
|
|
+- `ToolRegistry.handle(event)`: executes a registered tool and returns payload dict.
|
|
|
+
|
|
|
+`handoff_note` remains the only registered MVP tool. Unknown or disabled tools should still produce tool replies with explicit JSON errors, preserving current runtime behavior.
|
|
|
+
|
|
|
+`DebugRuntime` should accept an optional registry, defaulting to the built-in registry. `EventAgent` should also receive that registry. The runtime should stop building tool schemas manually.
|
|
|
+
|
|
|
+`GET /api/tools` returns:
|
|
|
+
|
|
|
+```json
|
|
|
+[
|
|
|
+ {
|
|
|
+ "name": "handoff_note",
|
|
|
+ "description": "Send a note to the event agent.",
|
|
|
+ "parameters": { "type": "object", "properties": { "message": { "type": "string" } }, "required": ["message"] }
|
|
|
+ }
|
|
|
+]
|
|
|
+```
|
|
|
+
|
|
|
+The static UI should fetch `/api/tools` on load, render a checkbox per tool, and send selected names in `event_agent.enabled_tools`.
|
|
|
+
|
|
|
+## Steps
|
|
|
+
|
|
|
+1. Add failing tests for:
|
|
|
+ - `GET /api/tools` returns `handoff_note` metadata.
|
|
|
+ - Runtime passes selected tool schemas from registry into ChatAgent.
|
|
|
+ - EventAgent returns disabled/unknown errors through the registry path.
|
|
|
+ - Static HTML/JS no longer hardcodes a `tool-handoff-note` checkbox dependency.
|
|
|
+2. Implement `application/tools.py`.
|
|
|
+3. Refactor `EventAgent` and `DebugRuntime` to use `ToolRegistry`.
|
|
|
+4. Add `GET /api/tools`.
|
|
|
+5. Update static UI to render tool checkboxes dynamically and preserve default checked state.
|
|
|
+6. Run:
|
|
|
+
|
|
|
+```bash
|
|
|
+uv run pytest tests/test_event_agent.py tests/test_debug_runtime.py tests/test_websocket_api.py
|
|
|
+uv run pytest
|
|
|
+```
|
|
|
+
|
|
|
+## Verification
|
|
|
+
|
|
|
+Expected result:
|
|
|
+
|
|
|
+- Tool metadata comes from backend API.
|
|
|
+- Runtime and EventAgent use the same registry.
|
|
|
+- UI selected tool list still drives `event_agent.enabled_tools`.
|
|
|
+- Full suite passes.
|