Skip to main content
Returns a single formatted_context string that stitches together the compacted history with any messages that arrived after the last compaction cutoff. Drop the result straight into your prompt. No further assembly required. If no compaction has run yet, every recorded message comes back as a recent message, so this method is useful from the very first turn.

Parameters

str
required
The conversation to assemble context for. Must be a valid UUID registered via record_message.
str
default:"structured"
Formatting style for the compacted portion:
  • "structured": labelled sections (facts, decisions, preferences, current state)
  • "narrative": prose summary
  • "bullet_points": bulleted list

Returns

A ContextForPromptResponse ready for prompt injection.
str | None
The combined compacted + recent context, formatted per style. Inject directly into your LLM prompt.
bool
Whether usable context (compacted or recent) was found.
bool
Whether the compacted portion is stale relative to newer messages.
float | None
Compression ratio of the compacted portion.
float | None
Quality validation score of the compacted portion.
int | None
How long ago the compaction completed.
bool
True when the compacted portion was flagged for quality concerns.
List[Dict[str, Any]]
Raw un-compacted messages since the last compaction. Use if you want to format them yourself.
int
Number of un-compacted messages included.
int
Number of messages covered by the compacted portion.
int
Total messages in the conversation.

Example

Raises

  • AuthenticationError: when the API key is missing or invalid.
  • NetworkError: when the SDK cannot reach Synap.

See also