Skip to content

ToolCallEntry

🛈 DocStrings

A tool call and its latest state.

Source code in src/acptui/protocol/state.py
@dataclass(eq=False)
class ToolCallEntry:
    """A tool call and its latest state."""

    tool_call_id: str
    name: str | None = None
    title: str | None = None
    kind: str | None = None
    status: str = "pending"
    content: list[ToolCallContent] = field(default_factory=list)
    locations: list[ToolCallLocation] = field(default_factory=list)
    raw_input: object = None
    raw_output: object = None
    can_cancel: bool = False

    @property
    def display_title(self) -> str:
        """Title for display, falling back to the tool name."""
        return self.title or self.name or self.tool_call_id

    @property
    def finished(self) -> bool:
        """Whether the tool call is done (successfully or not)."""
        return self.status in {"completed", "failed", "cancelled"}

    def apply(self, update: ToolCallUpdate) -> None:
        """Apply an upsert (patch semantics)."""
        if is_set(update.name):
            self.name = update.name
        if is_set(update.title):
            self.title = update.title
        if is_set(update.kind):
            self.kind = update.kind
        if is_set(update.status):
            self.status = update.status if update.status is not None else "pending"
        if is_set(update.content):
            self.content = list(update.content or ())
        if is_set(update.locations):
            self.locations = list(update.locations or ())
        if is_set(update.raw_input):
            self.raw_input = update.raw_input
        if is_set(update.raw_output):
            self.raw_output = update.raw_output
        if is_set(update.capabilities):
            caps = update.capabilities
            self.can_cancel = caps is not None and is_set(caps.cancel) and caps.cancel is not None

display_title property

display_title: str

Title for display, falling back to the tool name.

finished property

finished: bool

Whether the tool call is done (successfully or not).

apply

apply(update: ToolCallUpdate) -> None

Apply an upsert (patch semantics).

Source code in src/acptui/protocol/state.py
def apply(self, update: ToolCallUpdate) -> None:
    """Apply an upsert (patch semantics)."""
    if is_set(update.name):
        self.name = update.name
    if is_set(update.title):
        self.title = update.title
    if is_set(update.kind):
        self.kind = update.kind
    if is_set(update.status):
        self.status = update.status if update.status is not None else "pending"
    if is_set(update.content):
        self.content = list(update.content or ())
    if is_set(update.locations):
        self.locations = list(update.locations or ())
    if is_set(update.raw_input):
        self.raw_input = update.raw_input
    if is_set(update.raw_output):
        self.raw_output = update.raw_output
    if is_set(update.capabilities):
        caps = update.capabilities
        self.can_cancel = caps is not None and is_set(caps.cancel) and caps.cancel is not None

:fa-brands-github: Show source on GitHub