ADR-0038: More tools: remote MCP, httpTool, web search, and approving a call
- Status: Accepted on 2026-11-30 by the maintainer, with every recommendation of the first draft (see "Settled with the maintainer"). Built by one task per part (decision 6); where building differs, "As built in 0.8-t1", "0.8-t2", "0.8-t3", "0.8-t4" and "0.8-z1" say so.
- Date: 2026-11-29
- Related: ADR-0004 (the client never chooses tools), ADR-0015 and ADR-0030 (a button the server acts on), ADR-0017 (tool cards), ADR-0022 (
toolResults), ADR-0025 (retrieval as a tool), ADR-0026 (provider path), ADR-0028 (the React budget). Decided in task 0.8-x5; approving a call is built after 0.8-b1.
Context
A bot today reaches the outside world only through defineTool: a server-side function with a strict Zod schema, a timeout (default 10 s, at most 120 s), a 16,000-character output cap, arguments re-validated before execute runs, and results that never reach the browser except through replies and ui. THREAT_MODEL.md (T6, T11) still says: don't give an anonymous bot tools with side effects, "not supported yet".
Sites ask for four things that build on it:
- Tools from a remote MCP server they already run or buy (a CRM, a booking system, a docs server), without wrapping each tool by hand.
- Calling their own HTTP API in a few lines ("order status", "opening hours of a branch"), without writing
fetch, timeouts and size checks each time. - The web as a fallback when the bot's documents have nothing, for questions like "is the A4 closed today".
- A visitor approving a call before it runs ("Book a demo for Tuesday 10:00?" with Approve and Decline), which is what makes tools with side effects acceptable at all.
Each one moves data across a new boundary: to a third-party server, to the app's API, to a web search, or into a button the server acts on. The rules that bound the design:
- ADR-0004: the client never chooses the model, instructions, tools or identifiers; every endpoint has limits and budgets; no content or PII in logs.
- ADR-0022 and ADR-0025, decision 6: what a tool returns is third-party data; retrieved text is always wrapped as untrusted.
- ADR-0015 and ADR-0030: a click is a visitor message, with one exception (the handoff button). A button the server acts on needs its own ADR. This is that ADR, for a second action.
- CLAUDE.md: only
src/openai/importsopenai; raw OpenAI stream events never reach clients; the library hardcodes no model IDs and reads no files at runtime. - ADR-0028: a feature that grows the React entry makes room first. After 0.7 the entry has 501 B left of 34 KB and the headless case 86 B of 12 KB (measured on
mainat9cd7dfawith a local zlib; CI's zlib reads 538 and 86).
What the OpenAI API offers (checked 2026-11-29)
From the openaiDeveloperDocs MCP server and the types of openai 7.62.0, the version the package depends on:
- Remote MCP (MCP servers guide): a hosted tool
{ type: 'mcp', server_label, server_url | tunnel_id, allowed_tools, require_approval, authorization, headers, server_description, defer_loading }. OpenAI's servers call the MCP server (Streamable HTTP or HTTP/SSE), list its tools into anmcp_list_toolsitem and record each call, arguments and output, as anmcp_callitem.allowed_toolstakes names or a filter (tool_names,read_onlyfrom the server'sreadOnlyHint).require_approvalisalways(the default),neveror a filter; an approval arrives as anmcp_approval_requestitem and is answered with anmcp_approval_responsein the next request.authorizationis not stored by OpenAI and must be sent with every request. No fee per call beyond tokens. The guide's own warnings: a malicious server can exfiltrate anything in the model's context, servers may change their tools without notice, and data sent to an MCP server follows that server's retention and residency, not OpenAI's.connector_idis deprecated for models released after 2026-09-01. - Web search (web search guide):
{ type: 'web_search', filters: { allowed_domains | blocked_domains } (up to 100), search_context_size, user_location, external_web_access }. The answer cites withurl_citationannotations (URL, title, position), and the guide requires an interface that shows web results to show the citations as "prominent, clickable links".include: ['web_search_call.action.sources']lists every URL consulted. Withtool_choice: 'auto'the model may skip the search.max_tool_callsonresponses.createcaps built-in tool calls per response, acrossfile_searchandweb_searchtogether. - Cost (pricing, Tools table): web search is $10 per 1,000 calls plus the search content tokens at the model's input rate (a fixed 8,000-token block per call for
gpt-4o-miniandgpt-4.1-mini).file_searchis $2.50 per 1,000 calls. - Residency (data residency): both "Responses Web Search" and "Remote MCP server tool" are eligible for regional storage in every listed region and regional processing only in the United States and Europe; hosted tools aren't available for regional processing in Australia, India and Japan.
Decision
1. Remote MCP: askdare is the MCP client, in an add-on
askdare calls the MCP server itself and turns each allowed tool into an ordinary askdare tool. It doesn't use OpenAI's hosted mcp tool (settled question 1). The hosted tool would save the client code, but the call would happen between OpenAI and the MCP server, out of askdare's reach: it couldn't apply the timeout, the output cap, the untrusted wrapper (ADR-0025, decision 6), the per-day limits or the visitor's approval of decision 4, and the server's output would go straight into the model's context. It would also tie MCP to the OpenAI path (ADR-0026) and require the server to be reachable from OpenAI's network.
-
Where: a new add-on,
@boldare/askdare-mcp, so core gains no dependency. It depends on the official@modelcontextprotocol/sdkclient (pinned and reviewed like every dependency) and speaks Streamable HTTP only. The older HTTP+SSE transport is deprecated in the MCP specification and isn't supported. -
The API: a factory that returns tools for
defineBot({ tools }):import { mcpTools } from '@boldare/askdare-mcp'; const crm = mcpTools({ server: 'crm', // a label for logs and doctor, [a-z0-9_-] url: 'https://mcp.example.com/mcp', // https only (http://localhost outside production) headers: (context) => ({ authorization: `Bearer ${process.env.CRM_MCP_TOKEN}` }), allow: ['find_contact', { name: 'create_ticket', approval: true }], timeoutMs: 10_000, }); defineBot({ tools: [...crm, findSlots] });The tool names the model sees are
<server>__<tool>, so two servers can't collide with each other or with the bot's own tools;defineBotrefuses duplicates as it does today. -
Which servers: only those in the server's code, with a fixed URL. Neither the visitor nor the model can name a server, a URL or a tool outside
allow. -
Credentials stay on the server.
headersis a function of the tool context (bot, locale, the verified identity of ADR-0009), so a signed-in visitor's call can carry a token the app mints for that user; it is never filled from the model's arguments or the request. Headers are never logged, never reach the client and never go to OpenAI. OAuth flows of the MCP authorization specification are out of scope: the app passes a token it already has. -
The allowlist is required.
allownames each tool; a tool the server lists butallowdoesn't name doesn't exist for the bot. The tools' descriptions and input schemas come from the server'stools/list, cached per instance for 10 minutes; a listing that fails leaves that server's tools out of the turn and is reported once toonError. Because a server can change a tool's description or schema at any time,askdare doctorprints a fingerprint of each allowed tool's definition and warns when it differs from the one the app pinned inallow({ name, fingerprint }, optional; settled question 3). -
Arguments: an MCP schema is often not valid for OpenAI's strict mode, so these tools are sent with
strict: falsewhen the schema isn't strict-compatible, and the add-on validates the arguments against the listedinputSchemabefore the call. A tool whose schema it can't check is refused at listing time, with a doctor warning. -
The client declares no capabilities. No sampling, no roots, no elicitation: a server can't ask the model to write, read the app's files or prompt the visitor. Resource links and images in a result are dropped, never fetched.
-
Timeouts and size: each call has
timeoutMs(default 10 s, at most 30 s, below the turn's deadline), listing has 5 s. The result's text content (andstructuredContent, as JSON) goes through the same 16,000-character cap as every tool; over it, the call fails with askdare's own text. AnisErrorresult is a failed call, and the model sees askdare's fixed failure text, not the server's. -
Results are always untrusted: wrapped as
{"untrusted_tool_result": …}whatever the bot'stoolResultssays, assearch_knowledgeresults are, and the matching rule joins the instructions. -
Approval by default for tools that may write: a tool needs the visitor's approval (decision 4) unless the server annotates it
readOnlyHint: trueorallowsaysapproval: false. An annotation is the server's word, so the docs say to check it (settled question 4). -
doctorgainsmcp.reachable(initialize and list within 5 s),mcp.allowed(every name inallowexists) andmcp.changed(a pinned fingerprint differs).
2. httpTool: one endpoint of the app, as a preset over defineTool
httpTool builds a normal Tool (so replies, ui, timeoutMs and decision 4's approval work as they do), with the request built from validated arguments only. It lives in core (no dependency, fetch only) and is exported from @boldare/askdare next to defineTool.
const orderStatus = httpTool({
name: 'order_status',
description: 'Looks up the status of one of the signed-in customer’s orders.',
input: z.object({ orderId: z.string().regex(/^[A-Z0-9]{8}$/) }),
url: 'https://shop.example.com/api/orders/{orderId}',
headers: (context) => ({
authorization: `Bearer ${process.env.SHOP_API_TOKEN}`,
'x-customer': context.identity?.id ?? '',
}),
response: (body: { status: string; eta: string | null }) => ({ status: body.status, eta: body.eta }),
});- Method:
GETby default;POST,PUT,PATCHandDELETEtake abody: (input, context) => JSON. Any method other thanGETneeds the visitor's approval unless the tool saysapproval: false(settled question 5). - The URL template can't move the request elsewhere (no SSRF):
- the template is an absolute
https:URL (http://localhostoutside production), parsed once at definition; scheme, host, port and the path before the first placeholder are fixed, and placeholders aren't allowed in them; - a placeholder
{name}names a top-level field ofinputwith a string, number or boolean schema, checked at definition, so a typo fails at startup; - each value is filled with
encodeURIComponent, and an empty value,.or..fails the call, so a value can't add a path segment or climb out of the prefix; - after filling, the server checks that the URL's origin is the template's and its path starts with the fixed prefix, and refuses the call otherwise;
- query parameters come from an optional
query: (input, context) => Record<string, string>, set throughURLSearchParams; - redirects are not followed (
redirect: 'manual'); a3xxis a failed call.
- the template is an absolute
- Headers come from the server:
headers(context)as for MCP. Nothing from the visitor's request (cookies,Authorization,X-Forwarded-For) is forwarded. - The response: only a
2xxwith a JSON content type counts; anything else is a failed call, and the model sees{ "error": "http_error", "status": 404 }(the status only, never the body). The body is read up tomaxResponseBytes(default 64 KB, at most 1 MB) and the read is cut there.response(body, { status })shapes it into what the model sees; without it, the whole body goes on. The shaped result then takes the usual 16,000-character cap andtoolResultswrapping (it is the app's own API, sotoolResultsdecides, unlike MCP). - Timeout:
timeoutMs, default 10 s as for every tool, passed tofetchas anAbortSignaltogether with the turn's.
3. web_search: off by default, a fallback after the documents
-
A bot turns it on in
defineBot:defineBot({ knowledge: { index }, // or { vectorStoreId } webSearch: { when: 'fallback', // 'fallback' (default) | 'always' allowedDomains: ['gov.pl', 'example.com'], // optional, up to 100 contextSize: 'low', // optional: 'low' | 'medium' | 'high' liveAccess: true, // optional: external_web_access country: 'PL', // optional: user_location, never from the visitor limits: { perBotPerDay: 200, perVisitorPerDay: 10, perTurn: 2 }, }, });Without
webSearchthere is no web search, which is how a bot with regulated content keeps it off.web_searchbecomes a reserved tool name. The web search tool is OpenAI's hosted one (web_search, neverweb_search_preview), sowebSearchis refused at startup on a provider that has none (ADR-0026), anddoctorreports a regional endpoint where hosted tools aren't available (Australia, India and Japan today). -
when: 'fallback'offers the search only after the documents found nothing:- with the bot's own index (
search_knowledge, ADR-0025) this is enforced:web_searchjoinsallowed_toolsonly on the steps after asearch_knowledgecall in this turn returned no passages. The tool list stays the same on every step, so the prompt cache holds; - with an OpenAI vector store (
file_search), both searches run inside one response and askdare can't see the first one's results before the model may call the second. There,fallbackoffersweb_searchon every step with a rule in the instructions ("search the documents first; search the web only when they have nothing, and say the answer comes from the web"). It is a request to the model, not a guarantee, and the docs say so (settled question 6); - without a knowledge base,
fallbackis refused at startup; the bot sayswhen: 'always'.
- with the bot's own index (
-
Citations: the answer's
url_citationannotations already becomecitation { index, title, url }events inopenai/citations.ts, through the same http(s) check, so web sources show in the answer's source list as links, and the protocol doesn't change.web_search_callitems becometool.statusevents namedweb_search; the queries never reach the client. The source list counts as OpenAI's "prominent, clickable" citations, and the[n]markers stay text (settled question 8). -
Cost: a search costs a call fee and tokens. The token part is reserved like any turn: while a turn may still search, its reservation adds 8,000 input tokens per remaining allowed search, OpenAI's block for the small models and a fair estimate for the rest, and real usage replaces it at the end. The call fee isn't tokens, so it is bounded by count:
max_tool_callsis set toperTurnplus one forfile_searchwhen the bot has it, and the daily counters are checked beforeweb_searchis offered; an exhausted counter takes it out ofallowed_toolsuntil the next day.onUsagegetswebSearchCalls, so the app can price the fee, anddocs/costs.mdgets the arithmetic. -
Privacy: the visitor's question, rewritten by the model, leaves for a web search.
docs/privacy.mdsays so;onInputredaction (ADR-0022) runs before the model reads the message, so it covers the queries too.
4. Approving a call in the chat
-
Which calls: a tool says so in its definition.
approvalindefineTool(and so inhttpToolandmcpTools) takes a function that writes, from the validated arguments, the one sentence the visitor approves:defineTool({ name: 'book_demo', input: z.object({ day: z.string(), time: z.string(), email: z.string() }), approval: { summary: (input) => `Book a demo on ${input.day} at ${input.time} for ${input.email}` }, execute: bookDemo, });The summary is plain text, at most 200 characters, never Markdown, and shows only what the developer picked. It shows values the model chose, which is the point: the visitor checks them. A summary is required rather than a generic "Allow book_demo?", which tells a visitor nothing (settled question 13).
-
What happens in the turn:
- The model calls an approval tool. The server validates the arguments as for any call, does not run the tool, and leaves the call without output. Other calls of the same step run as usual.
- It sends
tool.approval { messageId, callId, name, summary, handle }and ends the turn. The answer shows the model's text, if it wrote any, and the card. handleis encrypted withCHAT_SECRETlike a form handle (ADR-0031), bound to the bot, the visitor or signed-in user, the conversation, the call ID and a SHA-256 of the arguments as stored, and expires after 10 minutes (settled question 12).- The visitor answers. Approving or declining posts to the turn endpoint,
POST /messages, withapproval: { handle, approve }in place ofmessage(settled question 9). It is a turn like any other: the same limits, budgets, conversation lock and stream. - The server checks the handle and reads the call's arguments from the stored conversation, never from the request, and checks their hash. Approved: the tool runs with them and its output answers the call. Declined: the call is answered with askdare's fixed
{"status":"declined"}. Then the model continues and writes a new answer, so a decline gets a reply too (settled question 10).
-
Only one approval per turn. A second approval call in the same step, or a later step, is answered with
{"status":"one_at_a_time"}and doesn't show a card (settled question 11). -
What the model sees while it waits: nothing; it isn't running. The approval tool's description, sent to the model, ends with a fixed sentence: the visitor approves the call in the chat before it runs, and the output says whether they did.
-
A turn that ends unapproved: if the visitor writes a message instead, or the handle expires, the next turn answers the open call with
{"status":"not_approved"}before the visitor's message. Today's repair of a call left without output (ADR-0015,danglingCallId) is the path; for approval tools it writes this output instead of the generic one. A handle used twice, or after its call has an output, answers409, like a form sent twice. -
History: a message gets an optional
approval: { callId, name, summary, state }rebuilt from the stored call:pending(no output, with a fresh handle while the 10 minutes last),approved(any output but askdare's fixed ones),declinedorexpired(not_approved). The summary is derived again from the stored arguments with the tool's currentapproval.summary, asuipayloads are. -
The default UI: a primitive
ToolApproval(parttool-approval, with buttons in partsapproveanddecline,data-state), shown under the answer's text in the default skin, with the summary as the group's label. Its texts areapproval.approve,approval.decline,approval.approved,approval.declinedandapproval.expired, in the bot's dictionary per language. The buttons are disabled while a turn runs and once answered. The iframe renders the same primitive, so approval works in the script-tag widget too, unlike tool cards. -
The client:
ChatMessage.approval, set by the reducer, andactions.approve(handle, approve), which runs the store's existing send path with a different body. The parts that read the stream don't change.
Size. Measured on main by removing the closest feature, the handoff's client side (its event, reducer case, action and two primitives): it costs 141 B in the headless case and 272 B in the React entry (gzipped, the same script). Approval has the same pieces, with a larger event (four fields), a history field and a card with two buttons and four states, and its action reuses the send path. The estimate:
- headless case: about +200 B (+150 to +250);
- React entry: about +500 B in all (+350 to +650), the headless part included;
- texts come with the bot's public configuration, so they cost the bundles nothing.
That doesn't fit the 86 B and 501 B left. 0.8-b1 must free at least 300 B in the headless case and 900 B in the React entry first, which keeps about 100 B and 400 B of headroom for marked patches (ADR-0028). b1's targets, 600 B and 1,536 B, cover it. If b1 falls short, the approval task stops and a budget ADR decides; it doesn't raise a budget on its own. The implementing task measures again and writes the real numbers into this ADR.
5. Limits and logs for every remote call
- Per turn:
limits.remoteCallsPerTurn(default 5) countshttpTooland MCP calls in one turn; past it, a call fails with askdare's text, as the step limit does. Web search has its ownperTurn. - Per day:
limits.remoteCalls: { perBotPerDay: 1_000, perVisitorPerDay: 100 }in the existing rate-limit store (memory or Upstash), keyed as handoff limits are (ADR-0030, decision 7), and web search's own counters (decision 3). A call is counted when it starts, and a failed call stays counted. When a bot's daily count runs out,onErrorgets one report a day, without IPs. - Logs and hooks: askdare logs no arguments, results, filled URLs (a path can hold an email), headers, MCP output or search queries. The tool calls in
onUsage(ChatToolCallReport) keepname,durationMsandoutcomeand gainkind(function,http,mcp,web_search) and, for HTTP, the status code. Errors are reported by class name and status code only, never the remote server's text.
6. Order of building, one task each
httpTool ──┐ (core, no protocol change)
web_search ┴─→ approval (after b1) ─→ remote MCP add-on
httpToolwith the limits and logs of decision 5: server-only, no protocol change. Until approval lands, a non-GEThttpToolneedsapproval: falsewritten out.web_search, beside it:bot/define-bot.tsandopenai/only.- Approving a call, after 0.8-b1:
defineTool, the protocol,chat/*and the React primitives (the 0.8 hot files). - Remote MCP last: a new add-on that uses the limits and, for tools that write, the approval.
bot/define-bot.ts takes model settings (ADR-0036), prompt versions (ADR-0039) and then webSearch, in that order, as ROADMAP.md plans.
As built in 0.8-t1
Amended on 2026-11-30 (task t1, httpTool and the remote call limits), where the code differs from or adds to decisions 2 and 5:
- How a tool says it is remote: a public
kindondefineToolandTool,'function' | 'http' | 'mcp'(ToolKind, defaultfunction).httpToolsetshttp; the MCP add-on (0.8-t4) setsmcpthroughdefineTool({ kind: 'mcp' }), so it needs nothing internal.httpandmcpcalls count against the remote call limits, and their failures are logged by error class only. AnydefineToolthat calls a server itself may saykind: 'http'. For z1:ToolKindandTool.kindare new public API next tohttpTool's types (HttpToolDefinition,HttpToolMethod,HttpToolQueryValue) andRemoteCallLimits. - The HTTP status reaches the usage report through an internal symbol on the tool
httpToolbuilds, not throughexecute. Called directly, anhttpTool'sexecutereturns the shaped body or throws an error that names the outcome and status only. - Decision 2, the template: besides the rules above, the template may have no credentials, query, fragment, backslash or whitespace, and its path must be written as a URL keeps it (no empty,
.or..segments, nothing that needs encoding), so the filled URL is compared with what the URL parser makes of it.http:works forlocalhost,127.0.0.1and[::1], outside production. A placeholder may also name an enum or literal field; not a nullable one. A value with/,\or%fails the call as.and..do (the security review's hardening): encoded, it would stay in its segment for askdare, but a server or proxy that decodes the path before routing it would read more segments, or.., into it. - Decision 2, the response: a
204 No Contentor205 Reset Contentcounts, withnullas the body, since aDELETEoften answers with one.query,headers,bodyandresponsemay be async; aresponsethat throws fails the call, and the report keeps the status. A2xxJSON body that doesn't parse fails ashttp_errorwith its status; a body overmaxResponseBytesfails with the tool's "too much data" text. The request is sent withcache: 'no-store', so a framework's fetch cache never answers one visitor with another's result. - Decision 2, approval:
approvalonhttpTooltakes onlyfalseuntil 0.8-t3 adds the approval of decision 4. - Decision 5, the counts:
limits.remoteCalls.perTurnis counted in the turn; the daily counters per visitor or user, per IP (bothperVisitorPerDay) and per bot are taken when the call starts, after its arguments were validated, and refunded together when one refuses it, as handoff's are. A call refused by the turn's limit takes nothing from the day. The console's playground counts like a visitor;askdare evalcounts against the bot's daily count only (ADR-0035, decision 4). A rate-limit store that fails refuses the call. The kill switch refuses every remote call. - Decision 5, the report:
ChatToolCallReport.kindis required (every report since 0.8 has it) andstatusis set forhttpcalls whose server answered, failed ones included.
As built in 0.8-t2
Written at the release (task y1, 2026-12-01) from t2's hand-over, where web search as built differs from or adds to decision 3:
- Where it lives:
webSearchindefineBotwith its ownlimits(perTurn,perVisitorPerDay,perBotPerDay), not inBotLimits; the types areWebSearchConfigandWebSearchLimits.fallbackon a bot withoutknowledgeis a setup error, andweb_searchis refused as a tool name. - The report: web searches aren't function calls, but they join
onUsage'stoolswithkind: 'web_search'(name, duration and outcome, never the query), andChatUsageReport.webSearchCallscounts the searches OpenAI billed. The admin records don't carry the count, so the dashboard's costs leave the search fees out. doctor's regional check names four endpoints without hosted web search on 2026-11-30: Australia, India, Japan and, new since this ADR was written, the United Arab Emirates.- The widget shows a search as any tool's status (
status.tool, "Using web_search…"); a text of its own, such as "Searching the web…", needs the chat's texts and is left for later. - Not verified live (the smoke project had no credit):
{ type: 'web_search' }insideallowed_toolson the fallback's later steps,max_tool_callsbounding the searches, and the stream's shape. Unit tests use streams built from the web search guide;src/openai/web-search.smoke.tsrecords the real fixture (testing/fixtures/web-search.sse) withSMOKE_RECORD=1. - Checked live at the release (y1, 2026-12-01,
gpt-6-luna):web-search.smoke.tspassed: the first step offered onlysearch_knowledge, which found nothing; the second offeredweb_searchwithmax_tool_calls: 1, which OpenAI accepted and kept to (one search with two queries, billed once), and the answer cited the pages asurl_citations. The step's stream is recorded intesting/fixtures/web-search.sse(queries kept, safety identifier redacted) and replayed byrecorded.test.tsin both conversation modes.
As built in 0.8-t3
Amended on 2026-11-30 (task t3, approving a call), where the code differs from or adds to decisions 2 and 4:
- The API:
approvalindefineToolis{ summary },falseor absent (ToolApproval, andTool.approval).httpTooltakes the same; a method other thanGETneeds one of the two,{ summary }orfalse, and is refused at startup with neither. This replaces t1's interim "approval: falserequired"; aGETmay ask for approval too. The MCP add-on (0.8-t4) passesapprovalthroughdefineTool. - The summary is written from the validated arguments, then whitespace runs (line breaks included) become one space and control and format characters (bidi overrides, zero-width marks) go; what is left must be 1 to 200 characters (code points). A summary that throws or breaks that fails the call with askdare's "The tool failed.", logged by the tool's name only, never with the summary or the arguments. The browser checks the rule again (
isApprovalSummary, shared with the server's schemas). - Which call becomes the card: of a step's calls of approval tools, the first whose arguments fit and whose summary can be written. Earlier ones that fail are answered with their error; every later one, in the same step, gets
one_at_a_time. When its handle can't be issued, the card's call gets askdare's{"status":"approval_unavailable"}and still counts as the turn's card, so later calls getone_at_a_timetoo. The history picks the card the same way, from the stored calls, and shows none forapproval_unavailable, so a reload shows what the turn showed. One card per turn means one per answer: the turn that answers a card may show a new one. - Ending the turn: the step's other calls run, the forms of the step go out, and the step is stored before the card is sent: an item store records it with the other calls' outputs, an OpenAI conversation gets those outputs appended (as an answered
suggest_repliesis). The waiting call shows notool.status;tool.approvalis the answer's last event beforemessage.end. The asking answer offers no reply options and gets no rating handle (it is a question), and the history doesn't rate it either. - The handle is its own token type (
askdare-approval+jwt), bound to the bot, the visitor (its subject) or signed-in user (identityKey), the conversation, the call, the tool's name and the SHA-256 of the stored arguments. The 10 minutes start when the card is issued: the limits store keeps a 10-minute window per call (ask:ao:<pseudonym>), and a reload's handle lives only for what is left of it. Without the window (an in-memory store on another instance, a store that failed), the history shows the card asexpired. - The answer is
POST /messageswithapprovaland an emptytext, without attachments, and with the conversation's resume token. Before the stream starts, the server verifies the handle (404for a forged, expired or foreign one, or one of another conversation), applies the history's rate limit (the answers it refuses never reach the turn's limits, and each reads the store), reads the conversation's latest 100 items for the call (404when it isn't there, its name differs or its arguments' hash doesn't match;409with the keyerror.approvalAnsweredwhen it has an output), then takes a one-time claim in the limits store (ask:ac:<pseudonym>, 11 minutes;409when taken), then the turn's usual limits. A turn that ends before it answered the call (a lock, a failure, a visitor who left) gives the claim back, so the card can be answered again. - One turn at a time: a bot with an approval tool takes the conversation lock that output checks use (ADR-0022) for every turn, so a message can't close a call while an answer to it runs, and two answers can't interleave.
- In the turn, the answer stores no visitor message. An item store opens the turn by appending the call's output, at the version it read; an OpenAI conversation gets it as the request's input. Approved, the tool runs through the same path as any call (timeout, remote call limits, untrusted wrapping,
tool.status, itsuiandrepliesunder the new answer); declined, the output is{"status":"declined"}. A visitor message instead: an item store appends{"status":"not_approved"}for each approval call still waiting in its window before the message; an OpenAI conversation answers it in the repair path of a call left without output, which reads the conversation's latest 50 items to tell an approval call from an interrupted one. - The history splits a turn at the card's output: the card stays on the answer that asked (or on an answer with empty text and the call's item ID, when the model wrote nothing before the call), and the answer after the visitor's answer is a message of its own, with the approved call's cards and options.
approvedis any output but askdare'sdeclinedandnot_approved, the tool's failures included. - With output checks,
tool.approvalis held with the answer and dropped when the answer is replaced or withheld, so a card only shows under an answer the checks passed as it was; the history agrees. - The client:
actions.approve(handle, approve)runs the store's send path with the answer instead of a message, and shows the card's answer at once. A404before the next answer starts marks the cardexpired; a409(error.approvalAnswered) keeps what the visitor chose; another failure puts it back topending. A card still waiting when the next answer starts is markedexpired, as the server answers it; a message the server refuses leaves it waiting. Nomessage.sentevent fires for an answer to a card;message.receiveddoes for the bot's next answer. - Elsewhere: in the console's playground the turn ends at the card with a placeholder handle, and the card shows read-only, like a form there.
askdare evaldoes the same and counts the requested call intools(ADR-0035, "As built in 0.8-t3"). - Size, measured with
scripts/react-size.mjsand CI's zlib (Node 24): the headless case went from 11,675 to 11,996 bytes gzipped (+321 B; 292 of 12,288 left), the React entry from 33,221 to 33,747 (+526 B; 1,069 of 34,816 left) and the embed case from 12,438 to 12,759 (+321 B). The React entry landed on the estimate; the headless case went past it (+200, at most +250 estimated), because the browser checks the summary's rule and the history's card like the event's, and the next answer marks a waiting card expired. It fits within the room 0.8-b1 made, with about 290 B left for the headless case, so no budget changes. - Not checked live (the smoke project had no credit): that OpenAI accepts a developer note (output checks) between a call and its output in a conversation, and the order of items when the answer is sent. If the model call after an approved tool fails before OpenAI stored its input, the tool ran but its output isn't in the conversation; the next message then tells the model it wasn't approved. An item store doesn't have this gap: it stores the output before the model call, under the conversation lock. Transcripts and admin records show an answer to a card as a turn with an empty
input; marking them is a follow-up. - Checked live at the release (y1, 2026-12-01,
gpt-6-luna, the site run locally withopenaiConversations()):book_call's card answered with Approve (the tool ran, the next answer confirmed it), Decline (the model answered that it didn't book), and a typed message instead (the card turned expired, the message got its answer); a reload showed the same three states from history. With a temporaryonOutputthat held an answer ending at a card, the answer and its card were withheld, and the next message got a normal answer: OpenAI accepted the developer note between the open call and itsnot_approvedoutput, with no 400.
As built in 0.8-t4
Amended on 2026-11-30 (task t4, the MCP add-on), where the code differs from or adds to decisions 1 and 5:
- The API:
mcpTools({ server, url, headers, allow, timeoutMs })returns oneToolperallowentry. An entry is a name or{ name, fingerprint?, approval? }, andapprovalis{ summary: (input) => string }orfalse, as settled with the maintainer on 2026-11-30: the decision'sapproval: truehad no place for the summary decision 4 requires. A tool that needs approval (the server doesn't sayreadOnlyHint: true) and has neither is left out of every turn, reported toonErrorand warned about bydoctor. Asummaryinallowmeans approval for every call, even of a tool the server calls read-only.serveris at most 32 characters; tool names with characters other than[A-Za-z0-9_-]can't be allowed, since the model's tool names can't hold them. - The SDK is
@modelcontextprotocol/client2.4.0, pinned: the client package of the SDK's version 2, which splits client and server.@modelcontextprotocol/sdk1.x would have pulled in Express, Hono and the server's other dependencies. The client brings@modelcontextprotocol/core,zod,jose(already in core's tree), andcross-spawn,eventsource,eventsource-parserandpkce-challengefor stdio, the old SSE transport and OAuth, which askdare doesn't use. Its two JSON Schema validators, Ajv and@cfworker/json-schema, are bundled in its build; askdare uses@cfworker/json-schema, which interprets a schema instead of compiling it to code and fetches no remote$ref. The tests run the SDK's server package (@modelcontextprotocol/server, a dev dependency) on a loopback port. - Core's hooks (minor changeset):
defineTooltakesload(context), run before each turn bystreamTurn(at most 6 s, a little more than the listing's 5 s), whoseLoadedTool(description, JSON Schema,strict, and the Zod schema that checks the arguments) replaces the tool's description and input for that turn, the compaction after it included; a tool that loads none sits the turn out, but still counts for the rule on wrapped results and for closing a call that waited for approval (the code review's fix), since its earlier calls are in the conversation.defineToolalso takesdiagnose(signal), whoseToolChecksdoctorshows once per function for a bot, failures first when the report's 20 checks per bot would be exceeded. A tool ofkind: 'mcp'always has its results wrapped, and the matching rule joins the instructions.LoadedTool,ToolLoadContextandToolCheckare new public types (for z1). The only change to a hot file is one hunk inserver/handler.ts's doctor report, in its own commit. - Connections: each listing and each call opens a connection and closes it after, so an MCP session is never shared and one visitor's headers never carry another's call. A listing is shared by every visitor, so
headersgets{ operation: 'list' }without a visitor; a call gets{ operation: 'call', tool, botId, visitorId, locale, identity, source }. Headers the transport sets (content-type,accept,host,mcp-session-id,mcp-protocol-versionand the like) are refused. Redirects fail the request (redirect: 'error'), requests skip any fetch cache, and each response is read up to 1 MB. The client declares no capabilities and turns off the SDK's automatic answers to input requests. - Listing: cached per
mcpToolscall, bounded at 5 s as a whole (headersincluded), and at most 32 pages; after a failure the server's tools sit out turns for 30 seconds before the next try, so turns don't wait on a server that is down.onErrorhears about a failure once until a listing succeeds, and about allowed tools that are missing or left out once per listing. A description over 4,000 characters, or a schema over 16,000 characters of JSON, leaves the tool out, since both sit in every turn's prompt. - Strict mode: a schema goes to the model with
strict: trueonly when every object is closed with all its properties required and it uses onlytype,properties,required,additionalProperties,items,enum,description,anyOf,$defsand local$refs (the guide's supported subset;titleandconstaren't in it), at most 5 levels deep; anything else goes withstrict: false. The$schemakeyword is dropped from the copy the model gets. - Results: the model gets
{ text, structuredContent, omittedContent }: the text blocks joined, the structured content as the server sent it, and how many other blocks were dropped. - Fingerprints are
sha256:and 32 hex digits (128 bits) of the SHA-256 of the canonical JSON of the tool's name, description, input schema andreadOnlyHint, what the model sees and what decides approval. Beyond decision 1'sdoctorwarning, a tool whose pinned fingerprint no longer matches sits out every turn until it is pinned again, as a pin is meant to stop a changed definition from reaching the model. doctor: per server,mcp.reachable(connect, initialize and list within 5 s, failing otherwise),mcp.allowed(a warning naming the missing tools),mcp.changed(a warning naming the changed ones), one warning for tools left out with why, and the fingerprints, four per line.- Not checked live: against a third-party MCP server, and OpenAI's acceptance of the schemas real servers list with
strict: false; a schema the API refuses would fail the bot's turns until the tool is taken out ofallow. - Checked at the release (y1, 2026-12-01):
src/mcp.smoke.tslisted DeepWiki's public server (https://mcp.deepwiki.com/mcp, Streamable HTTP, three tools), passeddoctor's checks, printed the fingerprints and loadedread_wiki_structureandread_wiki_contentsas a turn does. The turn on a real model, and with it OpenAI accepting the listed schemas, waits for the funded run intasks/0.8-y1-release.md. - And with a real model (y1, 2026-12-01,
gpt-6-luna): a turn asked about a repository's DeepWiki page, the model calledsmoke__read_wiki_structure, the call succeeded and the turn completed, so OpenAI accepted the server's listed schema.
As built in 0.8-z1 (the API review)
Amended on 2026-11-30 (task z1), as the maintainer settled before 0.8.0 shipped:
- Decision 5, the names: the per-turn limit is
limits.remoteCalls.perTurn, besideperBotPerDayandperVisitorPerDayinRemoteCallLimits, so the remote call limits are named aswebSearch.limitsare. t1 built it aslimits.remoteCallsPerTurn, which never shipped, so there is no alias. Default and range are unchanged (5, 0 to 50). - Decision 4, the MCP add-on's approval:
McpAllowedTool.approvalis core'sToolApproval(with the arguments asReadonly<Record<string, unknown>>), exported from@boldare/askdare; the add-on's ownMcpApprovalis gone. - Decision 1, fingerprints: their format (
sha256:and 32 hex digits, over the name, description, input schema andreadOnlyHint) is public API (ADR-0006), since apps pin them inallow: changing it is a breaking change.
As built in 0.8.x: the last step says why
Amended on 2026-12-04, after the daily live smoke failed from 2026-12-01 with no change to askdare's code (model behaviour drift at OpenAI, gpt-6.1-terra):
- The loop: a bot with
handoff, a model form and a vector store, on its last step, sendsallowed_toolswith onlyfile_search. Asked for a person or an offer, the model searched the documents about 14 times in one response, spent itsmax_output_tokenson reasoning and ended without text.allowed_toolsrestricts the calls without telling the model why. - Decision 3,
max_tool_calls, doesn't bound it: the reference says calls past the maximum are "ignored", not refused. Sendingmax_tool_calls: 2shrank the input but the model kept trying (about 8 searches still visible) and the turn still ended atmax_output_tokens.maxToolCallsstays as it was: it bounds the web search fee, which is what it is for. - The fix: a last step that takes away functions the model could call before ends the instructions with one more rule (
lastStepRuleinopenai/tools.ts): no function can be called now, write the answer, say that a handover or a form can't happen in this answer and that the visitor can ask again, and, while a hosted search is left, search only for facts. Measured: 3.4k input tokens instead of about 22k, about 160 output tokens, 10 s instead of 45–50 s, with the price from the documents and the sentence about the person and the form. - The prompt cache: every other step keeps its instructions as they were, and the rule goes last, after everything the steps share. On models before GPT-6.2 the instructions start the prefix, so a last step that follows earlier steps misses the cache from there on, once per turn that reaches it; a bot with
maxSteps: 1sends the rule on every turn, so its prefix stays stable. From GPT-6.2 the API puts top-levelinstructionsafter the input (keep the prefix unchanged), so nothing changes in the prefix at all. A developer message appended toinputwould keep the prefix on every model, but with a conversation store at OpenAI it would be stored in the conversation and read back on later turns, where the functions are available again.
Consequences
- New public API (ADR-0006, when each part ships):
httpTooland its option types;webSearchindefineBot, the reserved tool nameweb_search,webSearchCallsin the usage report;approvalindefineTool; thetool.approvalevent, theapprovalfield ofPOST /messagesand of the history response (additive in protocol version 1);ChatMessage.approvalandactions.approve; theToolApprovalprimitive, its parts and theapproval.*texts;limits.remoteCalls(perTurn,perBotPerDay,perVisitorPerDay), andkindandstatusinChatToolCallReport;@boldare/askdare-mcpwithmcpTools, and threedoctorchecks.
- Tools with side effects become possible for an anonymous bot, with the visitor's approval. Approval is consent, not authentication: the tool still decides whose account it acts on from the verified identity, never from the arguments, and the docs say so.
THREAT_MODEL.mdT6 and T11 change their "not supported yet" when approval ships. - A turn can end in the middle of a step for the first time, with a call left open until the visitor answers. The repair path for open calls becomes part of normal operation, not only of aborted turns.
- Approving or declining costs a model call. It counts against the visitor's message limits like a typed message.
- MCP costs an add-on and a dependency, and the app's server makes the calls, so the MCP server must be reachable from it (not from OpenAI). It works on every provider path.
- A web search costs about 1 cent plus up to 8,000 input tokens. With the defaults, at most 200 searches a day per bot, about $2 in fees plus tokens.
- Web search sends the visitor's question, rewritten, to a search provider. It is off by default; turning it on is the bot owner's decision, for the privacy notice.
- The
fallbackof web search is only a request to the model on vector-store bots; it is enforced only with the bot's own index. - The React entry and the headless case grow by about 500 B and 200 B, after b1 has made room.
Settled with the maintainer (2026-11-30)
The first draft left these questions open, each with a recommendation. The maintainer accepted all fifteen as recommended ("Yes, accept all"), and the decisions above are written that way.
- MCP through OpenAI's hosted tool, or askdare as the client? Settled: askdare as the client (decision 1). The hosted tool is less code, but takes the timeout, output cap, untrusted wrapper, limits and approval out of askdare's hands and works only at OpenAI.
- MCP in an add-on with the official SDK, or a small client in core? Settled: the add-on
@boldare/askdare-mcpwith@modelcontextprotocol/sdk. Core stays without a dependency, and the protocol's session and transport details aren't ours to maintain. - MCP tool definitions from the server at runtime, or pinned in the app's code? Settled: from the server with a required allowlist, a 10-minute cache and an optional fingerprint per tool that
doctorcompares. Pinning whole definitions in code duplicates the server and goes stale silently in the other direction. - Which MCP tools need approval by default? Settled: all but those the server marks
readOnlyHint: true, overridable per tool inallow. - Does a non-
GEThttpToolneed approval by default? Settled: yes, unless the tool writesapproval: false. when: 'fallback'on a vector-store bot: a rule in the instructions only, or not offered? Settled: the rule, documented as a request to the model. Enforcing it would take a second response after an answer was already streamed.- Web search off by default? Settled: yes, a bot turns it on, and
whendefaults tofallback. - Is the source list enough for OpenAI's "prominent, clickable" citations? Settled: yes for now, since every web source shows as a link right under the answer; the
[n]markers stay text. Linking the markers costs React bytes; we do it if OpenAI's terms say the list isn't enough. - Answer an approval through
POST /messages, or a new endpoint? Settled:POST /messageswith anapprovalfield. It reuses the stream, the limits, the lock and the client's send path, which is why the approval fits in about 200 headless bytes. A separate endpoint would duplicate all four. - Does a decline run a model call? Settled: yes, so the bot replies ("All right, I didn't book it") and the transcript reads naturally. Ending without a model call is cheaper but leaves a call output without an answer and needs a second response shape.
- One approval per turn, or several cards? Settled: one. Several cards in one answer make the visitor approve things they didn't read, and the state and UI stay simple.
- How long is an approval handle valid? Settled: 10 minutes. An action approved much later may no longer be what the visitor wants (a slot taken, a price changed); the model can ask again.
- A required
approval.summary, or a generic card? Settled: required. A visitor can only consent to what the card says. - The default limits: 5 remote calls per turn, 1,000 per bot and 100 per visitor a day; web search 2 per turn, 200 per bot and 10 per visitor a day. Settled as written; a bot sets its own.
- The order:
httpTooland web search side by side, then approval after b1, then MCP. Settled as in decision 6.
Alternatives considered
- OpenAI's hosted MCP tool, with its
require_approvalmapped onto the visitor's card. Less code and no dependency, but see settled question 1. The approval would also arrive as anmcp_approval_requestinside a response, a second approval mechanism beside decision 4's. - An MCP proxy or gateway in front of every server, run by the app. That is the app's choice, and
mcpToolsworks with one; askdare shouldn't require it. httpToolwith a free URL argument and a host allowlist. The model would build URLs, and every encoding trick (..,%2F,@, IPv6 literals, redirects) would need its own rule. A fixed template with filled values removes the class.- Web search always on, with a rule in the instructions. Cheaper to build, but every question could cost a search fee and send the question to the web, including on bots with regulated content.
- Searching the web before the turn, when the index finds nothing. It would search with the visitor's raw words, without the model's reading of the question, and pay a search on every miss, including small talk.
- Approval without a model call: the server runs the tool and shows the result as a card. The model would never see the result and couldn't answer about it.
- A generic "confirm" reply option (ADR-0015) where the visitor types "yes". The model would have to decide whether "yes" approves the call, and a prompt injection could too; a sealed handle bound to the call and its arguments leaves no doubt.
- Approval handled by the app's
execute(for example, a confirmation email). Still possible and sometimes better for high-value actions; decision 4 covers the common case in the chat.