Repository navigation
Backlog
Labels
post-mvpExpansion after the usable API workflow; no AppExchange prerequisite
Description
Part of #1528. Needs #1530. Can run in parallel with #1531, coordinating on frontend/src/lib/genui/library.ts.
Why
The route is where the model learns the library, and where tool results reach the browser.
How
- System prompt. It is made of three parts:
- the existing grounding rules (
systemPrompt()infrontend/src/lib/assistant/tools.ts, with the V9 branch unchanged); library.prompt({ preamble, additionalRules, examples });- the binding rules: data comes only from this conversation's tool results, so reference them, and never restate a row or a number.
- the existing grounding rules (
- A new SSE event,
result.- Its payload is
{ id: tool_use_id, name, result }, emitted after each tool runs. - It carries exactly what the model receives, including the same 40 KB cap.
- The browser keeps the results per turn. The
toolevent stays as the citation.
- Its payload is
- A flag:
ERWEB_ASSISTANT_GENUI_ENABLED. With it off, the prompt and behaviour are unchanged byte for byte, and the existing assistant tests intests/functional/grow.spec.tspass untouched. - Harden the loop (
claude-apiskill).max_tokens. Raise it from 1500, which cannot hold a program with a table and a chart. The route already streams.- Prompt caching. Tools and system are stable per (role, flag). Put a
cache_controlbreakpoint after the system prompt. Verify thatusage.cache_read_input_tokens > 0from the second round on, and record it in the PR. - Stop reasons.
max_tokens: emitdonewith a truncation flag the UI shows.refusal: show a plain message rather than an empty turn.
- Effort. Set
output_config.effortexplicitly; Live eval set for generated answers: parse rate, grounding, correctness, cost per answer #1536 picks the level. - Tool definitions. Set
strict: true, and validate inputs beforeexecuteTool.
- Metering.
tokensFrom()infrontend/src/lib/usage/record.tssums onlyinput_tokens + output_tokens. With caching on, most of the prompt moves tocache_read_input_tokensandcache_creation_input_tokens, so metered usage would quietly fall.- Decide how cached tokens are metered: counted in full, or as their own figure.
- Change
tokensFromto match, with a unit test that fails on the current behaviour.
- Model. Its default does not change here. Live eval set for generated answers: parse rate, grounding, correctness, cost per answer #1536's eval decides whether the default for
ERWEB_ASSISTANT_MODEL(claude-opus-5today) moves.
Acceptance criteria
- Unit: prompt assembly gives the same bytes for the same role and flag. That is the precondition for caching.
- Unit:
resultevents carry exactly what the model saw, including truncation. - Unit:
tokensFromcounts cached tokens per the decision above. - Functional, scripted in
tests/mock-erserver/server.mjs:- an OpenUI Lang answer with a bound table streams through;
- a
max_tokensstop and arefusaleach produce their message.
- With the flag off, the existing assistant specs pass unchanged.
- The PR body shows cache-read tokens observed against the real API in dev.
-
make frontendpasses.
Metadata
Metadata
Assignees
Labels
post-mvpExpansion after the usable API workflow; no AppExchange prerequisite
Activity