跪拜 Guibai
← All articles
HarmonyOS

Building a HarmonyOS Agent Workbench That Shows Intent, Not Chat

By 一只牛博 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Most Agent integrations on mobile start with a chat box that hides the model's decision-making. Exposing intent, tool selection, and failure context inline turns the UI into a debugging surface, which is what teams actually need during integration before they can trust an Agent with real tasks.

Summary

A new Agent workbench built with ArkUI and a local Gateway shifts the HarmonyOS interaction model from conversation to task orchestration. Instead of displaying a natural-language reply, the page shows the structured routing result: which intent was recognized, which tool will execute, whether confirmation is required, and the model's reasoning. The interface connects to only two endpoints—a health check and an intent router—keeping the end-side thin and the model Key off-device.

The page models every exchange as a stateful message: pending, success, or error. A health-check button at the top quickly isolates whether a failure is in the UI code or the Gateway process. When the Gateway address is deliberately broken, the error stays inline in the message list rather than disappearing into a toast, preserving the task context for debugging.

The workbench validates four integration points: local Gateway reachability, Network Kit requests from a HarmonyOS device, structured intent routing from natural language, and clear failure states for unreachable addresses. It stops short of executing tools, but the boundary it draws—service status, user input, model routing, execution feedback—is the minimum a production Agent UI needs beyond a chat bubble.

Takeaways
Starting with a chat box skips the information needed for debugging: service status, model intent, tool routing, and error location.
A local Agent Gateway keeps the model Key off the HarmonyOS device; the end-side only requests localhost and displays results.
The `/health` endpoint and a dedicated button let developers quickly distinguish UI bugs from a dead Gateway process.
Structured routing results (`intent`, `tool`, `needConfirm`, `reason`) replace a natural-language reply so users can judge task trustworthiness.
Messages transition through a `pending` state before showing success, preventing users from thinking a button press was ignored.
Deliberately breaking the Gateway address surfaces Network Kit errors inline in the message list, preserving the task context.
When accessing a local Gateway from a Previewer or simulator, `127.0.0.1` must point to the host machine; LAN access requires `0.0.0.0` and the host's LAN IP.
Conclusions

An Agent UI that only shows final replies is a black box; a workbench that shows routing decisions is a debugging tool, and the latter is what teams need before they can ship.

The three responsibilities defined here—initiate task, make model judgment visible, keep failure in context—form a practical checklist that applies to any mobile Agent integration, not just HarmonyOS.

Keeping the model Key exclusively on a local Gateway and off the device is a security boundary that also simplifies the client code to pure display logic.

Showing a `pending` state before replacing it with a result is a small UI detail that eliminates a common source of user confusion during network latency.

Concepts & terms
Agent Gateway
A local service that sits between a device and an LLM, handling API key management, health checks, and intent routing so the client never holds credentials or executes tool logic directly.
Intent Routing
The process of converting a natural-language user request into a structured object containing the recognized intent, the tool to invoke, whether confirmation is needed, and the model's reasoning.
ArkUI
HarmonyOS's declarative UI framework for building native applications, used here to construct the Agent workbench page.
Network Kit
HarmonyOS's networking module that handles HTTP requests from an application, requiring explicit internet permission in the module configuration.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗