Skip to content

[feat] Content-kind decomposition — strip code blocks / tool outputs / file reads #310

Closed

Description

@Sinity

Problem

Conversation output currently mixes authored prose, fenced code, tool
calls, tool-result payloads, file reads, thinking traces, and other
mechanically emitted material into one undifferentiated text stream.
Existing role filters reduce speaker noise, but they do not let users
ask for prose-only context or suppress mechanical artifacts in a
principled way.

That makes corpus mining, resume-style summaries, handoff briefs, and
human review needlessly noisy. Content-kind projection should be a real
archive/query contract, not a late-stage string-trimming trick.

Strengthened scope

Introduce a canonical content-kind projection contract for rendered and
query-returned conversation content, then expose it consistently across
CLI, MCP, and facade surfaces.

The first shipped taxonomy should be richer than the issue title alone.
Minimum first-class kinds:

  • prose/authored text
  • fenced code blocks
  • tool invocation records
  • tool-result payloads
  • file-read payloads (distinct from generic tool results)
  • reasoning / thinking traces
  • system / protocol noise when the source format exposes it distinctly

The implementation should:

  • classify content kinds in shared substrate/runtime logic once, not by
    fragile final-string surgery in each command
  • prefer structured content_blocks and semantic block metadata when
    available, with a shared text-fallback decomposition for legacy/plain
    messages that still detects fenced code and preserves prose order
  • pair tool-result payloads to their originating tool calls when enough
    metadata exists so file-read outputs can be filtered without bluntly
    deleting all tool traffic
  • make role projection and content-kind projection composable and order
    stable
  • preserve the raw archive unchanged; this is a projection contract, not
    ingestion mutation
  • expose the same projection model through CLI, facade, and MCP where
    conversation/query text is returned

User-facing contract

At minimum, support these controls on the CLI root query surface and the
corresponding MCP/facade contract:

  • --no-code-blocks
  • --no-tool-calls
  • --no-tool-outputs
  • --no-file-reads
  • --prose-only

--prose-only should be a real preset over the shared projection model,
not a separate bespoke path.

Design requirements

  • Provider-specific quirks must normalize into the shared taxonomy
    rather than leaking different flag behavior per provider.
  • The default output must remain backward-compatible unless a caller
    opts into projection.
  • Projection must compose cleanly with truncation, role filters,
    transforms, stream output, plain/markdown/JSON rendering, and detail
    payload serialization.
  • Empty messages produced by projection should not survive into rendered
    output as blank shells.
  • The public contract should be typed, reusable, and testable without
    invoking CLI glue.

Surface requirements

Land the shared contract in all three surface families:

  • CLI query/detail/stream output
  • MCP get_conversation and list/query surfaces that return conversation
    content or payloads
  • facade/archive methods that return conversation objects intended for
    downstream rendering or analysis

This should not create three separate flag-parsing or projection
implementations.

Acceptance criteria

  • CLI output can exclude code blocks, tool calls, tool outputs, and
    file-read payloads independently, plus a prose-only mode.
  • MCP and facade surfaces expose the same projection contract where they
    return conversation/query text or serialized message payloads.
  • Mixed-content tests cover structured blocks and text-fallback messages
    containing prose, fenced code, tool calls, tool results, file reads,
    and thinking traces in the same transcript.
  • File-read suppression is narrower than generic tool-output suppression
    when the underlying metadata is sufficient to distinguish them.
  • The decomposition/projection logic is implemented once in shared logic
    rather than by repeated output-string patching.

Strategic value

This is not just output cleanup. It creates a cleaner semantic substrate
for later mining, summaries, live-session inspection, and downstream
products, while preventing future surfaces from reintroducing bespoke
text-mangling logic.

Activity

  1. Sinity commented on Apr 23, 2026

    @Sinity
    OwnerAuthor

    Starting implementation. I tightened the issue contract first so this lands as one shared projection model rather than another CLI-only string filter. Tactics for this slice: (1) shared structured-first content-kind classifier with text fallback, (2) conversation-level projection so tool-result/file-read pairing can work across message boundaries, (3) surface parity across CLI query/stream, MCP detail/export surfaces, and facade conversation reads, (4) mixed-content tests covering prose, fenced code, tool calls, tool outputs, file reads, and thinking traces in one transcript.

  2. Sinity commented on Apr 23, 2026

    @Sinity
    OwnerAuthor

    Implemented the strengthened #310 plan on feature/feat/content-kind-projection and opened PR #391.

    What landed on the branch:

    • shared substrate contract in polylogue.lib.content_projection with canonical content kinds and reusable ContentProjectionSpec
    • structured-first projection with text fallback for fenced code and reasoning tags
    • tool-result to tool-use semantic pairing so file-read payloads can be suppressed without dropping all tool output
    • surface wiring through conversation runtime, archive operations, facade methods, CLI query output, shared formatting/payload helpers, and MCP read/export tools
    • root CLI controls: --no-code-blocks, --no-tool-calls, --no-tool-outputs, --no-file-reads, --prose-only
    • owning tests across core, CLI, facade, and MCP, including attachment-only prose-only behavior
    • refreshed top-level help surfaces and docs for the new flags

    Verification run locally:

    • pytest -q tests/unit/core/test_content_projection.py tests/unit/cli/test_query_fmt.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_query_exec.py tests/unit/cli/test_click_app.py tests/unit/cli/test_terminal_snapshots.py tests/unit/core/test_facade_api.py tests/unit/mcp/test_server_surfaces.py -q
    • devtools verify

    PR: #391

  3. Sinity commented on Apr 23, 2026

    @Sinity
    OwnerAuthor

    Merged via PR #391: #391

    Merge commit: 811c94826ffd4690be002fd7c3ef987bf65d4c74

    #310 is now closed. master is clean.

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

    area:cliarea:parsertype:feat

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions