Skip to content

symfonic.agent.middleware.citation_default

citation_default

Citation hygiene by default for the public Agent.

The legacy engine strips HMS layer tags ([semantic], [episodic], …) from every user-visible reply. The public Agent returns the raw model reply; presentation stays opt-in. CitationDefaultMiddleware is the default-wire vehicle: wrap once and run/stream return presented text through the parity-tested present_response/HoldBackStream path, so no new tag pattern is introduced and the differential tests in tests/agent/presentation/ keep covering the strip.

Wrapping anything that is not exactly the public Agent refuses at construction. A mis-wrapped object would silently pass raw text through, which is the failure this module exists to prevent.

CitationDefaultMiddleware

CitationDefaultMiddleware(agent: Any, *, on_extraction: ExtractionHook | None = None)

Bases: PresentedAgent

An Agent whose turns ship with citation hygiene applied.

Identical output contract to :class:PresentedAgent; the only addition is the construction refusal, which makes an unwired composition a loud error instead of a tag leak.

Source code in src/symfonic/agent/middleware/citation_default.py
def __init__(self, agent: Any, *, on_extraction: ExtractionHook | None = None) -> None:
    if type(agent) is not Agent:
        raise ConfigurationError(
            "citation default wraps a public Agent; "
            f"got {type(agent).__name__}. Compose citation hygiene over "
            "the Agent whose turns must not leak layer tags."
        )
    super().__init__(agent, on_extraction=on_extraction)