Skip to content

Expand LLMSwarmResult.Synthesis into a structured PSCustomObject #29

@ocalvo

Description

@ocalvo

Problem

Invoke-LLMSwarm currently returns:

Synthesis = $synth.Content   # raw string

(see Public/Invoke-LLMSwarm.ps1:138)

Consumers get an opaque blob. There is no programmatic way to access the synthesizers reasoning, conclusions, per-task references, or token breakdown without string-parsing.

Proposed shape

Replace the single string with a [PSCustomObject] with sub-properties:

Synthesis = [PSCustomObject]@{
    PSTypeName   = "PwrCortex.SwarmSynthesis"
    Summary      = <short one-paragraph conclusion>
    Content      = <full synthesizer response text>
    KeyFindings  = <List[string]>       # extracted bullet points
    References   = <List[SwarmTaskRef]> # which Tasks[i] each finding came from
    Provider     = <string>
    Model        = <string>
    InputTokens  = <int>
    OutputTokens = <int>
    TotalTokens  = <int>
    ElapsedSec   = <double>
    StopReason   = <string>
}

Where SwarmTaskRef is @{ TaskIndex; TaskPrompt; Excerpt }.

Implementation

  1. In Invoke-LLMSwarm, instead of storing $synth.Content, build the structured object from the [LLMResponse] returned by the synthesis call.
  2. Ask the synthesizer to return its conclusions as a JSON block (or parse bullet lines) so KeyFindings/References can be populated reliably. Fallback: empty lists, Content always populated.
  3. Update CLAUDE.md and Invoke-LLMSwarms .OUTPUTS section.
  4. Update Enter-LLMChat:192 which passes $swResult.Synthesis into chat history — needs $swResult.Synthesis.Content.

Acceptance

  • (Invoke-LLMSwarm ...).Synthesis.KeyFindings returns a list.
  • (Invoke-LLMSwarm ...).Synthesis.References[0].TaskIndex resolves.
  • Backwards compatibility is explicitly broken (Synthesis was a string, now an object). Release as feat!: / major bump per release-please rules.

Related

  • Sibling issue: Replace Write-Host console UI with .format.ps1xml views

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions