Skip to main content
Version: 0.9.0

mellea.stdlib.context.simple

Stateless single-turn context (no history is forwarded to the model).

Classes​

CLASS SimpleContext ​

A SimpleContext is a context in which each interaction is a separate and independent turn. The history of all previous turns is NOT saved..

Methods:

FUNC add ​

add(self, c: Span) -> Self

Add a new component or CBlock to the context and return the updated context.

The added span is stored on the context chain but is not forwarded to the model on subsequent generations — SimpleContext.view_for_generation always returns an empty list, so each generation is treated as a stateless, independent turn. To actually talk to the model, pass the prompt as the action argument to MelleaSession.chat / Backend.generate_from_context, not via add.

Args:

  • c: The component, content block, or model output to record.

Returns:

  • A new context of the same concrete subtype containing only the
  • added entry; prior history is not retained. Returning Self (not the
  • hard-coded SimpleContext) keeps a subclass statically its own type.

FUNC view_for_generation ​

view_for_generation(self) -> list[Span] | None

Return an empty list, since SimpleContext does not pass history to the model.

Each call to the model is treated as a stateless, independent exchange. No prior turns are forwarded. Spans recorded via add are kept on the in-memory chain (as_list) for inspection but discarded for generation.

Returns:

  • list[Span] | None: Always an empty list.