Confidence
An answer with how sure the agent is, the evidence for and against, and what would change its mind, so the user can ask it to verify or accept.
≈ 1,338 tokens per use (tool 771 · guidance 314 · typical payload 253)How token costs are estimated
Example: Confidence
Why did Fernhill Labs’ churn risk jump this week?
Fernhill’s churn risk appears to have risen because active seats fell about 40% after the pricing change on the 2nd. Billing and their support threads agree, but the usage export is a day old.
When to use
- The user will act on a claim the agent isn't fully sure of: a cause, a diagnosis, a figure pieced together from several sources.
- The sources disagree, are stale or thin, and the user should see that before relying on the answer.
- The agent could check further (fresher data, another source), but it costs time, so the user should decide.
When not to use
- The answer is a plain fact the agent is sure of. Just answer.
- The uncertainty is in guesses the user could correct, such as party size or budget. Use Assumptions.
- The point is where each sentence came from. Use Citations.
How the agent should use it
- Set
levelhonestly from the evidence (high,medium,low) and hedge theclaimto match. Put the hedge words inhedges; they're underlined in the claim. - Keep
reasonto one short line, such as "2 sources agree, 1 is stale". It sits next to the level; the detail goes inevidence. - Include evidence against whenever it exists.
sourceandurlcome from tool results, never from memory. - Give
changeMindas concrete checks, especially at low and medium: what fresh data would move the level. - Name the check in
verifyLabel("Check live usage", "Pull full logs"). SetcanVerify: falsewhen there's nothing more to check. - Only send
scoreif a tool or calibrated model produced it. The level is enough on its own. - On
verify, check further and show a new confidence card with the updated level. Onaccept, carry on with the answer.
Interaction
- The level shows as three bars and a label; colour marks high and low only. A low level adds a "Treat this as a hypothesis" line and opens the evidence.
- Evidence is a disclosure listing what supports the claim, what cuts against it, and what would change the agent's mind.
- Verify and Accept are pill buttons; Verify is the primary one at low confidence. After either, the buttons are replaced by a record, which takes focus and is announced.
- While streaming, the claim, level and evidence arrive in turn and the buttons are disabled. A
resultfrom history restores the record without callingonResult.
Installation
npx shadcn@latest add https://your-site.com/r/confidence.json
Usage
import { tool } from "ai"
import { confidenceTool } from "@/components/genui/confidence.schema"
const tools = {
[confidenceTool.name]: tool({
description: confidenceTool.description,
inputSchema: confidenceTool.inputSchema,
}),
}import { Confidence } from "@/components/genui/confidence"
function ToolPart({ part, addToolResult }) {
if (part.type !== "tool-show_confidence") return null
return (
<Confidence
{...part.input}
status={part.state === "input-streaming" ? "streaming" : undefined}
result={part.state === "output-available" ? part.output : undefined}
onResult={(result) =>
addToolResult({
tool: "show_confidence",
toolCallId: part.toolCallId,
output: result,
})
}
/>
)
}The result tells the agent what the user chose:
{ action: "verify" } // check further, then show an updated card
{ action: "accept" } // carry on with the answerSchema
| Prop | Type | Notes |
|---|---|---|
question | string? | Shown above the card |
claim | string | The answer, up to 400 characters |
level | "low" | "medium" | "high" | How sure the agent is |
reason | string | One line next to the level, up to 120 characters |
score | number? | 0–100. Data-bound; omit unless a tool produced it |
hedges | string[]? | Up to 4 words from the claim to underline |
evidence | { id, stance, text, source?, url? }[]? | Up to 8. stance is for or against; source and url are data-bound |
changeMind | string[]? | Up to 4 things that would change the agent's mind |
verifyLabel | string? | Verify button label. Default Verify |
canVerify | boolean? | false offers only Accept. Default true |
Host props: status (streaming, ready), onResult, result and className.
Source
Checkpoint
The restore points of a long agent run, with the current one marked. Roll back to an earlier one after a confirm step, or continue.
Handoff
The agent hands a task to a person or another agent, with the reason, the context it passes on, what's done and what's left, and a note the user can edit.