Skip to content

agents / Exports / ExecutorInterface

Interface: ExecutorInterface

Interface for executing AI provider operations

Executors abstract the execution mechanism, allowing providers to work with either local API calls or remote server calls transparently.

Implementation patterns:

  • LocalExecutor: Direct API calls using provider SDKs
  • RemoteExecutor: HTTP/WebSocket calls to remote server
  • CacheExecutor: Cached responses with fallback to another executor
  • HybridExecutor: Conditional local/remote execution

Implemented by

Table of contents

Properties

Methods

Properties

name

Readonly name: string

Get executor name/identifier

Defined in

packages/agents/src/interfaces/executor.ts:100


version

Readonly version: string

Get executor version

Defined in

packages/agents/src/interfaces/executor.ts:105

Methods

executeChat

executeChat(request): Promise<AssistantMessage>

Execute a chat completion request

Parameters

NameTypeDescription
requestChatExecutionRequestChat execution request with messages, options, and tools

Returns

Promise<AssistantMessage>

Promise resolving to assistant message response

Example

typescript
const response = await executor.executeChat({
  messages: [{ role: 'user', content: 'Hello!' }],
  options: { model: 'gpt-4', temperature: 0.7 },
  provider: 'openai',
  model: 'gpt-4'
});

Defined in

packages/agents/src/interfaces/executor.ts:57


executeChatStream

executeChatStream(request): AsyncIterable<UniversalMessage, any, any>

Execute a streaming chat completion request

Parameters

NameTypeDescription
requestStreamExecutionRequestStreaming chat execution request

Returns

AsyncIterable<UniversalMessage, any, any>

AsyncIterable of message chunks

Example

typescript
for await (const chunk of executor.executeChatStream({
  messages: [{ role: 'user', content: 'Tell me a story' }],
  options: { model: 'gpt-4' },
  provider: 'openai',
  model: 'gpt-4',
  stream: true
})) {
  console.log(chunk.content);
}

Defined in

packages/agents/src/interfaces/executor.ts:78


supportsTools

supportsTools(): boolean

Check if the executor supports tool calling

Returns

boolean

true if tool calling is supported

Defined in

packages/agents/src/interfaces/executor.ts:84


validateConfig

validateConfig(): boolean

Validate executor configuration

Returns

boolean

true if configuration is valid

Defined in

packages/agents/src/interfaces/executor.ts:90


dispose

dispose(): Promise<void>

Clean up resources when executor is no longer needed

Returns

Promise<void>

Defined in

packages/agents/src/interfaces/executor.ts:95

Released under the MIT License.