Skip to content

Executor

Calls an LLM provider with messages and returns the raw provider response.

---
title: Executor
config:
  look: handDrawn
  theme: colorful
  class:
    hideEmptyMembersBox: true
---
classDiagram
    class Executor {
      <<protocol>>
        +execute(agent: Prompty, messages: Message[]) unknown [async-capable]
        +executeStream(agent: Prompty, messages: Message[]) unknown [async-capable]
        +formatToolMessages(rawResponse: unknown, toolCalls: ToolCall[], toolResults: string[], textContent: string?) Message[] [sync]
    }

The following helper methods are declared via @method and must be implemented by every runtime. The schema declares the logical protocol contract; each runtime maps async-capable methods to idiomatic sync/async shapes for that language.

NameSignatureRuntime shapeDescription
executeexecute(agent: Prompty, messages: Message[]) -> unknownasync-capableCall an LLM provider with messages and return the raw response
executeStreamexecuteStream(agent: Prompty, messages: Message[]) -> unknownasync-capable (optional default)Call an LLM provider and return a streaming response. Returns a language-specific async iterable/stream of raw chunks. Not all providers support streaming; the default implementation should signal lack of support.
formatToolMessagesformatToolMessages(rawResponse: unknown, toolCalls: ToolCall[], toolResults: string[], textContent: string?) -> Message[]syncFormat tool call results into messages for the next iteration