cd /news/ai-agents/connecting-conversation-and-ui-with-… Β· home β€Ί topics β€Ί ai-agents β€Ί article
[ARTICLE Β· art-174523] src=dev.to β†— pub= topic=ai-agents verified=true sentiment=↑ positive

Connecting Conversation and UI with Hermes: The Architecture of an AI Dialogue Plugin

A developer built Hermes, an AI dialogue plugin that renders interactive forms directly in chat, letting a model call tools to create drafts while a React UI collects missing values and submits the request through an SDK. The architecture links the model to the outside world through three mechanisms: Python-registered tools with JSON schemas, a SKILL.md playbook loaded on demand, and directives that Hermes replaces with UI components. The developer reports that a local model (qwen3.6) sometimes invented directive names or skipped the form, prompting the use of an afterCall field to carry mandatory follow-up instructions back to the model.

recommendation

Put mandatory post-tool instructions in the tool's return value (afterCall) rather than the system prompt, since the result always reaches the model immediately after the call.

more in playbook: Designing agent systems
by read7 min views1 publishedNov 23, 2026

I built a Hermes plugin that opens a form in the chat when you talk to it, helps you fill in the values through a GUI, and then runs the request through an SDK behind the scenes.

I will not go into the SDK itself (the mechanics of sending funds).

There are three players:

Player Role
User Tells the chat what they want. Fills in the form and decides when to run it
Model Reads the conversation and decides what to do
UI Renders a form in the chat. Calls the SDK from the submit button

The model can only produce text and tool calls. Hermes therefore provides three mechanisms that connect the model to the outside world.

flowchart LR
    U([User]) -- chat --> M[Model]
    M -- 1.1 call a tool --> P[Plugin logic<br/>Python]
    P -- return value + afterCall --> M
    S[1.2 SKILL.md<br/>playbook] -. only when loaded .-> M
    M -- 1.3 write a directive in the reply --> H[Hermes]
    H -- replace with a component --> UI[Form<br/>React]
    U -- input / submit --> UI
    UI -- run --> SDK[(SDK)]
Mechanism Purpose Direction
tool Lets the model invoke processing Model ⇄ plugin logic
SKILL.md Teaches the model the procedure β†’ Model
directive Hermes replaces it with a UI component Model β†’ Hermes β†’ UI

A tool is a function the model can call. The developer registers the name, the shape of the arguments, and the handler. The handler is written in Python.

ctx.register_tool(
  name='create_draft',
  schema={
    'name': 'create_draft',
    'description': 'Create a draft for a transfer',
    'parameters': {
      'type': 'object',
      'properties': {
        'kind': {'type': 'string', 'enum': ['send', 'deposit', ...]},
        'fields': {
          'type': 'object',
          'properties': {
            'network': {'type': ['string', 'null'], 'enum': ['polygon', 'base', ..., None]},
            'token':   {'type': ['string', 'null'], 'enum': ['USDC', 'JPYC', ..., None]},
            'amount':  {'type': ['string', 'null']},
            'to':      {'type': ['string', 'null']},
          },
          'additionalProperties': False,
        },
      },
      'required': ['kind', 'fields'],
    },
  },
  handler=create_handler,
)

The only thing visible to the model is the schema. Every field allows null, and the allowed values are listed in an enum. If the user says "I want to send 0.01 USDC," the model calls the tool with arguments in this shape. Fields the user did not mention are left as null rather than guessed.

{
  "kind": "send",
  "fields": { "network": null, "token": "USDC", "amount": "0.01", "to": null }
}

Hermes runs the handler and returns the result to the model. The model reads that result and writes its next reply.

This is where afterCall comes in. You put "rules to follow after the call" in the return value. Because the return value always reaches the model immediately after the tool is called, it is a good place for instructions that must not be skipped.

In practice, with a local model (qwen3.6), I saw it invent directive names, pass along unverified information, or skip the form I had prepared. I now put those same reminders in afterCall.

Here is a typical example:

{
  "directive": "::draft-card{id=\"…\"}",
  "afterCall": "In your next reply, write the directive above on its own line, exactly as is. Do not ask for missing values in the chat. Collect input through the card."
}

SKILL.md is a playbook you have the model read. You write "when asked to send funds, proceed like this" in Markdown.

---
name: send
description: "Start a transfer and report the result."
---

Do not ask for the network, token, amount, or destination in the chat.
The form already has input fields. Write a short sentence, then put the directive on the next line.

The only thing that always goes into the system prompt is the one-line description. The body enters the conversation only when the model decides "I need this skill" and loads it. The upside is that you can write a long procedure and still keep the everyday prompt short. The downside is that if the model never reads it, the procedure never arrives. In other words, whether it gets read is up to the model. This comes up again in the wrap-up.

A directive is a mechanism that replaces one line in the model's reply with a React component. On the UI side, you register a name and a component.

ctx.register({
  area: TRANSCRIPT_DIRECTIVE_AREA, // a constant from the Hermes Plugin SDK
  data: {
    name: 'draft-card',
    render: (props) => <DraftCard {...props} />,
  },
})

When the model replies like this, Hermes replaces the ::draft-card{...} line with a card. The contents of the curly braces are passed to the component as attrs.

I've opened a transfer form. Please fill in the rest.

::draft-card{token="USDC" amount="0.01"}

The model does not draw the screen. It just writes one line that means "put this component here."

sequenceDiagram
    actor U as User
    participant M as Model
    participant T as tool (Python)
    participant H as Hermes
    participant UI as Form (React)
    participant SDK as SDK

    U->>M: I want to send 0.01 USDC
    M->>T: call create_draft
    T-->>M: directive and afterCall
    M->>H: write the directive in the reply
    H->>UI: replace the directive line with a form
    U->>UI: fill in the rest and submit
    UI->>SDK: send funds

That was enough to get "talk to it and a form opens" working. But once the values had been passed from the directive attributes into the form, they existed only in React state (inside the screen). That is where the trouble started πŸ˜…

All three have the same root cause: where the values live. If you put them in the reply, the UI cannot edit them. If you put them in UI state, the model cannot read them.

So I decided to put them somewhere that is neither of those places. That somewhere is SQLite.

flowchart LR
    U([User]) -- chat --> M[Model]
    M -- create / read / update / cancel --> T[tool<br/>Python]
    T -- return value + afterCall + directive --> M
    T <--> DB[(Draft<br/>SQLite)]
    M -- "::draft-card{id=…}" --> H[Hermes]
    H -- replace with a component --> UI[Card<br/>React]
    UI <-- plugin REST API --> DB
    U -- input / submit --> UI
    UI -- send funds --> SDK[(SDK)]

Each chat session holds one draft row. The model reads and writes that same row through tools; the UI does it through the plugin's REST API. The table actually looks like this (only the columns needed for this explanation):

CREATE TABLE drafts (
  id TEXT PRIMARY KEY,
  session_id TEXT NOT NULL,
  kind TEXT NOT NULL,
  fields TEXT NOT NULL,        -- input values (JSON)
  revision INTEGER NOT NULL,   -- incremented by 1 whenever a value changes
  state TEXT NOT NULL,         -- editing / sending / consumed / cancelled
  claim_token TEXT,
  operation_id TEXT,
  outcome TEXT,
  ...
);

To summarize, I chose SQLite for these two reasons:

There is only one table, so I skipped an ORM and manage the schema version with PRAGMA user_version.

The only thing the directive now passes is the ID. Every time the card opens, it reads the latest saved values.

afterCall in the return value, you can reliably deliver reminders immediately after the call.SKILL.md That said, I ran into one more wall. When the text a plugin adds to the system prompt (the prompt section) exceeds 4,000 characters, a local model (qwen3.6) did not load it at all. The plugin cannot raise this limit. As I added more transfer types, it grew to 4,482 characters, and the model stopped calling tools entirely and started answering everything in the chat πŸ˜…

I also tried moving the procedure out into SKILL.md. But that model (qwen3.6) did not read the skill, and started asking for the destination in the chat. It was exactly the "if it does not read it, it never arrives" problem I described in 1.2.

For now, I write only a short one-line "when to use this" for each type, and push the detailed rules into the tool schema, afterCall, and validation on the card, so everything stays under the limit. If the number of types keeps growing, though, we will run out of room eventually. I am still thinking about how to handle that.

── more in #ai-agents 4 stories Β· sorted by recency
── more on @hermes 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/connecting-conversat…] indexed:0 read:7min 2026-11-23 Β· β€”