Skip to content

symfonic.capabilities.tools.context

context

The per-turn inputs every selection stage may read (T3.1.2).

SelectionContext dataclass

SelectionContext(state: MutableMapping[str, Any] = dict(), messages: Sequence[Any] = (), role: str = '', query: str = '')

What the stages know about the turn being selected for.

state is passed through to adopter-supplied resolvers by identity, not by copy: the pre-T3.1.2 react node handed them the live LangGraph state and a resolver that reads a tenant key out of it must keep working.

forced_choice is the one mutable field. The pipeline writes it when a stage resolves a force, and later stages (and the pipeline's own protection rule) read it. It is deliberately not an input a caller pre-seeds — the forced-choice stage owns that question, and a second writer would recreate the "two answers to one question" bug class the plan model exists to remove.

resolved_messages

resolved_messages() -> Sequence[Any]

messages if supplied, else the conversation on state.

Source code in src/symfonic/capabilities/tools/context.py
def resolved_messages(self) -> Sequence[Any]:
    """``messages`` if supplied, else the conversation on ``state``."""
    if self.messages:
        return self.messages
    return self.state.get("messages") or ()