Skip to content

symfonic.agent.facade_turn

facade_turn

The caller's half of one invocation, built the same way for every entry.

Extracted from :mod:symfonic.agent.facade when that module reached its size budget, and the seam is the one the module docstring already implied: the facade is the public surface -- overloads, validation, lifecycle -- and this is what one call becomes. One function, so run and stream cannot drift in what they hand the kernel; a difference there would be a difference in what the model is asked, invisible in the answer.

delegated_turn_for

delegated_turn_for(prompt: str, run_id: str, root_run_id: str, parent_run_id: str) -> TurnRequest

Build the child request whose lineage delegation already decided.

Source code in src/symfonic/agent/facade_turn.py
def delegated_turn_for(
    prompt: str, run_id: str, root_run_id: str, parent_run_id: str
) -> TurnRequest:
    """Build the child request whose lineage delegation already decided."""
    return turn_for(
        prompt, (), (), None,
        run_id=run_id,
        root_run_id=root_run_id,
        parent_run_id=parent_run_id,
    )

turn_for

turn_for(prompt: str, attachments: Sequence[Attachment], history: Sequence[Message], state: Mapping[str, Any] | None = None, *, session_id: str = '', run_id: str | None = None, root_run_id: str | None = None, parent_run_id: str | None = None) -> TurnRequest

One invocation's request, frozen before it reaches the kernel.

state is copied and deep-frozen here rather than at the far end: the boundary is the only place that knows the caller still owns their object, and freezing later would let a caller who mutates their dict mid-turn change what a rung two steps down sees.

Source code in src/symfonic/agent/facade_turn.py
def turn_for(
    prompt: str,
    attachments: Sequence[Attachment],
    history: Sequence[Message],
    state: Mapping[str, Any] | None = None,
    *,
    session_id: str = "",
    run_id: str | None = None,
    root_run_id: str | None = None,
    parent_run_id: str | None = None,
) -> TurnRequest:
    """One invocation's request, frozen before it reaches the kernel.

    ``state`` is copied and deep-frozen here rather than at the far end: the
    boundary is the only place that knows the caller still owns their object,
    and freezing later would let a caller who mutates their dict mid-turn
    change what a rung two steps down sees.
    """
    own_run_id = run_id or uuid.uuid4().hex
    return TurnRequest(
        prompt=prompt,
        attachments=tuple(attachments),
        history=tuple(history),
        run_id=own_run_id,
        root_run_id=root_run_id or own_run_id,
        parent_run_id=parent_run_id,
        session_id=session_id,
        properties=freeze_properties(state),
    )