Skip to main content

Class: ReActAgentWorker

ReAct agent worker.

Implements

Constructors

constructor

new ReActAgentWorker(«destructured»): ReActAgentWorker

Parameters

NameType
«destructured»ReActAgentWorkerParams

Returns

ReActAgentWorker

Defined in

packages/core/src/agent/react/worker.ts:72

Properties

_getTools

_getTools: (message: string) => Promise<BaseTool[]>

Type declaration

▸ (message): Promise<BaseTool[]>

Parameters
NameType
messagestring
Returns

Promise<BaseTool[]>

Defined in

packages/core/src/agent/react/worker.ts:70


llm

llm: LLM

Defined in

packages/core/src/agent/react/worker.ts:63


maxInteractions

maxInteractions: number = 10

Defined in

packages/core/src/agent/react/worker.ts:66


outputParser

outputParser: ReActOutputParser

Defined in

packages/core/src/agent/react/worker.ts:68


reactChatFormatter

reactChatFormatter: ReActChatFormatter

Defined in

packages/core/src/agent/react/worker.ts:67


verbose

verbose: boolean

Defined in

packages/core/src/agent/react/worker.ts:64

Methods

_getResponse

_getResponse(currentReasoning, sources): AgentChatResponse

Get response.

Parameters

NameTypeDescription
currentReasoningBaseReasoningStep[]current reasoning steps
sourcesToolOutput[]tool outputs

Returns

AgentChatResponse

  • agent chat response

Defined in

packages/core/src/agent/react/worker.ts:249


_getTaskStepResponse

_getTaskStepResponse(agentResponse, step, isDone): TaskStepOutput

Get task step response.

Parameters

NameTypeDescription
agentResponseAgentChatResponseagent chat response
stepTaskSteptask step
isDonebooleanwhether the task is done

Returns

TaskStepOutput

  • task step output

Defined in

packages/core/src/agent/react/worker.ts:279


_processActions

_processActions(task, tools, output, isStreaming?): Promise<[BaseReasoningStep[], boolean]>

Process actions.

Parameters

NameTypeDefault valueDescription
taskTaskundefinedtask
toolsBaseTool[]undefinedtools
outputChatResponseundefinedchat response
isStreamingbooleanfalsewhether the chat response is streaming

Returns

Promise<[BaseReasoningStep[], boolean]>

  • [reasoning steps, is done]

Defined in

packages/core/src/agent/react/worker.ts:186


_runStep

_runStep(step, task, kwargs?): Promise<TaskStepOutput>

Run a task step.

Parameters

NameTypeDescription
stepTaskSteptask step
taskTasktask
kwargs?anykeyword arguments

Returns

Promise<TaskStepOutput>

  • task step output

Defined in

packages/core/src/agent/react/worker.ts:302


extractReasoningStep

extractReasoningStep(output, isStreaming): [string, BaseReasoningStep[], boolean]

Extract reasoning step from chat response.

Parameters

NameTypeDescription
outputChatResponsechat response
isStreamingbooleanwhether the chat response is streaming

Returns

[string, BaseReasoningStep[], boolean]

  • [message content, reasoning steps, is done]

Defined in

packages/core/src/agent/react/worker.ts:133


finalizeTask

finalizeTask(task, kwargs?): void

Finalize a task.

Parameters

NameTypeDescription
taskTasktask
kwargs?anykeyword arguments

Returns

void

Implementation of

AgentWorker.finalizeTask

Defined in

packages/core/src/agent/react/worker.ts:386


initializeStep

initializeStep(task, kwargs?): TaskStep

Initialize a task step.

Parameters

NameTypeDescription
taskTasktask
kwargs?anykeyword arguments

Returns

TaskStep

  • task step

Implementation of

AgentWorker.initializeStep

Defined in

packages/core/src/agent/react/worker.ts:106


runStep

runStep(step, task, kwargs?): Promise<TaskStepOutput>

Run a task step.

Parameters

NameTypeDescription
stepTaskSteptask step
taskTasktask
kwargs?anykeyword arguments

Returns

Promise<TaskStepOutput>

  • task step output

Implementation of

AgentWorker.runStep

Defined in

packages/core/src/agent/react/worker.ts:358


streamStep

streamStep(step, task, kwargs?): Promise<TaskStepOutput>

Run a task step.

Parameters

NameTypeDescription
stepTaskSteptask step
taskTasktask
kwargs?anykeyword arguments

Returns

Promise<TaskStepOutput>

  • task step output

Implementation of

AgentWorker.streamStep

Defined in

packages/core/src/agent/react/worker.ts:373