conclusion

package
v0.601.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package conclusion implements the delegated-task conclusion protocol: parsing the sentinel <pando:conclusion> block emitted by a subagent and enriching it with software-owned launch metadata.

The package intentionally depends only on the domain models (plus stdlib and a YAML parser) so it can be reused by the orchestrator and app wiring without creating import cycles with internal/config or internal/project. Config and project resolution are threaded in via plain function/struct values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BriefInstruction

func BriefInstruction() string

BriefInstruction returns the instruction appended to a delegated subagent's prompt when delegation is enabled. It tells the subagent to close its run with a single <pando:conclusion> sentinel block listing ONLY the model-known fields. The software fills in all launch metadata (task id, engine, model, project, parent session, timestamps) from the task record it owns, so the model must NOT restate those.

The text is centralized here so it is reusable and testable, and so the orchestrator can append it as the trailing instruction after persona is applied.

func Enrich

func Enrich(task *models.Task, cfg DelegationOptions, resolver ProjectResolver) *models.Conclusion

Enrich builds the durable Conclusion for a terminal task. It parses the task's output for the sentinel block, synthesizes a fallback when configured, and always fills software-owned metadata (CapturedAt, project id/name). It returns nil when no conclusion can or should be captured.

The function is pure with respect to globals: everything it needs is passed in. It mutates task.ProjectID / task.ProjectName as a convenience for the caller (the resolved project is software-owned launch metadata) but never panics on nil inputs.

func FormatForParent

func FormatForParent(task *models.Task) string

FormatForParent renders a compact, pointers-not-dumps message describing a delegated task's result, suitable for injection into the parent agent loop. The header line carries only software-owned launch metadata (task id, engine, project, status, confidence) — never values the model could have hallucinated. The body carries the model-provided summary plus optional follow-up, artifacts and memory refs (each omitted when empty) so the parent can lazily fetch detail.

It is nil-safe: a task without a Conclusion yields a minimal single line so the parent still learns the task finished.

func Parse

func Parse(raw string) (*models.Conclusion, bool)

Parse scans raw for the sentinel block delimited by <pando:conclusion> ... </pando:conclusion>. When multiple blocks are present the LAST one is used (it is the final summary). The inner body is parsed as YAML; parsing is tolerant: missing fields default to their zero value, and an unparseable body with a present sentinel still returns a Conclusion whose Summary is the salvaged raw inner text.

It returns (conclusion, true) when a block was found, (nil, false) otherwise.

Types

type DelegationOptions

type DelegationOptions struct {
	// SynthesizeFallback enables deriving a conclusion from output/error when the
	// subagent did not emit a sentinel block. When false, a missing block means no
	// conclusion is captured.
	SynthesizeFallback bool
}

DelegationOptions carries the conclusion-relevant knobs the enricher needs. It is defined here (rather than importing internal/config) so the conclusion package stays free of import cycles; the app/orchestrator translate config into this value.

type ProjectResolver

type ProjectResolver func(canonicalPath string) (id string, name string)

ProjectResolver maps a canonical project path to its registry id and display name. It returns empty strings when the path is not a registered project.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL