Agent: dynamic models from aibroker, MCP agent tool per service, error display #27

Closed
opened 2026-04-08 22:14:59 +00:00 by timur · 1 comment
Owner

Changes needed

1. Dynamic model list from hero_aibroker

The agent tab model dropdown is hard-coded to 3 models (gpt-4o-mini, gpt-4o, claude-sonnet). It should dynamically fetch all available models from hero_aibroker across all connected providers.

  • Add GET /api/models endpoint that proxies ai.models RPC call to hero_aibroker
  • Replace hard-coded <select> with JS that populates on tab open
  • Graceful fallback if aibroker is not running

2. MCP agent tool per service

Each service already gets per-service MCP tools from its OpenRPC spec. Add an agent_run tool to every service MCP so Claude Desktop / MCP clients can invoke the agent directly.

  • Add agent_run tool to tools/list response alongside OpenRPC-derived tools
  • Handle agent_run in tools/call by delegating to agent::run_agent()
  • Tool schema: {prompt: string, model?: string, max_retries?: integer}

3. Better error display in agent UI

When the agent fails, show the actual error and script details prominently instead of just a generic failure message. Show per-attempt error details when retries occur.

## Changes needed ### 1. Dynamic model list from hero_aibroker The agent tab model dropdown is hard-coded to 3 models (gpt-4o-mini, gpt-4o, claude-sonnet). It should dynamically fetch all available models from hero_aibroker across all connected providers. - Add `GET /api/models` endpoint that proxies `ai.models` RPC call to hero_aibroker - Replace hard-coded `<select>` with JS that populates on tab open - Graceful fallback if aibroker is not running ### 2. MCP agent tool per service Each service already gets per-service MCP tools from its OpenRPC spec. Add an `agent_run` tool to every service MCP so Claude Desktop / MCP clients can invoke the agent directly. - Add `agent_run` tool to `tools/list` response alongside OpenRPC-derived tools - Handle `agent_run` in `tools/call` by delegating to `agent::run_agent()` - Tool schema: `{prompt: string, model?: string, max_retries?: integer}` ### 3. Better error display in agent UI When the agent fails, show the actual error and script details prominently instead of just a generic failure message. Show per-attempt error details when retries occur.
Author
Owner

Implemented on branch development_27 (commit 6f0bf37):

Changes:

  1. Dynamic models endpoint (GET /api/models) — proxies ai.models JSON-RPC call to hero_aibroker over Unix socket, returns all available models from all connected providers.

  2. Dynamic model dropdown — replaces the 3 hard-coded model options (GPT-4o Mini, GPT-4o, Claude Sonnet) with a JS fetch to /api/models on page load, populating the dropdown with all available models.

  3. agent_run MCP tool per service — every service's MCP server now includes an agent_run tool in tools/list. When called via tools/call, it delegates to agent::run_agent() which generates and executes Python code against the service. This lets MCP clients (like Claude Code) use the AI agent through the standard MCP protocol.

  4. Improved error display — agent failures now show a styled error alert with the actual error message, plus any LLM-generated explanation. Network errors include guidance about checking hero_aibroker. Success results get simple markdown-like formatting.

Files changed:

  • agent.rs — made send_unix_rpc and aibroker_socket_path public, added fetch_models()
  • mcp.rs — added agent_run tool to tools/list, handled it in tools/call
  • routes.rs — added GET /api/models route and models_handler
  • service.html — dynamic model loading, error formatting helpers, improved result display

All tests pass (7/7).

Implemented on branch `development_27` (commit 6f0bf37): **Changes:** 1. **Dynamic models endpoint** (`GET /api/models`) — proxies `ai.models` JSON-RPC call to hero_aibroker over Unix socket, returns all available models from all connected providers. 2. **Dynamic model dropdown** — replaces the 3 hard-coded model options (GPT-4o Mini, GPT-4o, Claude Sonnet) with a JS fetch to `/api/models` on page load, populating the dropdown with all available models. 3. **`agent_run` MCP tool per service** — every service's MCP server now includes an `agent_run` tool in `tools/list`. When called via `tools/call`, it delegates to `agent::run_agent()` which generates and executes Python code against the service. This lets MCP clients (like Claude Code) use the AI agent through the standard MCP protocol. 4. **Improved error display** — agent failures now show a styled error alert with the actual error message, plus any LLM-generated explanation. Network errors include guidance about checking hero_aibroker. Success results get simple markdown-like formatting. **Files changed:** - `agent.rs` — made `send_unix_rpc` and `aibroker_socket_path` public, added `fetch_models()` - `mcp.rs` — added `agent_run` tool to `tools/list`, handled it in `tools/call` - `routes.rs` — added `GET /api/models` route and `models_handler` - `service.html` — dynamic model loading, error formatting helpers, improved result display All tests pass (7/7).
timur closed this issue 2026-04-08 22:24:47 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_router#27
No description provided.