Skip to content

symfonic.agent.cutover.tool_names

tool_names

Compatibility import for naming projected tool messages.

The implementation belongs to :mod:symfonic.agent.response_messages so the native compatibility HTTP routes dump messages without loading cutover. This alias keeps the cutover consumers and the function identity.

named_tool_messages

named_tool_messages(typed: Sequence[Any], dumped: list[dict[str, Any]]) -> list[dict[str, Any]]

Name each tool dump: replayed exactly, generated from an earlier call.

typed[i] is the message dumped[i] was built from.

Source code in src/symfonic/agent/response_messages.py
def named_tool_messages(typed: Sequence[Any], dumped: list[dict[str, Any]]) -> list[dict[str, Any]]:
    """Name each ``tool`` dump: replayed exactly, generated from an earlier call.

    ``typed[i]`` is the message ``dumped[i]`` was built from.
    """
    names: dict[str, str] = {}
    for message, dump in zip(typed, dumped, strict=True):
        if dump.get("type") == "ai":
            names.update(names_by_call_id(dump.get("tool_calls") or ()))
        elif dump.get("type") == "tool":
            dump["name"] = (
                message.tool_name
                if hasattr(message, "tool_name")
                else names.get(dump.get("tool_call_id") or "")
            )
    return dumped