MingaAgent.ContextArtifact (Minga v0.1.0)

Copy Markdown View Source

Generates condensed context artifacts from agent sessions.

Unlike session export (#284) which produces a full transcript for humans, context artifacts produce a compact summary designed for feeding to a future agent session via @.minga/context/session-summary-{id}.md.

A 50K-token session with dozens of tool calls collapses into a 1-2K token context file that a fresh session can consume efficiently.

Summary

Types

Options for artifact generation.

Functions

Lists existing context artifacts in the project.

Saves a generated summary to the .minga/context/ directory.

Returns true if the conversation has enough content to be worth summarizing.

Returns the meta-prompt to inject for summary generation.

Types

artifact_opts()

@type artifact_opts() :: [project_root: String.t(), session_id: String.t() | nil]

Options for artifact generation.

Functions

list(project_root)

@spec list(String.t()) :: [String.t()]

Lists existing context artifacts in the project.

save(summary_text, opts)

@spec save(String.t(), artifact_opts()) :: {:ok, String.t()} | {:error, String.t()}

Saves a generated summary to the .minga/context/ directory.

Returns {:ok, path} or {:error, reason}.

summarizable?(messages)

@spec summarizable?([ReqLLM.Message.t()]) :: boolean()

Returns true if the conversation has enough content to be worth summarizing.

Requires at least 2 non-system messages (one user + one assistant).

summary_prompt()

@spec summary_prompt() :: String.t()

Returns the meta-prompt to inject for summary generation.