Skip to content

interlens.context.context_policy

interlens.context.context_policy

ContextPolicy

Bases: ABC

Decides how to fit a participant's view within its model's context window.

Crucially, fit runs on the typed ViewSegment list, before the family-specific finalize_view folds/merges anything. Operating pre-finalize means the policy can reliably preserve the system block and moderator seed (their origin is still intact) and trim only turn segments, instead of trying to reverse-engineer meaning out of already-folded text.

to_dict

to_dict() -> dict

Serialize as {"kind": ..., **params}. Subclasses with parameters extend the params; the default covers parameterless policies.

Source code in src/interlens/context/context_policy.py
def to_dict(self) -> dict:
	"""Serialize as ``{"kind": ..., **params}``. Subclasses with parameters extend the params; the default
	covers parameterless policies."""
	return {"kind": type(self).__name__}