Skip to content

MCP tool results: preserve typed content blocks, structured content, and resource links (full spec implementation, cloud-native) #223

Closed

Description

@JAORMX

The problem

When an MCP tool returns content richer than plain text — most concretely when the github MCP's get_file (or get_file_contents) returns a resource — mecatl has no way to fetch, download, or even surface that resource. The model sees a bare placeholder and the user sees nothing. This is the symptom the operator hit, and digging in revealed a broader gap: mecatl collapses every MCP CallToolResult to a single string, discarding most of the typed content the MCP spec defines.

What gets thrown away today

The choke point is flattenContent (internal/adapter/mcp/tool.go:167-186):

case *mcpsdk.TextContent:       b.WriteString(c.Text)
case *mcpsdk.ImageContent:      fmt.Fprintf(&b, "[image content: %s]", c.MIMEType)
case *mcpsdk.AudioContent:      fmt.Fprintf(&b, "[audio content: %s]", c.MIMEType)
case *mcpsdk.ResourceLink:      fmt.Fprintf(&b, "[resource link: %s]", c.URI)
case *mcpsdk.EmbeddedResource:  b.WriteString("[embedded resource]")

Discarded:

  • ResourceLink (resource_link): keeps only the URI as [resource link: <uri>]. Loses Name, Title, Description, MIMEType, Size, Icons, and the Annotations block (incl. audience). The model gets a useless bare URI it often cannot fetch; the client never learns a resource was intended for it.
  • EmbeddedResource (resource): collapses to the literal string [embedded resource] — the entire inline ResourceContents body (text or blob) the server deliberately shipped is dropped.
  • ImageContent / AudioContent: raw Data bytes discarded; only the MIME type survives as a bracket note.
  • res.StructuredContent: completely ignored (tool.go:143-147 reads only res.Content). The spec's structured-output channel never reaches the model or any client.
  • outputSchema: never read from the remote *mcpsdk.Tool (tool.go:39-63 captures only Name/Description/InputSchema). mecatl can't advertise an output schema to the model and can't validate structured results.

The ironic evidence: our own server proves the pattern, our client breaks it

mecatl's own MCP server (internal/adapter/mcpperf) deliberately emits user-audience ResourceLink content (mcpperf/tools.go:218,367,400) so a human-facing client can render a downloadable link while the model-facing text omits the raw path. ADR 0018 (docs/adr/0018-perf-observability.md:127,337) and the perf-mcp-interpretation skill document this as the intended pattern. The mcpperf tests (mcpperf_test.go:491-520, 610-632) assert the ResourceLink with Annotations.Audience=["user"] is on the wire.

When mecatl-the-client consumes that same server, flattenContent flattens it to [resource link: perf://pprof/heap] — stripping the audience annotation and giving the model a bare URI it cannot resolve (perf:// is not a scheme the harness fetches). The round-trip is broken: our server emits the spec-correct pattern, our client discards it.

The architectural root cause

session.ToolResult (engine/session/toolcall.go:71-79) is a single Content string + IsError bool. There is no structured-content field and no content-block-level metadata channel in the domain. The gRPC ToolResult proto (contracts/proto/mecatl/v1/mecatl.proto:964-971) mirrors this — call_id, content (string), is_error. By the time a tool result reaches the loop, the relay, or any client, everything has been flattened to a string. The TUI's MCP tool card (cmd/mecatui/ui/mcp.go, goldens tool_mcp_card_*) renders that flattened string.

This was a defensible simplification when MCP tool results were "text in, text out." With the 2025-06-18 spec revision, tool results are a typed, audience-aware content array plus an optional structured payload — and mecatl's model loses both axes.

How other harnesses handle this (the gap is industry-wide; mecatl is on the wrong side)

Client resource_link EmbeddedResource structuredContent audience split outputSchema
Spec render/fetch surface as artifact validate + expose user vs assistant validate
Claude Code URI only, metadata dropped dropped ignored not processed ignored
Claude Desktop partial dropped to LLM context, no UI ignored partial ignored
Codex dropped when structured present dropped when structured present kept (bug: drops blocks) not processed partial
ChatGPT Desktop ignores base64-as-text partial ignored (leaks image to model) ignored
mecatl URI only, all metadata + audience dropped [embedded resource] placeholder ignored not processed ignored

Evidence:

  • anthropics/claude-ai-mcp#287: Claude Desktop/Code "does not process the separate Annotations schema that applies to Resources, Resource Templates, and Content blocks"; embedded resources are "silently consumed into the LLM context — no clickable artifact, no downloadable file."
  • openai/codex#10334: Codex drops content[] blocks when structuredContent is present (mirror-image bug of mecatl's).
  • patent.dev "MCP Has an Image Problem": ChatGPT Desktop ignores audience:["user"], leaking image base64 into model context; "a specification only matters when implementations follow it."

What the spec says (2025-06-18, authoritative)

CallToolResult carries content[] (heterogeneous typed blocks: text, image, audio, resource/embedded, resource_link), structuredContent (optional JSON object, returned alongside content; a tool SHOULD also mirror it into a TextContent block for backward compat), isError, and the Tool definition may carry outputSchema (servers MUST conform, clients SHOULD validate). Every content block supports optional Annotations — distinct from ToolAnnotations — with audience (["user"]/["assistant"]/both), priority (0.0–1.0), lastModified (ISO 8601). resource_link is a reference (URI+metadata) the client may fetch/render; resource (EmbeddedResource) is inline content. https:// URIs are client-fetched; file:// and custom schemes are server-readonly. Resources also support subscribe + notifications/resources/updated and resource templates (URI templates).


Panel review (pre-implementation design review)

A panel of specialist reviewers (software-architect, secure-code-reviewer, devops-expert, library-reuse-reviewer, devex-reviewer, plus Spec-axis and Standards-axis passes) reviewed the proposed direction before implementation. Findings below shape the design. Full transcripts available on request.

Design correction (see comment): the panel's original decisions #1 (keep session.ToolResult string-only) and #8 (relay-owned sidecar) were an over-rotation and are withdrawn. The domain gets typed content of its own provider-neutral type (not MCP types) directly on session.ToolResult; it rides EvToolResult and Fold reconstructs it — no sidecar. The corrected decisions are below; the anti-corruption-layer rule (no mcpsdk.* in engine/) still holds.

Converged design decisions (corrected)

  1. Add typed content blocks to session.ToolResult of the DOMAIN'S OWN neutral type — NOT MCP types, NOT a relay sidecar. session.Content (engine/session/content.go:51) already exists as a provider-neutral content model carried on Message.Parts (conversation.go:61) for user messages, validated via NewContent/ValidateMediaParts. Generalize it (or add a sibling) to cover tool-result blocks: text, image, audio, resource-link (a reference: URI + name/description/MIME, not a fetch), embedded-resource (inline text or summarized blob). The MCP adapter maps mcpsdk.Content → session.Content (neutral) — the same posture the ACP adapter already uses (internal/adapter/acp/agent.go:815-857). No mcpsdk.* type crosses into engine/ (the anti-corruption-layer rule; the SkillSource/AgentDefSource precedent). The field is additive with a zero value (legacy string-only). NewToolMessage (conversation.go:94) already builds the tool-role Message carrying *ToolResult; tool-role messages gain Parts parity with user-role messages.

  2. Typed content rides the domain event — Fold/rehydration reconstructs it, NO sidecar. EvToolResult.ToolResult (event.go:860) already carries *ToolResult; the typed blocks ride it for free. engine/adapter/eventsource.Fold (ADR 0038) reconstructs them naturally because it already reads EvToolResult — no second store, no relay join. The loop stays storage-agnostic (it only emits session.Event; persistence is still Service.appendEvent at the relay). Backward-compat: old persisted sessions Load/Fold with zero-valued Parts = string-only; no migration shim, just a TestLoadLegacySessionWithFlatToolResult round-trip assertion.

  3. Audience-splitting and capability-gating live in COMPOSITION, not the MCP adapter. (software-architect HIGH; standards ACP: replay prior events on session/load #4). flattenContent cannot know the provider's modalities — that's the SINGLE composition-computed intersection (internal/app/capability.go modelCapability over Service.ProviderCapabilities()). The MCP adapter produces a neutral structured payload + a default model-facing string; composition decides per-result whether to upgrade to typed session.Content parts for the request. Mirrors the ACP gate (internal/adapter/acp/agent.go:486) — same seam, opposite verdict (ACP rejects resource_link in prompts because inbound is untrusted; tool results from operator-wired MCP servers are trusted provenance — preserve and route).

  4. audience is an untrusted-server self-attestation — NEVER a security control. (secure-code-reviewer HIGH, CWE-345/OWASP LLM01; Spec-axis W1). The server is the threat actor. Trusting audience:["user"] to suppress model-facing content inverts the trust model (a server hides an injection payload, or routes a secret into model context). Decision: treat audience as advisory display routing only — a ["user"] block may render an additional human-facing copy but must NEVER delete the model copy. Default every block to model-visible (TextContent parity). Still run untrusted-fencing/redaction regardless of audience.

  5. Do NOT dereference server-returned resource_link URIs automatically. (secure-code-reviewer HIGH, CWE-918/OWASP A10+API7; Spec-axis W2). ValidateClientURL is scheme/host-shape only and applies to client-PROVIDED URLs, not server-returned URIs. A server pointing at http://169.254.169.254/... is SSRF; headerRoundTripper scopes MCP creds to the configured server origin, not a resource URI. Decision: v1 surfaces the URI as a string reference (URI + name + description + MIME) for the model/user to act on; only https:// may ever be client-fetched, and even then through ValidateMediaURL-grade SSRF IP-deny + redirect re-validation + no cross-origin credential attachment. Non-https schemes stay server-readonly.

  6. Land the size bound FIRST (issue MCP tool results are not truncated to MaxOutputBytes (unlike every built-in tool) #178), then extend it to the new fields. (devops-expert H1; standards ACP: accept image/audio prompt content blocks #5). Built-in tools cap at MaxOutputBytes (25KiB); MCP results don't (open issue MCP tool results are not truncated to MaxOutputBytes (unlike every built-in tool) #178). Widening to carry typed blocks + StructuredContent + EmbeddedResource bodies before fixing MCP tool results are not truncated to MaxOutputBytes (unlike every built-in tool) #178 punches a hole in the log's implicit size ceiling — .events.jsonl / Redis EventLog bloat + memory DoS across replicas. Decision: per-block byte cap + total-bytes cap mirroring MaxOutputBytes, with the truncation marker preserved, applied to the structured-content/blob fields too. Verification: TestMCPTypedResultTruncatedToCap + a jsonlstore append-size assertion.

  7. Do NOT validate StructuredContent with session.ValidateJSON. (library-reuse HIGH). ValidateJSON is a deliberate fail-open subset validator for model-authored structured output (Subagent SubmitResult). MCP outputSchema is arbitrary server-provided full JSON Schema; ValidateJSON silently under-enforces and creates a second, weaker path. The SDK's client-side CallTool does NOT validate (validation lives server-side, server.go:380). If defense-in-depth client validation is wanted, use the SDK's transitive dep github.com/google/jsonschema-go (already in go.sum, MIT, Google-backed, full validator) — don't hand-roll a third.

  8. Reuse session.NewContent + ValidateMediaParts for media — no second validation path. (library-reuse MEDIUM; standards ACP: replay prior events on session/load #4; ADR 0001). The ACP adapter already maps content blocks → session.Content parts through the validating constructors (internal/adapter/acp/agent.go:815-857). AGENTS.md: "Reuses session.NewContent/ValidateMediaParts (no second validation path)." The MCP adapter routes image/audio/resource blocks through those same constructors; the per-type switch necessarily differs but the per-part validation is shared. (This is decision ACP: accept client-provided streaming-HTTP MCP servers #7 renamed for clarity — it now composes with decision mecatui: subagent / Task visibility (agent hierarchy dashboard) #1: the neutral content type IS session.Content.)

  9. Constructor ergonomics: keep NewToolResult/NewToolError 2-arg (additive only), add a builder for the new path. (devex HIGH). ~200 call sites across engine/agent, engine/adapter/*, internal/adapter/* + external consumers depend on the 2-arg constructors. Widening them = breaking (Changed). Decision: additive fields only (Added/minor); new path via a builder/options constructor; document the Content-vs-blocks precedence rule on the struct; proto documents the "both may be present; prefer blocks when non-empty" contract.

  10. This is a new ADR, never edited in place. (standards ACP: accept client-provided streaming-HTTP MCP servers #7; ADR lifecycle). A substantive tool-result contract decision. New ADR (e.g. 0058), superseding nothing. 0056/0057/0001 untouched. Triggers task api:update (the additive session.ToolResult field + generalized session.Content) + task generate (proto) + task docs (llms.txt) + a CLOUD-NATIVE.md List 1/List 2 re-audit (expected: no new outlives-a-call resource — it's a value-object widening, no new goroutine/LRU/map).

Spec-axis gaps to explicitly address or defer

  • subscribe / notifications/resources/updated (M1): ADR 0057 deferred ResourceUpdatedHandler. The proposal treats captured content as point-in-time. State subscription as out-of-scope explicitly.
  • Resource templates (M2): defer; state it.
  • Backward-compat TextContent mirror for structuredContent (M3): the design MUST emit a parallel TextContent block (spec SHOULD). Explicit.
  • outputSchema client SHOULD-validate (M4): only the SHOULD-validate half is mecatl's; confirm, don't assume conformance.
  • priority / lastModified (M5): drop explicitly if unused; don't silently strip.
  • audience on the wire to clients (S1): mecatl-specific extension beyond spec; flag as such.

Proposed scope (full spec implementation, productionized, cloud-native)

Phase 0 — land the size bound (issue #178 first)

  • Apply toolkit.Truncate/MaxOutputBytes to MCP tool results in flattenContent/remoteTool.Execute with the truncation marker.
  • Tests verify the cap; docs note MCP output cap matches built-in tools.
  • This unblocks Phase 1's richer payloads without a log-bloat/DoS hole.

Phase 1 — typed-block preservation on the domain ToolResult (adapter + composition + relay)

  • Domain: generalize session.Content (or sibling) to cover tool-result blocks (text/image/audio/resource-link/embedded-resource); add additive Parts []Content (or Blocks) to session.ToolResult; extend NewContent/ValidateMediaParts; keep NewToolResult/NewToolError 2-arg, add a builder for the blocks path.
  • MCP adapter: replace flattenContent with a path that maps mcpsdk.Content → session.Content (neutral) and produces (a) the typed blocks and (b) a default model-facing string. Preserve EmbeddedResource bodies (text verbatim, binary summarized), ResourceLink references (URI+name+desc+MIME, audience advisory-only, no URI dereference), Image/Audio (capability-gated via composition over the single modelCapability intersection, reusing session.NewContent/ValidateMediaParts).
  • Capture outputSchema from the remote tool spec; validate StructuredContent against it (via jsonschema-go if defense-in-depth wanted) — NOT session.ValidateJSON.
  • Emit the backward-compat TextContent mirror for structuredContent.
  • Composition: per-result audience/capability routing decision (the model copy is NEVER suppressed by audience; a ["user"] block may add a human-facing copy).
  • Relay: typed blocks ride EvToolResult.ToolResult (already-redacted at the existing chokepoint — no second redaction path); Fold reconstructs. No sidecar.
  • gRPC/HTTP proto: additive ToolResult fields (blocks + structured); document the dual-form contract ("both may be present; prefer blocks when non-empty").
  • TUI: surface typed blocks in the tool card — user-audience artifacts (downloadable links, image previews) distinct from model-facing text.
  • Backward-compat: legacy persisted sessions Load/Fold into string-only shape (zero-valued Parts); TestLoadLegacySessionWithFlatToolResult.

Phase 2 — resource fetching (the operator's concrete ask)

  • A model-facing affordance to fetch a resource_link the model received: route only https:// through ValidateMediaURL-grade SSRF IP-deny + redirect re-validation + no cross-origin creds; non-https stays server-readonly (read via ReadMcpResource against the owning server, which the adapter already supports).
  • Decide whether this is a new tool (FetchMcpResource) or an extension of ReadMcpResource to resolve a server-returned URI against the owning server.

Phase 3 — resource subscriptions (optional, deferred from ADR 0057)

  • Advertise subscribe; wire ResourceUpdatedHandler to invalidate a cached resource read. Low priority; file if/when operator demand.

Phase 4 — polish

  • Resource templates (URI templates) handling — defer unless needed.
  • priority/lastModified annotations — drop explicitly if unused.
  • mecatui resource-link rendering (clickable download, image preview).

Acceptance criteria

  • An MCP tool returning a resource_link (e.g. github MCP get_file) produces a model-facing reference the model can act on (URI + name + description + MIME) and a client-facing artifact; the model is NOT handed a useless bare placeholder. The operator's concrete scenario is resolved.
  • An MCP tool returning an EmbeddedResource surfaces the inline content (text verbatim; binary summarized with size), not [embedded resource].
  • structuredContent reaches the model/relay; outputSchema is captured and (optionally) validated via jsonschema-go, never session.ValidateJSON.
  • audience is advisory display routing only; never suppresses model-facing content; untrusted-fencing/redaction runs regardless.
  • Server-returned URIs are NEVER auto-dereferenced; only https:// may be client-fetched, through SSRF IP-deny.
  • session.ToolResult gains an additive Parts/Blocks field of the domain's own neutral content type (no mcpsdk.*); it rides EvToolResult and Fold reconstructs it; legacy sessions round-trip with zero-valued Parts. No relay sidecar.
  • MCP results are truncated to MaxOutputBytes (issue MCP tool results are not truncated to MaxOutputBytes (unlike every built-in tool) #178 closed) including the new structured fields.
  • New ADR (e.g. 0058); task api:update + task generate + task docs clean; CLOUD-NATIVE.md re-audit (no new List 1/List 2 row).
  • task lint && task test green; go run ./cmd/mecademo still prints a full offline session; the 10 gauntlet tests stay green.
  • A round-trip test: mecatl's own mcpperf server (emits user-audience resource_link) consumed by mecatl's client renders the link correctly — the broken round-trip fixed.

Out of scope (v1)

  • Resource subscribe / notifications/resources/updated (Phase 3, deferred from ADR 0057).
  • Resource templates (Phase 4).
  • priority/lastModified annotation handling beyond not-silently-stripping.
  • Changing the MCP transport (no stdio MCP, ever — ADR constraint).
  • Widening port.LLMRequest (provider-private knobs stay adapter Options).

References

  • internal/adapter/mcp/tool.go:167-186 (flattenContent), :39-63 (tool spec capture)
  • internal/adapter/mcp/resource.go (Resource/ResourceContents, readResource)
  • internal/adapter/mcpperf/tools.go:218,367,400 (userResourceLink) + mcpperf_test.go:491-520,610-632
  • engine/session/toolcall.go:71-89 (ToolResult), engine/session/content.go (NewContent/ValidateMediaParts/ValidateJSON), engine/session/conversation.go:61,94 (Message.Parts, NewToolMessage), engine/session/event.go:860 (EvToolResult.ToolResult)
  • contracts/proto/mecatl/v1/mecatl.proto:964-971 (ToolResult proto)
  • internal/adapter/acp/agent.go:486,809-836,815-857 (ACP resource_link rejection + content-block→session.Content mapping precedent)
  • internal/app/capability.go (modelCapability single intersection)
  • internal/adapter/server/{grpc,http}.go (Service.appendEvent relay persistence)
  • engine/adapter/eventsource.Fold (rehydration reconstructs from EvToolResult)
  • docs/adr/0056-mcp-client-reconnect.md, docs/adr/0057-mcp-server-notifications.md, docs/adr/0027-cloud-native.md, docs/adr/0037-engine-stability-contract.md, docs/adr/0038-event-sourced-rehydration.md, docs/adr/0001-acp-adapter.md, docs/adr/0018-perf-observability.md
  • MCP tool results are not truncated to MaxOutputBytes (unlike every built-in tool) #178 (MCP truncation gap — Phase 0), MCP client: consume server-initiated notifications (enable standalone SSE + listChanged handlers) #193 (MCP notifications — landed), Make the filesystem truly optional: a no-FS session profile #55 (no-FS profile)
  • MCP spec 2025-06-18: tools (/server/tools), resources (/server/resources)
  • anthropics/claude-ai-mcp#287, openai/codex#10334, patent.dev MCP image problem

Activity

  1. added
    enhancement
    on Jun 30, 2026
  2. JAORMX commented on Jun 30, 2026

    @JAORMX
    ContributorAuthor

    Design correction: drop the relay sidecar — put typed content on the domain ToolResult (provider-neutral, not MCP-shaped)

    On review, decision #8 (relay-owned sidecar) and the "keep session.ToolResult string-only" half of decision #1 are wrong — they were an over-rotation by the panel. The sidecar splits one logical thing (a tool result) across two storage locations (the domain event + a relay sidecar keyed by seq), so engine/adapter/eventsource.Fold can't reconstruct it, the relay manages a second store, and the TUI/gRPC joins two sources. That's strictly worse than the problem it solves.

    The panel itself surfaced the better answer but didn't land on it:

    • software-architect noted "session.Content (engine/session/content.go) already exists for the prompt path."
    • devex-reviewer HIGH ACP: persist allow_always as a learned permission rule #3: "Reuse the existing session.Content type for blocks. Message.Parts []Content already carries multimodal parts with NewContent/ValidateMediaParts. Inventing a parallel ToolResult.Blocks []SomethingElse forces two mental models and two validation paths. Reuse session.Content so a tool author learns one type."

    The conflation was "typed blocks" ↔ "MCP-shaped typed blocks." The domain must not import mcpsdk.* (that part of decision #1 stands — the anti-corruption-layer rule, the SkillSource/AgentDefSource precedent). But the domain does not need MCP types — it needs its own provider-neutral content model, which it already half has in session.Content.

    The corrected design

    1. Extend the domain's neutral content model to cover tool-result blocks. session.Content today is media-only (image/audio, inline-data or URL). Generalize it (or add a sibling session.ContentBlock) to carry: text, image, audio, resource-link (URI + name/description/MIME — a reference, not a fetch), embedded-resource (inline text or summarized blob). This is mecatl's own content type — no mcpsdk import, same status session.Content already has. NewContent/ValidateMediaParts extend to cover it (the panel's decision ACP: accept client-provided streaming-HTTP MCP servers #7 — no second validation path — holds and is now structurally enforceable).

    2. Add the typed blocks to session.ToolResult directly as an additive field (Parts []Content or Blocks []ContentBlock), zero-value = legacy string-only. NewToolMessage (conversation.go:94) already builds the tool-role Message; it carries the *ToolResult. Tool-role messages gain Parts parity with user-role messages (Message.Parts at conversation.go:61). RecordToolResults is unchanged (it already appends NewToolMessage(r)).

    3. It rides the domain event. EvToolResult.ToolResult (event.go:860) already carries *ToolResult; the typed blocks ride it for free. Fold/rehydration (ADR 0038) reconstructs them naturally because it already reads EvToolResult — no sidecar, no second store, no relay join. The loop stays storage-agnostic (it only emits session.Event; persistence is still Service.appendEvent at the relay). Backward-compat: old persisted sessions Load/Fold with zero-valued Parts = string-only.

    4. The MCP adapter maps mcpsdk.Content → session.Content (neutral) — the same mapping posture the ACP adapter already uses (internal/adapter/acp/agent.go:815-857 maps content blocks → session.Content parts). The per-type switch differs; the per-part validation is shared. No mcpsdk type crosses into engine/.

    5. Audience/capability routing stays in composition (decision ACP: route file I/O through client fs/* delegation #2 unchanged). The MCP adapter produces the neutral blocks + a default model-facing string; composition decides per-result whether to upgrade the request to typed parts over the single modelCapability intersection.

    What this changes vs. the issue body

    • Decision mecatui: subagent / Task visibility (agent hierarchy dashboard) #1: the "keep session.ToolResult string-only" half is withdrawn. The domain gets an additive Parts/Blocks field of its own neutral content type (not MCP types). The anti-corruption-layer rule (no mcpsdk.* in engine/) still holds.
    • Decision Epic: ACP adapter — Phase 3 long-tail #8: withdrawn entirely. No relay sidecar. Typed content rides EvToolResult.ToolResult; Fold reconstructs it.
    • Phase 1 relay bullet: the "persist as a relay-owned sidecar keyed by event seq" becomes "persist as part of EvToolResult.ToolResult (already-redacted at the existing chokepoint); Fold reconstructs." No second redaction path (decision ACP: accept client-provided streaming-HTTP MCP servers #7 holds).
    • Acceptance criterion: "session.ToolResult stays string-only" becomes "session.ToolResult gains an additive Parts/Blocks field of the domain's own neutral content type (no mcpsdk.*); legacy sessions round-trip with zero-valued Parts."

    Why this is still api-compat-safe

    NewToolResult/NewToolError stay 2-arg (decision #9 holds — ~200 call sites untouched). The new field is additive with a zero value; classification is Added (minor) per engine/COMPATIBILITY.md, triggers task api:update + engine/CHANGELOG.md. The proto ToolResult gets additive repeated block fields (wire-safe). Fold reads the new field but a zero value is the legacy form — no migration shim needed, just a TestLoadLegacySessionWithFlatToolResult round-trip assertion.

    All other panel decisions (#2 audience-in-composition, #3 audience-is-advisory-only, #4 no URI dereference, #5 size-bound-first, #6 no ValidateJSON for structured content, #7 reuse NewContent/ValidateMediaParts, #9 constructor ergonomics, #10 new ADR) stand unchanged.

    This is the better solution the operator asked about. Updating the issue body to match.

  3. reopened this on Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementresearchui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions