Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.20.0] — 2026-12-02

### Added

- **A tool-call label can be filled from the call's arguments.** A tool schema's
`x-summary-template` (`X_SUMMARY_TEMPLATE_KEY`), or the `data-tools-url` catalog's
`summary_template` that django-spec-agents 0.31.0 emits, such as
`"Search orders for {query}"`, labels the card head and the step-group row with the filled
sentence. Placeholders fill from top-level string, number and boolean arguments; if any
cannot be filled the label is the static one, as before. A filled template outranks every
static label, a host's `toolSummaries` entry included. Values are set as text.
`ToolCatalogEntry` gains `summaryTemplate`. No opt-in: the server or tool supplies the
template, and a tool without one labels exactly as before.
- **A tool card's arguments read by what the server says about each one.** The
`data-tools-url` catalog's `arguments` projection (django-spec-agents 0.31.0 and later), or a
client tool's own `parameters.properties`, labels an argument by its `title`, draws an enum
constant as its `oneOf` label, draws a `date` or `date-time` string through `Intl` in the
browser's locale, and leaves an `x-hidden` argument out of the list. View raw still shows the
exact JSON, constants and hidden arguments included. `ToolCatalogEntry` gains `arguments`, and
`ToolCallCardOptions` gains `display` (a `PayloadDisplay`, the arguments region only), with
`ArgumentDisplays`, `ArgumentDisplay`, `ArgumentChoice` and `PayloadDisplay` exported as types;
a malformed projection costs that field, never the entry. No opt-in: a catalog or schema
without these keys draws exactly as before.

## [0.19.0] — 2026-12-02

### Added
Expand Down Expand Up @@ -1103,7 +1127,8 @@ move page walks a host over. Each entry below says whether a host opts in.
kept offering the moon under `theme="dark"`. Only the toggle's own click redrew it before. A host
opts in to nothing.

[Unreleased]: https://github.com/Artui/agents-web-components/compare/v0.19.0...HEAD
[Unreleased]: https://github.com/Artui/agents-web-components/compare/v0.20.0...HEAD
[0.20.0]: https://github.com/Artui/agents-web-components/compare/v0.19.0...v0.20.0
[0.19.0]: https://github.com/Artui/agents-web-components/compare/v0.18.0...v0.19.0
[0.18.0]: https://github.com/Artui/agents-web-components/compare/v0.17.0...v0.18.0
[0.17.0]: https://github.com/Artui/agents-web-components/compare/v0.16.0...v0.17.0
Expand Down
2 changes: 2 additions & 0 deletions demo/app/scenarios.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ export const SCENARIOS = [
["Nothing to open", "ping"],
["Readable arguments", "look up an invoice"],
["Sub-agents", "delegate this"],
["Labels from arguments", "search orders"],
],
attrs: { "data-tools-url": "/tools/" },
},
{
slug: "approvals",
Expand Down
48 changes: 48 additions & 0 deletions demo/mock-server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,28 @@ async function streamText(res, messageId, chunks) {
emit(res, { type: "TEXT_MESSAGE_END", messageId });
}

const TOOL_CATALOG = [
{
name: "search_orders",
summary: "Search orders",
summary_template: "Search orders for {query} in {status}",
// How each argument reads in the card's list: a title, enum labels, a date
// format and a hidden key, as django-spec-agents projects them.
arguments: {
query: { title: "Customer" },
status: {
oneOf: [
{ const: "late", title: "Running late" },
{ const: "open", title: "Awaiting reply" },
],
},
since: { format: "date" },
trace_id: { "x-hidden": true },
},
},
{ name: "tag_record", summary: "Tag a record", summary_template: "Tag {record} with {tags}" },
];

function emitToolCall(res, id, name, args, parentMessageId) {
emit(res, { type: "TOOL_CALL_START", toolCallId: id, toolCallName: name, parentMessageId });
emit(res, { type: "TOOL_CALL_ARGS", toolCallId: id, delta: JSON.stringify(args) });
Expand Down Expand Up @@ -969,6 +991,25 @@ async function handleAgent(res, body) {
const parent = id("msg");
await streamText(res, parent, ["Trying the flaky one…"]);
emitToolCall(res, id("call"), "break_something", {}, parent);
} else if (/\bsearch orders\b/i.test(prompt)) {
// Labels filled from the call's arguments: the /tools/ catalog gives these
// tools a summary_template. The first fills; the second lacks an argument
// and the third's is a list, so both show the static summary instead. The
// catalog's arguments projection labels the first card's arguments list.
const parent = id("msg");
await streamText(res, parent, ["Looking those up…"]);
const calls = [
["search_orders", { query: "acme", status: "late", since: "2026-11-01", trace_id: "req-81f2" }],
["search_orders", { query: "globex" }],
["tag_record", { record: "order-17", tags: ["urgent", "vip"] }],
];
for (const [name, args] of calls) {
const call = id("call");
emitToolCall(res, call, name, args, parent);
await sleep(400);
emitToolResult(res, call, JSON.stringify({ ok: true }));
}
await streamText(res, id("msg"), ["Done."]);
} else if (/\bthink silently\b/i.test(prompt)) {
// Reasoning that carries no text, the way a provider sends redacted
// thinking or reasoning with its summaries off: a start and an end and
Expand Down Expand Up @@ -1668,6 +1709,13 @@ const server = createServer((req, res) => {
editorRoute(req, res, path);
return;
}
if (req.method === "GET" && req.url === "/tools/") {
// The tool-label catalog, entries as django-spec-agents' build_tool_catalog
// writes them (tests/fixtures/summary_template.json is the recorded output).
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify(TOOL_CATALOG));
return;
}
if (req.method === "GET" && req.url === "/runs/") {
// The run index behind the header's checkpoint control. Without this route
// the button is not built at all — the element only offers it when a host
Expand Down
7 changes: 6 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ paths.
| `X_DESTRUCTIVE_KEY` / `X_NAVIGATES_KEY` | const | The JSON-Schema extension keys. |
| `parseToolCatalog(data)` | function | Parse a fetched `data-tools-url` catalog into a `Record<string, ToolCatalogEntry>` — whole entries, not bare summaries, so a caller can reach `description` too. Malformed input yields an empty map rather than throwing. |
| `ToolCatalogEntry` | type | One row of that catalog. |
| `ArgumentDisplays` | type | A catalog entry's `arguments` projection, read: argument name to its `ArgumentDisplay` (a `Map`). |
| `ArgumentDisplay` | type | How one argument reads: `{ title?, format?, choices?, hidden? }`. |
| `ArgumentChoice` | type | One choice of an enumerated argument: `{ const, title? }`. |
| `prettifyToolName(name)` | function | Last fallback of the tool-card label chain (`delete_record` reads as *Delete record*). |

## Host seams
Expand Down Expand Up @@ -157,7 +160,8 @@ paths.
| `ToolGroupDisplayMode` | type | How an opened step group draws its calls (`TOOL_GROUP_DISPLAY`'s values). |
| `ToolPayloadFormatter` | type | Draws one region of a card's body (`AgUiChat.formatToolPayload`); `null` falls through to the built-in pretty-print. |
| `ToolPayload` | type | The region being drawn: `arguments` (the parsed record) or `result` (the raw string and its outcome). |
| `ToolCallCardOptions` | type | Per-card wiring beyond name / args / label / strings — currently `formatPayload`. |
| `ToolCallCardOptions` | type | Per-card wiring beyond name / args / label / strings: `formatPayload` and `display` (a `PayloadDisplay`, read by the arguments region only). |
| `PayloadDisplay` | type | How a card's arguments read: `{ arguments?, locale? }`, an `ArgumentDisplays` map and the `Intl` locale dates draw in. |
| `requestConfirmation(host, request, options?)` | function | Append the inline confirmation card to the transcript. |
| `ConfirmationRequest` | type | What the card displays. |
| `ConfirmationOptions` | type | `{ signal?, strings?, onAlwaysAllow? }` — abort resolves the card as declined; `strings` localizes it; passing `onAlwaysAllow` is what adds the third button. |
Expand Down Expand Up @@ -234,5 +238,6 @@ paths.
| `TOOL_OUTCOME` | How a tool call ended, as a server states it on `TOOL_CALL_RESULT` (`success` / `failed` / `denied`). |
| `X_CONFIRM_KEY` | Confirmation-prompt key: on a tool's JSON Schema for a client-side confirmation, and in an AG-UI interrupt's `metadata` for a server-side approval. |
| `X_SUMMARY_KEY` | JSON-Schema key carrying a short tool-card label. |
| `X_SUMMARY_TEMPLATE_KEY` | JSON-Schema key carrying a tool-card label with `{name}` placeholders filled from the call's arguments. |
| `MAX_TOOL_ROUNDS` | Upper bound on tool-call → re-run rounds per send. |
| `VERSION` | The package version string. |
6 changes: 4 additions & 2 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ another origin, add `credentials="include"` too; see
| `data-routine-minute-step` | `5` | The minute step of the routine form's time field, a whole number from 1 to 30; anything else keeps 5. Read each time the form opens. A routine saved at a minute off the step still shows that minute. See [The time and timezone fields](skills.md#the-time-and-timezone-fields). |
| `data-skill-editor-button` | absent | With `data-skill-editor-url`, also puts a Skills button in the header. Off by default. On a narrow panel it moves into the header's [More menu](header-and-panel.md#the-header-row-and-its-more-menu) like the other optional controls. |
| `data-editors` | absent | `external` hands the skill editor and routines to the page: the Skills and Routines buttons, Make this a routine and the palette's Manage skills fire `ag-ui-open-editor` instead of opening the view in the panel, for an [editor element](editors.md#the-editors-on-a-page-of-their-own) to answer. Read at each click. The methods still open the panel. |
| `data-tools-url` | — | URL of a server tool-label catalog (`[{ name, summary, description? }]`), fetched with the element's headers and cookie policy; labels tool-call cards for server-side tools. |
| `data-tools-url` | — | URL of a server tool-label catalog (`[{ name, summary, summary_template?, description?, arguments? }]`), fetched with the element's headers and cookie policy; labels tool-call cards for server-side tools and [their arguments](tool-calls.md#what-the-server-says-about-each-argument). |
| `user-key` | `userKey` | Who the stored conversation belongs to — any string identifying the signed-in principal. Joins the storage namespace, and **changing it purges what the previous principal left behind**. Live (not connect-time): a logout is the host's to announce. See [Who the stored conversation belongs to](durability.md#who-the-stored-conversation-belongs-to-user-key). |
| `user-name` | `userName` | The signed-in user's display name, for the [greeting](theming.md#the-greeting-on-an-empty-page) an empty conversation shows under `placement="page"`. Presentation only: unlike `user-key` it scopes nothing and is never sent. Absent or blank gives the nameless greeting. Live. |
| `data-threads-url` | — | URL of a server thread index (django-ag-ui's `ThreadsView`, or any server that keeps to [the threads contract](threads-contract.md)); enables durable, cross-device chat history. |
Expand Down Expand Up @@ -222,7 +222,9 @@ the django-ag-ui `@tool` registry), whose schema never reaches the browser — e
`chat.toolSummaries = { list_projects: "Search projects" }`. Or point
`data-tools-url` at a server catalog endpoint (django-ag-ui's `tools/`) and the
labels are fetched automatically — per card, `x-summary` → an explicit
`toolSummaries` entry → the fetched catalog → the raw name.
`toolSummaries` entry → the fetched catalog → the raw name. A
[summary template](tool-calls.md#a-label-filled-from-the-calls-arguments) the call's
arguments can fill comes before all of them.

`sharedState` is AG-UI shared state, documented under
[the run loop](concepts.md#the-run-loop-and-the-ag-ui-client); `unread` and `unhandledActivityTypes` are
Expand Down
34 changes: 34 additions & 0 deletions docs/tool-calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,23 @@ this list too. Parts: `tool-card-section-head` (the heading row), `tool-card-raw
`tool-card-field-value`; a value the card worded itself carries `data-kind` (`boolean`,
`empty` or `count`, else `text`).

#### What the server says about each argument

The arguments list reads more of the tool's schema when it has it: a client tool's own
`parameters.properties`, else the `arguments` projection on the `data-tools-url` catalog's
entry, which django-spec-agents 0.31.0 and later emit, translated, for the request's locale.
Per argument:

- `title` replaces the prettified key;
- `oneOf: [{const, title}]` draws a value equal to a `const` as its `title` (the View raw JSON
keeps the constant);
- `format: "date"` and `"date-time"` draw a string through `Intl.DateTimeFormat` in the
browser's locale (a date as its calendar day), and fall back to the text if it does not parse;
- `x-hidden: true` leaves the argument out of the list; View raw still shows it.

A malformed `arguments` costs only itself: the entry keeps its label. The result region never
reads them, since a result's keys are not arguments.

### Drawing a card's body yourself

A thirty-field result is a wall of JSON where a host wanted a table, or a
Expand Down Expand Up @@ -201,6 +218,23 @@ is the authority.
If a tool's schema carries an `x-summary` string (use `X_SUMMARY_KEY`), the card shows it on the
label instead of the raw tool name.

### A label filled from the call's arguments

A tool can name what this call does rather than what the tool is. An `x-summary-template`
string at the schema root (use `X_SUMMARY_TEMPLATE_KEY`), or a `summary_template` on the
tool's entry in the `data-tools-url` catalog, holds `{name}` placeholders that the call's
top-level arguments fill: `"Search orders for {query}"` called with `{ "query": "acme" }`
labels the card head, and the step-group row, *Search orders for acme*. django-spec-agents
0.31.0 and later emit both from `@tool(summary_template=...)`.

The schema's template comes first, then the catalog's. Each placeholder fills from an
argument that is a non-empty string, a finite number or a boolean. If any placeholder
cannot be filled (the argument is missing, empty, nested or an array or object; the name is
dotted; or the template has a stray brace), the label is the static one, through the chain
above, never a half-filled sentence or literal braces. A filled value is set as text, so
markup in an argument shows as the characters it is. A tool without a template labels
exactly as before.

Every card leads with a **status icon** drawn entirely in CSS — a spinning ring while the call
runs, then a check / cross / slash / dotted ring on success / error / decline / not finished.
Re-theme it via custom properties (or the `tool-card-icon` part): `--ag-ui-tool-icon-done`,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@artooi/agents-web-components",
"version": "0.19.0",
"version": "0.20.0",
"description": "Framework-free <ag-ui-chat> Web Component over the AG-UI protocol. Drop-in chat sidebar with a pluggable client-side tool registry, DOM driver primitives, animations, and destructive-action confirmation modal.",
"type": "module",
"main": "./dist/index.js",
Expand Down
52 changes: 52 additions & 0 deletions scripts/record_summary_template_fixture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python
from __future__ import annotations

import json
import sys
from importlib.metadata import version
from pathlib import Path

import django
from django.conf import settings

settings.configure(INSTALLED_APPS=[], USE_I18N=False)
django.setup()

from django_spec_agents import ToolRegistry, build_tool_catalog, tool # noqa: E402

OUT = Path(__file__).resolve().parent.parent / "tests" / "fixtures" / "summary_template.json"

registry = ToolRegistry()


@tool(registry, summary="Search orders", summary_template="Search orders for {query} in {status}")
def search_orders(query: str, status: str = "open", limit: int = 10) -> list[str]:
"""Find orders matching a query."""
return []


@tool(registry, summary="Tag a record", summary_template="Tag {record} with {tags}")
def tag_record(record: str, tags: list[str]) -> str:
"""Tag a record."""
return record


@tool(registry, summary="Ping")
def ping() -> str:
"""Check the server is up."""
return "pong"


def record() -> dict[str, object]:
"""The catalog and the client-tool schemas, both as django-spec-agents builds them."""
return {
"generator": "scripts/record_summary_template_fixture.py",
"djangoSpecAgents": version("django-spec-agents"),
"catalog": build_tool_catalog(registry),
"schemas": {binding.spec.name: binding.input_schema for binding in registry},
}


if __name__ == "__main__":
OUT.write_text(json.dumps(record(), indent=2) + "\n")
sys.stdout.write(f"wrote {OUT.name}\n")
65 changes: 65 additions & 0 deletions scripts/record_tool_arguments_fixture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python
from __future__ import annotations

import datetime
import json
import sys
from importlib.metadata import version
from pathlib import Path
from typing import Annotated, Literal

import django
from django.conf import settings

settings.configure(INSTALLED_APPS=[], USE_I18N=False)
django.setup()

from django.db import models # noqa: E402
from pydantic import Field # noqa: E402

from django_spec_agents import ToolRegistry, build_tool_catalog, tool # noqa: E402

OUT = Path(__file__).resolve().parent.parent / "tests" / "fixtures" / "tool_arguments.json"

registry = ToolRegistry()


class Status(models.TextChoices):
OPEN = "open", "Awaiting reply"
DONE = "done", "Closed"


@tool(registry, summary="File a ticket")
def file_ticket(
due_date: datetime.date,
status: Status,
customer_ref: Annotated[str, Field(title="Customer")],
mode: Literal["fast", "slow"] = "fast",
trace_id: Annotated[str, Field(json_schema_extra={"x-hidden": True})] = "",
reminder_at: datetime.datetime | None = None,
follow_up: Status | None = None,
query: str = "",
) -> str:
"""File a support ticket."""
return "filed"


@tool(registry, summary="Ping")
def ping(note: str = "") -> str:
"""Check the server is up."""
return "pong"


def record() -> dict[str, object]:
"""The catalog and the client-tool schemas, both as django-spec-agents builds them."""
return {
"generator": "scripts/record_tool_arguments_fixture.py",
"djangoSpecAgents": version("django-spec-agents"),
"catalog": build_tool_catalog(registry),
"schemas": {binding.spec.name: binding.input_schema for binding in registry},
}


if __name__ == "__main__":
OUT.write_text(json.dumps(record(), indent=2) + "\n")
sys.stdout.write(f"wrote {OUT.name}\n")
7 changes: 7 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@ export const X_CONFIRM_KEY = "x-confirm";
*/
export const X_SUMMARY_KEY = "x-summary";

/**
* Schema-root key holding a label with `{name}` placeholders (e.g.
* `"Search orders for {query}"`), filled from the call's top-level arguments.
* A placeholder the arguments cannot fill shows the static label instead.
*/
export const X_SUMMARY_TEMPLATE_KEY = "x-summary-template";

/**
* Schema-root key marking a tool as navigating — its handler triggers a full
* page reload. The element checkpoints the call before the reload and resumes
Expand Down
2 changes: 2 additions & 0 deletions src/core/ag_ui_chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,8 @@ export class AgUiChat extends HTMLElement {
resolveTool: (name) => this.#tools.resolve(name),
toolSummaries: () => this.toolSummaries,
serverSummary: (name) => this.#tools.summary(name),
serverSummaryTemplate: (name) => this.#tools.summaryTemplate(name),
argumentDisplays: (name) => this.#tools.argumentDisplays(name),
toolDisplay: () => this.toolDisplay,
toolGroupDisplay: () => this.toolGroupDisplay,
// A thunk over the live property, not the property itself: the card keeps
Expand Down
Loading