Add per-tool `ui_visibility` so UI adapters can keep tool results from the client

Merged
DS
8d ago
+3270-196

This pull request was posted by Claude Code using claude-opus-5-5 on behalf of David.

Closes #10696

Why we make these changes

AGUIEventStream and VercelAIEventStream stream every tool call's arguments and full return to the client, and both adapters' dump_messages write the full return, so a server-side tool's result can't stay on the server. Following DouweM's decision, visibility lives on the tool, with an adapter default. Thanks @rscholz98 for the end-to-end repro and for pushing the design forward.

#14377 is a separate opt-in mode in which only posted content leaves the server, so it doesn't need per-tool visibility; this PR covers the default mode, where the adapters render the agent's own history.

New public surface

  • ToolUIVisibility (Literal['public', 'redacted', 'private']) in pydantic_ai.tools and pydantic_ai.messages
  • ToolDefinition.ui_visibility, and ui_visibility= on Tool, Agent.tool/tool_plain, FunctionToolset and its tool/tool_plain/add_function, Capability.tool/tool_plain
  • BaseToolCallPart.ui_visibility and BaseToolReturnPart.ui_visibility, the stamp the adapters read
  • UIAdapter.default_ui_visibility (also on from_request/dispatch_request), UIEventStream.default_ui_visibility, and default_ui_visibility= on AGUIAdapter.dump_messages/VercelAIAdapter.dump_messages

User-visible behavior

@agent.tool_plain(ui_visibility='redacted')
def get_chat_insights(chat_id: str) -> dict[str, str]: ...

Before, the client got the tool's full return. Now it gets the call and its arguments, with '[REDACTED]' as the result; 'private' sends neither. The model and the stored history still get the full return. Frontend and output tools stay public, and a 'private' tool that needs approval or defers at runtime is shown 'redacted'. Client-held history warns.

Deliberate choices

  • The adapter parameter is default_ui_visibility, not the decision's default_tool_visibility, which collides with models.ToolVisibility and ModelRequestParameters.tool_visibility. Confirmed.
  • ui_visibility covers a tool's call and its return value, not content attached with ToolReturn.content. That content reaches the model as a separate user message, and dump_messages sends it as one, so the docs put data the client must not see in the return value. This boundary is deliberate: a provenance field on UserPromptPart is the wrong shape. #14479 moves that content onto the tool's result; whichever of the two lands second makes 'redacted' drop it.
  • A response a capability supplies instead of the model's — from a wrap_model_request that doesn't call its handler, SkipModelRequest, or on_model_request_error — is stamped from the step's tool definitions like the model's own, in ModelRequestNode._finish_handling, _recover_model_request_error and the streamed short-circuit replay. Only ui_visibility is written there; those paths keep main's tool_kind typing, since execution already types the call (ToolManager._with_tool_kind).
  • A 'private' tool sends nothing tied to its call, including the events in its result's metadata, which a 'redacted' tool still sends. A 'private' tool that needs to update the client emits an event with ctx.emit().
  • A model that streams a 'private' tool's name in pieces gets that call and its arguments sent under the partial name when the partial name isn't stamped 'private': another tool's name the client is shown (lookup for lookup_secret), or a name no tool has (look) under a 'public' or 'redacted' default. Its result is never sent, and its stamp comes from the complete name. Holding tool-call events until the name is final is tracked in #14647.
  • ui_visibility covers a tool's result, including a failure it reports with ToolFailed or ModelRetry, not an exception that ends the run. The adapters send that exception's text as the run's error for every tool, as on main; tracked in #14648.
  • An enqueued tool exchange isn't stamped by the run: its author sets ui_visibility on the parts, as for any history the application builds itself.
  • A 'private' call that defers at runtime becomes 'redacted' through a replace(call, ui_visibility='redacted') copy, placed in the deferred calls and swapped into the run's history by replacing the response, as ModelRequestNode._finish_handling does. The part in history is never edited in place.
  • ui_visibility hides a tool's call and result, not its name. An unknown-tool retry and a tool search result name tools under their own call's visibility, which a non-public default covers. The ToolAvailabilityDeltaPart the adapters send, so that a client-held history keeps a revealed tool, names it under any default. That round trip is deliberate (#6793), and filtering it would need a per-name field on the part.
  • A tool that runs other tools, such as Pydantic AI Harness's ToolBridge tool_call and code mode's run_code, is sent by its own visibility. prepare_tools and PrepareTools run inside capability wrapper toolsets (Agent._get_toolset), so they can't set those tools, which take the adapter's default. Carrying the inner tool's visibility onto the outer result is tracked in #14667.
  • A call the run executes from a history that lost its stamps, such as an approval sent back by a client holding the history, is stamped from its tool's definition before it runs, in ToolManager._with_tool_kind beside tool_kind. An approved 'private' call is stamped 'redacted', as it was from the moment it deferred. sanitize_messages resets any ui_visibility a client sends in Pydantic AI's own message format, as it resets model_id, so the definition decides even when the client claims a stamp.
  • A realtime session stamps its tool calls and returns like a run, from the tools it advertises, so dump_messages of RealtimeSession.all_messages() hides them the same way.
  • A file the model's response carries, such as a native tool's generated image, is part of its answer and is sent like its text; #14646 can decide whether a per-native-tool setting hides it.

Verification

  • tests/test_ui_tool_visibility.py: both adapters, the live stream and dump_messages, for every rule above, including a reload that reads only the stamps, an approval sent back by a client holding the history, and the client-held-history warning.
  • test_redacted_tool_result_completes_the_client_tool_call in tests/ui_roundtrip: the real AI SDK and @ag-ui/client complete the tool call on the placeholder, streamed and after a reload.
  • tests/durable_exec/temporal/test_ui_visibility.py: a Temporal workflow with a 'private' tool. Its stamps cross the activity boundary, the event streams over the handler's events and dump_messages over the returned history send nothing of it, and the history replays. A workflow recorded on main also replays on this branch, with the tool unset and set to 'private'. That was a local probe, and adding one timer to the workflow makes the same replay fail.
  • test_session_stamps_tool_parts_like_a_run in tests/realtime/test_capabilities.py: a realtime session and a standard run making the same calls carry the same stamps.
  • The existing UI adapter suites pass with their snapshots unchanged.

What changes for existing users

With no ui_visibility set, no part is stamped, and every stream and dump is unchanged. Serialized tool parts and tool definitions gain a ui_visibility: null field. Prefect cache keys are unchanged: an unset ui_visibility is left out of them, so a flow retried across the upgrade still finds its cached model requests and tool calls (test_cache_policy_keys_for_unset_ui_visibility_are_pinned pins main's digests). dispatch_request passes default_ui_visibility to from_request, so a UIAdapter subclass that overrides from_request without **kwargs needs the new keyword, as for the keywords added before it.

PR decisions

2026-11-25 · Q2 DECIDED: call-part stamp timing · iter -

  • Decision: Stamp the call part at creation in ModelResponsePartsManager._typed_call_part and _agent_graph._narrow_tool_call_parts, as tool_kind is (#5143). The return part gets the same resolved value as its call, unless Douwe's Q8a answer splits them. Timing holds whatever carrier Q1 picks.
  • Why: Call events go out on PartStartEvent before the tool runs. Decided by the maintainer driving the PR (dsfaccini).
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7154195625
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN Q2: call-part stamp timing

2026-11-25 · Q3 DECIDED: field default · iter -

  • Decision: ToolDefinition.ui_visibility: ToolUIVisibility | None = None; docs say None means the adapter default, which is 'public' unless set. Add ui_visibility= everywhere #13214 added durable=: Tool, Agent.tool/tool_plain, FunctionToolset(...) default, FunctionToolset.tool/tool_plain/add_function, Capability.tool/tool_plain. What the stamp holds for an unset tool goes to Douwe inside Q1.
  • Why: Follows #13214 durable: bool | None = None and include_return_schema; a 'public' default can't tell unset from explicit. Decided by the maintainer driving the PR (dsfaccini).
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7154195625
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN Q3: field default

2026-11-25 · Q5 DECIDED: names and placement · iter -

  • Decision: default_ui_visibility plus a ToolUIVisibility alias in pydantic_ai.tools (precedent ToolDefinitionKind). Placement: UIAdapter field plus from_request and dispatch_request kwargs (as manage_message_history); UIEventStream field (as manage_system_prompt); keyword-only kwarg on concrete AGUIAdapter.dump_messages and VercelAIAdapter.dump_messages next to ag_ui_version/sdk_version; base UIAdapter.dump_messages(cls, messages) unchanged. Condition: flag the rename in the PR body as a deliberate change from the comment.
  • Why: Avoids clash with models/__init__.py:ToolVisibility and ModelRequestParameters.tool_visibility; third-party adapters override base dump_messages. Decided by the maintainer driving the PR (dsfaccini).
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7154195625
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN Q5: names and placement

2026-11-25 · Q6 DECIDED: redaction shape · iter -

  • Decision: One fixed placeholder '[REDACTED]' (spelling from _instrumentation.py), applied wherever a return's content leaves the server: AG-UI content, Vercel output, errorText on tool-output-error and tool-input-error, AG-UI denied and interrupted content. Outcome channels stay; AG-UI outcome marker drops retry feedback; Vercel tool-output-denied unchanged; args still sent. Condition: a tests/ui_roundtrip scenario showing the JS clients close the tool UI on the placeholder.
  • Why: Decision said only 'placeholder'; one rule for every content egress. Decided by the maintainer driving the PR (dsfaccini).
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7154195625
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN Q6: redaction shape

2026-11-25 · Q7 DECIDED: side channels · iter -

  • Decision: For 'redacted' and 'private', drop the MCP Apps payload (MCPAppToolResult.result is the full CallToolResult) in AGUIEventStream._handle_tool_result (ActivitySnapshotEvent), the AG-UI dump path in ag_ui/_adapter.py (ActivityMessage from get_mcp_app_tool_result), and vercel_ai/_utils.py:iter_metadata_chunks (Vercel stream and dump). Keep BaseEvents from metadata at both levels; drop BaseEvents from content. Condition: docs section says metadata events still go out for 'redacted' and 'private' tools.
  • Why: Metadata events are the tool's deliberate channel (docs/ui/ag-ui.md); the MCP Apps payload carries the result. Decided by the maintainer driving the PR (dsfaccini).
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7154195625
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN Q7: side channels on non-public returns

2026-11-25 · Q8 external half DECIDED: frontend tools public · iter -

  • Decision: A tool with kind='external' (frontend tools, _AGUIFrontendToolset(ExternalToolset)) is stamped 'public' whatever is set. Q8a (approval-required result) and Q8b (private tool deferring at runtime) stay OPEN with Douwe.
  • Why: Douwe's literal text: frontend and deferred tools are always public. Decided by the maintainer driving the PR (dsfaccini).
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7154195625
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN Q8: deferred tools (external half only)

2026-11-25 · Q10 DECIDED: warning trigger · iter -

  • Decision: One UserWarning per run, from the adapter's run path, under manage_message_history='client' with no conversation_store, when the default is non-public or the first non-public stamp is projected (precedent _warn_on_repeated_client_messages). Standalone UIEventStream and dump_messages don't warn. No public field just to carry the warning.
  • Why: Decision said 'warn' without a trigger. Decided by the maintainer driving the PR (dsfaccini).
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7154195625
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN Q10: warning trigger

2026-11-26 · Q1 DECIDED: stamp location · iter -

  • Decision: Typed ui_visibility field on both BaseToolCallPart and BaseToolReturnPart, stamped at creation like tool_kind. For a tool with no setting, the adapter writes its default into the stamp for the run, so a later dump_messages without the default still hides it.
  • Why: DouweM answered 2026-11-25T21:26Z: "all yes: the five recommendations stand, including the default_ui_visibility name"
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7175082545
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN Q1: stamp location; Q1/Q4/Q8a/Q8b/Q9 ASKED DOUWE

2026-11-26 · Q4 DECIDED: bulk setter · iter -

  • Decision: Document PrepareTools for setting ui_visibility in bulk, as #13214 did for durable; no new capability, and SetToolMetadata is unchanged.
  • Why: DouweM answered 2026-11-25T21:26Z: "all yes: the five recommendations stand, including the default_ui_visibility name"
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7175082545
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN Q4: bulk setter; Q1/Q4/Q8a/Q8b/Q9 ASKED DOUWE

2026-11-26 · Q8a DECIDED: approval-required result · iter -

  • Decision: The call of an approval-required tool stays public so the user can approve it; its result follows the tool's own ui_visibility setting, not "always 'public'".
  • Why: DouweM answered 2026-11-25T21:26Z: "all yes: the five recommendations stand, including the default_ui_visibility name"
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7175082545
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN Q8: deferred tools (approval half); Q1/Q4/Q8a/Q8b/Q9 ASKED DOUWE

2026-11-26 · Q8b DECIDED: private tool deferring at runtime · iter -

  • Decision: A 'private' tool that defers at runtime is shown as 'redacted' from the moment it defers.
  • Why: DouweM answered 2026-11-25T21:26Z: "all yes: the five recommendations stand, including the default_ui_visibility name"
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7175082545
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN Q8: deferred tools (runtime-defer half); Q1/Q4/Q8a/Q8b/Q9 ASKED DOUWE

2026-11-26 · Q9 DECIDED: native tools · iter -

  • Decision: The adapter default covers native tool parts in this PR; a per-tool ui_visibility field on AbstractNativeTool is a follow-up issue.
  • Why: DouweM answered 2026-11-25T21:26Z: "all yes: the five recommendations stand, including the default_ui_visibility name"
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7175082545
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN Q9: native tools; Q1/Q4/Q8a/Q8b/Q9 ASKED DOUWE

2026-11-26 · D1 DECIDED: output tools always public · iter -

  • Decision: Output tool calls and returns are always 'public': the stamp sites also read model_request_parameters.output_tools, a kind='output' def with a non-None value stamps 'public', and under a non-public default the filler writes 'public' onto output defs via prepare_output_tools.
  • Why: Decided by the maintainer driving the PR (dsfaccini). Output args are the run's answer; text/NativeOutput/PromptedOutput answers reach the client anyway
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7175082545
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN D1-D6: build design points (D1)

2026-11-26 · D2 DECIDED: after_model_request stamps unstamped call parts · iter -

  • Decision: The adapter's run capability (beside ReinjectSystemPrompt in UIAdapter.run_stream_native) also overrides after_model_request and returns replace(response, parts=...) stamping every still-unstamped tool call part (function with unknown name, native) with the non-public default; never mutate. Returns copy their call's stamp. Document: a short-circuiting wrap hook skips after_model_request.
  • Why: Decided by the maintainer driving the PR (dsfaccini). Widened from native-only: an unknown-name call's retry return lists every tool name, private ones included
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7175082545
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN D1-D6: build design points (D2)

2026-11-26 · D3 DECIDED: approval-required private stamped redacted · iter -

  • Decision: An approval-required (kind='unapproved') tool set to 'private' is stamped 'redacted' at creation; 'public' and 'redacted' follow their own setting.
  • Why: Decided by the maintainer driving the PR (dsfaccini). The user can't approve a call they can't see; a shown call with no result leaves the tool UI open
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7175082545
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN D1-D6: build design points (D3)

2026-11-26 · D4 DECIDED: runtime-deferred private call swapped for redacted copy · iter -

  • Decision: A 'private' call that defers at runtime becomes 'redacted' by building replace(call, ui_visibility='redacted') and swapping the response in ctx.state.message_history for replace(response, parts=...), as ModelRequestNode._finish_handling does; the copy goes into deferred_calls. Never edit in place. Flag this mechanism in the PR body as a deliberate choice.
  • Why: Decided by the maintainer driving the PR (dsfaccini). In-place edits break the _instrumentation.py:MessageJsonCache invariant and trip MessageHistoryMutatedWarning; deriving at projection breaks 'streams and dump read the stamp' and leaks on a usage-limit stop
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7175082545
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN D1-D6: build design points (D4)

2026-11-26 · D5 DECIDED: no load_messages change · iter -

  • Decision: No load_messages change for placeholders: server mode keeps a client result only for a call still pending at the end of stored history (_take_new_turn, _answering_parts); client-held history is warning-only (Q10).
  • Why: Decided by the maintainer driving the PR (dsfaccini). DouweM 10/26: a redacted or hidden copy from the client can never replace the real one in server mode
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7175082545
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN D1-D6: build design points (D5)

2026-11-26 · D6 DECIDED: fill defaults only when non-public · iter -

  • Decision: The adapter adds the definition filler and the D2 sweep only when default_ui_visibility != 'public'; a None definition value otherwise stays None. One stamp rule, implemented as one rule: (1) None stays None; (2) non-public default fills unset function defs with the default and output defs with 'public'; (3) external/output with any non-None value -> 'public'; (4) unapproved + 'private' -> 'redacted'; (5) runtime defer of 'private' swaps in a 'redacted' copy; (6) after_model_request stamps remaining unstamped call/native parts with the non-public default. Test and document: a standalone UIEventStream default applies only to unstamped parts (default 'private' with no filler hides unstamped frontend/output calls).
  • Why: Decided by the maintainer driving the PR (dsfaccini). Keeps behavior and snapshots unchanged for default users (CLAUDE.md: leave behavior unchanged for users not hitting the problem)
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7175082545
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN D1-D6: build design points

2026-11-26 · pre-push review 1 of 3 at f66cd6e9d9f92403a6bb73f581098a17c5aa79ed · iter -

  • Decision: 1 finding, confirmed by local repro: dump_messages in both adapters sends a 'redacted'/'private' tool's ToolReturn.content (a separate UserPromptPart from ToolCallExecutor._tool_user_part) while the stream drops it; remediation held on OPEN D7. Notes triaged: serialized null field (known, in PR body), temporal hand edits (CI verifies), _ui_visibility side effect + private field write (cleanup with D7 remediation).
  • Why: tree ba9bc281c602cd643e32fb87343673e76310891a; full branch 8833aee26d..f66cd6e9d9; policy base 0b98f7f043; reviewer haiku/high via policy-base-review
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175

2026-11-26 · D7 DECIDED: ToolReturn.content is outside ui_visibility · iter -

  • Decision: (C): no field on UserPromptPart. ui_visibility covers a tool's call and its return value; content attached with ToolReturn.content is user-channel content that reaches the model as a user message and that dump_messages sends as one. Docs say data the client must not see belongs in the return value. The stream no longer nulls FunctionToolResultEvent.content. Flag as a deliberate boundary in the PR body with the #6662 link; no follow-up issue. Answers pre-push review 1's finding.
  • Why: Decided by the maintainer driving the PR (dsfaccini): Douwe's direction relayed in #6662 ('A provenance field on UserPromptPart is the wrong shape'; 'Content a developer deliberately attaches as user parts through ToolReturn is left alone'); neither adapter's stream sends event.content; (A) would add a key to every serialized UserPromptPart
  • Source: https://github.com/pydantic/pydantic-ai/issues/6662#issuecomment-5443082639
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN D7: link a tool's user-channel content to its visibility

2026-11-26 · pre-push review 2 of 3 at 3b22b74b722c2241e0c583019bbe8705ad958e20 · iter -

  • Decision: Prior finding resolved per D7. 3 findings, all done: (1) warning skipped on the interrupted-closeout path after the cleanup, an intra-branch regression vs f66cd6e9d9 (main never warned): _interrupted_tool_result now warns too, through _warn_once_on_hidden_tools, with a test; (2) handle_event docstring now says a result event's content is outside ui_visibility; (3) the content-boundary test asserts the content is not on the wire.
  • Why: tree 88f6d21c0a649265fef4aaa701c1e5573a5d93c1; follow-up scope f66cd6e9d9..3b22b74b72; policy base b2b7827671; reviewer haiku/high
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175

2026-11-26 · pre-push review 3 of 3 at 9766744b561f8d8ee98590c66221dfeade1c8597 · iter -

2026-11-26 · CI and hosted review on d80f09200d · iter -

  • Decision: CI: test_deferred_output_json_schema snapshot and test_sanitize_messages policy rows lacked ui_visibility; fixed in 27cf471773 (Keep policy: a stamp only decides what the client is sent of a part it holds). Hosted findings: macroscope AssertionError on a hidden output call's closeout (reproduced, fixed); PR Review Checks weak empty-response assertion (fixed); veria enqueued exchanges skipped the stream default (reproduced, fixed); veria fragmented tool names (call start + arg deltas under the partial name reproduced; thread left open, OPEN D8) [corrected 2026-11-26: the result does leak when the shorter name's tool has a stamp; see D8 DECIDED].
  • Why: CI run 45762590673 on d80f09200d; review threads on #14645
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175

2026-11-26 · defer: per-native-tool ui_visibility (Q9) · iter -

2026-11-26 · D8 DECIDED: tool name streamed in pieces · iter -

  • Decision: D8a (fix here): handle_tool_call_delta resets ui_visibility when a name delta grows the name, so the call is stamped from the complete name; the result leaked when the shorter name's tool had a stamp (explicit, or the D6 filler under a non-public default). D8b (document + follow-up): the call start and arg deltas under the shorter name still go out; docs paragraph 'Tool names streamed in pieces'; holding tool-call events tracked in https://github.com/pydantic/pydantic-ai/issues/14647.
  • Why: Decided by the maintainer driving the PR (dsfaccini): probes with a control arm; veria's reply; Q1/Q2 stamp-from-own-definition contract; buffering would move PartStartEvent timing on the path every provider shares
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#discussion_r4704330381
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN D8: tool name streamed in fragments

2026-11-26 · D9 DECIDED: enqueued tool exchanges stay unstamped · iter -

  • Decision: Keep the documented edge; docs tell authors to set ui_visibility on the ToolCallPart and ToolReturnPart they enqueue. No follow-up issue.
  • Why: Decided by the maintainer driving the PR (dsfaccini): only operator-authority code enqueues tool returns, the author holds the control, same constraint as D2, D6 'None stays None'
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#discussion_r4704330390
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN D9: stamp enqueued tool exchanges

2026-11-26 · D10 DECIDED: run-ending exception text is outside ui_visibility · iter -

  • Decision: Document: a ToolFailed/ModelRetry message is the tool's result and follows ui_visibility; any other exception ends the run and its text goes to the client as the protocol's error event for every tool, as on main; override on_error() to change it. Test ToolFailed under 'redacted'/'private'. Follow-up https://github.com/pydantic/pydantic-ai/issues/14648 proposes #12326's store pattern for every run-ending exception.
  • Why: Decided by the maintainer driving the PR (dsfaccini): main control; #12326 scoped its sanitizing to store errors (discussion_r4464498037); D7 boundary; security precheck: already public behavior the maintainer scoped
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#discussion_r4704440809
  • Session: 2228e620-5e5d-4c35-bea7-85c06d4cf175
  • Supersedes: OPEN D10: run error text from a non-public tool

2026-11-26 · Follow-up issues 14647 and 14648 filed · iter -

2026-11-26 · Standalone stream and frontend calls: docs corrected · iter -

  • Decision: D6's 'default private with no filler hides unstamped frontend/output calls' holds for output tools only: a frontend call is hidden while it streams, then _show_deferred_hidden_calls sends it when the run defers it (the Q8b rule). Docs, the default_ui_visibility field docstring and the test now say so and assert both; no code change.
  • Why: PR Review Checks finding r4705182492 asked for the claim to be tested; the probe on 7e3aadc613 showed the frontend half was wrong
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#discussion_r4705182492

2026-11-26 · review-branch run 1 at 27deaca51b: triage · iter -

  • Decision: Do (fixed): legacy tool-bound RetryPromptPart translated in client_view (BLOCKING); ui_visibility left out of continuation digests; invalid visibility fails closed (assert_never in ui_visibility_of/client_tool_return); _DefaultUIVisibility _safe_at_runtime; renames call_part_from_tool_defs/_call_part_after_delta/_apply_tool_defs_to_call_parts; client_response_part shared by stream and dump; isinstance tuples; tests (ModelRetry, placeholder errorText, stored/client reload, dispatch_request default, legacy retry, invalid value, no private reads, expectation dicts); docs (### headings, ToolUIVisibility, MCP Apps caveats, wider name-fragment trigger, model text, reload/stamp wording, adapter subscriber shape). Skip: underscore renames (api-design.md: non-underscore names on exported classes are public); cassette case (projection runs after the model layer, and no provider is known to fragment names); downgrade re-save dropping the stamp (true of every field added to message parts); RetryInfo on redacted returns (Q6 dropped it from the AG-UI outcome marker); nested harness calls (code mode emits no nested tool events; their output is the outer tool's result).
  • Why: /review-branch suite: 3 waves, claim-checks CONFIRMED 40, RESCOPED 2, REFUTED 4
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645

2026-11-26 · Q7 AMENDED: a 'private' tool's metadata events are not sent · iter -

  • Decision: 'private' sends nothing tied to the call: both streams drop its result event with the BaseEvents/data chunks in its metadata, and dump_messages drops the return with them. 'redacted' keeps Q7 as decided (metadata events sent; MCP Apps payload and content events dropped). A 'private' tool reaches the client with ctx.emit, which carries no call id unless to_payload adds one.
  • Why: Decided by the maintainer driving the PR (dsfaccini). DouweM's Decision: "'private' sends neither", adopting rscholz98's "no call events and no result events. dump_messages drops the call and the return part"; Q7's reason rides on a sent result event; (a) needs a new UIEventStream hook and a client_view/Vercel dump shape change with no precedent
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7145205946
  • Supersedes: Q7 DECIDED: side channels ('private' half); OPEN D11: metadata events of a private tool

2026-11-26 · D12 DECIDED: no code now; heads-up on #14479 · iter -

  • Decision: D7 stands while main stores ToolReturn.content as a sibling UserPromptPart. One action: a comment on #14479 that client_tool_return keeps attachments on a 'redacted' return; whichever PR lands second makes 'redacted' drop them (attachments=()) and rewrites the "What it doesn't cover" ToolReturn.content sentences. The heads-up comment on #14479 is still to be posted.
  • Why: Decided by the maintainer driving the PR (dsfaccini): #14479 dumps attachments in encrypted_value/callProviderMetadata; no textual or test conflict flags it in either order; Q6 ("wherever a return's content leaves the server") settles the rule once content is part of the return
  • Source: https://github.com/pydantic/pydantic-ai/pull/14479
  • Supersedes: OPEN D12: ToolReturn.content after PR 14479

2026-11-26 · Flake on 27deaca51b filed as 14650 · iter -

2026-11-26 · D13 DECIDED: stamp responses that skip model.request() · iter -

  • Decision: (a). Stamp ui_visibility alone, from the step's tool definitions, in ModelRequestNode._recover_model_request_error (both modes, before after_model_request), on the streamed short-circuit response before its replay in ModelRequestNode.stream, and in ModelRequestNode._finish_handling. None stays None; tool_kind on these paths unchanged.
  • Why: Decided by the maintainer driving the PR (dsfaccini): probe on a73fd5adfd (wrap/skip/recover leaked an explicit 'private' tool's args and result on both protocols and dump; fix arm hides all; identity for tools without a setting); Q1/Q2 stamp-from-definition contract; ToolManager._with_tool_kind (#9710); D2's doc-only constraint (no hook holds the adapter default) absent here
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#discussion_r4706383131
  • Supersedes: OPEN D13: responses that skip model.request() are never stamped

2026-11-26 · D14 DECIDED: serialized ui_visibility null stays · iter -

  • Decision: Skip. ui_visibility serializes as null on every tool call, return and definition, as upstream/main already does with tool_kind: ToolPartKind | None = None on the tool parts (#5143) and durable: bool | None = None on ToolDefinition (#13214). No serializer change.
  • Why: Decided by the maintainer driving the PR (dsfaccini) after checking the precedent on upstream/main
  • Source: https://github.com/pydantic/pydantic-ai/pull/13214

2026-11-26 · D17 DECIDED: a 'redacted' native return drops provider_details · iter -

  • Decision: Fix under Q6: client_tool_return clears provider_details on a 'redacted' NativeToolReturnPart, so the Vercel dump's callProviderMetadata no longer carries it; add a dump test.
  • Why: Decided by the maintainer driving the PR (dsfaccini); Q6 applies the placeholder wherever a return's content leaves the server
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#issuecomment-7188094735

2026-11-26 · defer: stale tool_kind when a streamed name grows · iter -

2026-11-26 · D15/D16 DECIDED: a tool's name is outside ui_visibility · iter -

  • Decision: Document, no code, no follow-up issue (deliberate scope boundary). ui_visibility hides a tool's call and result, not its name: the unknown-tool retry and a search_tools result name tools under their own call's visibility (a non-public default stamps both through the D2 sweep), and ToolAvailabilityDeltaPart names a revealed tool under any default. Docs: "What it doesn't cover" names paragraph; PR body: Deliberate choices bullet.
  • Why: Decided by the maintainer driving the PR (dsfaccini): probe with control arm (direct private call hidden; leak only under the 'public' default for retry and search, under any default for the delta); Douwe's Decision scopes 'private' to call and result events; the delta's client round trip is Douwe's design (#6793, "Client-driven tool availability is intentional"); stream and dump read stamps only, so a filter needs a per-name carrier (bar 2); the unknown-call 'redacted' alt closes one of three channels and still shows the near-miss name; D7/D10 boundary precedent
  • Source: https://github.com/pydantic/pydantic-ai/issues/10696#issuecomment-7145205946

2026-11-26 · D18 DECIDED: ToolBridge tool_call and code mode run_code follow their own visibility · iter -

  • Decision: Document plus follow-up issue. A tool that runs other tools is sent by its own stamp; PrepareTools can't set tool_call or run_code (the prepare_tools hook runs inside capability wrapper toolsets, Agent._get_toolset), so the docs name the two workarounds that work: a non-public default_ui_visibility (the D2 sweep stamps the outer call) or the capability's tools selector. "Setting it in bulk" says which tools prepare_tools doesn't see. Follow-up issue (labels feature, area:ui-adapters, area:capabilities, pkg:harness) tracks carrying the inner tool's visibility onto the outer result.
  • Why: Decided by the maintainer driving the PR (dsfaccini): probe on 7a9becb56b (leak on both protocols and dumps; PrepareTools sees only the inner tools and the stamp stays None; both workarounds hide the result while the model gets it); fix needs a new channel from call_tool to the outer stamp in the harness (#13744); run-1 triage "their output is the outer tool's result"; defer rule (b) with the behavior verified
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#issuecomment-7188094735

2026-11-26 · defer: outer tools carrying an inner tool's ui_visibility (D18) · iter -

2026-11-26 · D19 DECIDED: one Temporal workflow test, no pre-change replay gate · iter -

  • Decision: Add one Temporal workflow-level test (TemporalAgent, a 'private' tool, ProcessEventStream handler): stamps on the handler's events and the returned history, no secret from VercelAIEventStream/AGUIEventStream over those events or from either dump_messages, and Replayer on its own history with replay_failure None. No pre-change replay gate and no patch marker. needs-durable-exec-review stays for a durable-exec reviewer's signoff marker.
  • Why: Decided by the maintainer driving the PR (dsfaccini): durable_exec/AGENTS.md "Add a workflow-level test where the engine's runtime behavior depends on the change"; contract --touched lists ToolDefinition and FunctionToolset (temporal/_transports.py moves ToolDefinition whole); precedent #9710 test_tool_kinds.py and #9711 self-replay; probe: identical activity types main vs branch, a main-recorded history replays on the branch with the tool unset and set 'private', an added timer fails the same replay (control); #12572's patch gate was driven by scheduling and listing changes this field doesn't make
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#issuecomment-7188094735

2026-11-26 · review-branch run 3 at efbfce1b9e: triage · iter -

  • Decision: Do: distinct stamp helper names; one last_response_index with an asserted invariant; visibility_by_call_id; protocol-keyed expectations and full result chunks in the tests; error-carrier docs; dump_messages links; the _safe_at_runtime docstring. Skip: routing replayed deferred calls through handle_event (its index filter would drop the replayed part end); dropping underscores on methods of private classes (class convention); a public field for the client-held warning (Q10); the warning stacklevel (matches the repeated-messages warning on the same path); one source for the output-tool 'public' (D1); DBOS/Prefect and durable-container tests (D19). Three blockers became D20-D22.
  • Why: /review-branch suite: 3 waves, claim-checks CONFIRMED 42, RESCOPED 4, REFUTED 7, UNSETTLED 13
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#issuecomment-7188094735

2026-11-26 · D20 DECIDED: stamp a call from its definition before it runs · iter -

  • Decision: ToolManager._with_tool_kind also fills an unstamped call's ui_visibility from its tool definition, through one tool_def_ui_visibility(tool_def) shared with ui_visibility_stamps; with approved=True a 'private' value becomes 'redacted'. None stays None. The history copy of the call stays unstamped; its return carries the stamp. Denied or answered client results are not re-stamped, since their content is the client's.
  • Why: Decided by the maintainer driving the PR (dsfaccini): probe on both protocols, where a client-held history sent the result of an approved requires_approval 'redacted'/'private' tool and of a runtime ApprovalRequired 'private' tool with no warning; a stamped control hides it; filling from the definition alone leaves a runtime-deferred 'private' call's UI open; _with_tool_kind (#9710) and D13 precedent
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#issuecomment-7188094735

2026-11-26 · D21 DECIDED: realtime stamps its tool parts like a run · iter -

  • Decision: Realtime builds a name-to-ui_visibility map from the advertised tools beside _tool_kinds, tool_call_part stamps from it, and the three returns it builds directly copy the call's stamp. A parity test checks a standard run and a session making the same calls produce equal stamps. No docs/realtime change.
  • Why: Decided by the maintainer driving the PR (dsfaccini): a full-session probe dumped a 'private' tool's call and result and a 'redacted' result on both protocols, the fix hides them and leaves unset tools identical; Q1 stamps "like tool_kind", which realtime already copies (#9710); realtime/AGENTS.md permits only deliberate, documented differences
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#issuecomment-7188094735

2026-11-26 · D22 DECIDED: a native tool's generated file is part of the answer · iter -

  • Decision: Document under "What it doesn't cover": a FilePart in the response, such as ImageGenerationTool's image, is sent like the response's text whatever the ui_visibility. One comment on #14646, so a per-native-tool setting can decide files. No code.
  • Why: Decided by the maintainer driving the PR (dsfaccini): probe with a 'public' control (the native return's content is hidden under 'redacted'/'private', the file is sent); the image can be the run's output (output_type=BinaryImage enables ImageGenerationTool); D1's reason; Google's image models emit the same part with no call; no adapter links the file to its call
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#issuecomment-7188094735

2026-11-26 · D23 DECIDED: sanitize_messages resets ui_visibility · iter -

  • Decision: sanitize_messages resets ui_visibility to None on tool call and return parts, with no opt-out flag, as it does model_id; a resumed call is then stamped from its tool's definition (D20). Supersedes the Keep row for the field in tests/test_sanitize_messages.py.
  • Why: Decided by the maintainer driving the PR (dsfaccini) on sanitize_messages precedent: it resets server-owned fields (workspace_ref, model_id). A probe showed a client-sent 'public' stamp on native history sent a 'redacted' tool's approved result on both protocols; the field is new, so no user on main is affected.
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#discussion_r4710861288

2026-11-26 · D24: first regression against main, Prefect cache keys, fixed · iter -

  • Decision: The new ui_visibility=None changed every Prefect user's model-request and tool task cache keys, the first regression against main this PR had. Fixed in df6f699ad4 as DouweM gave it: _excluded_fields leaves ui_visibility out while it's None; a set stamp stays in the key. test_cache_policy_keys_for_unset_ui_visibility_are_pinned pins main's three digests.
  • Why: A flow retried across the upgrade would re-run model requests and tool calls that had already finished.
  • Source: https://github.com/pydantic/pydantic-ai/pull/14645#issuecomment-7198173924

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.

https://claude.ai/code/session_01BYcNCmrLXujLakdqvbTubV