# Class Expert

Expert agent extending SimpleAgent with configuration-based setup.

#### Hierarchy (View Summary)

- SimpleAgent
  - Expert

- Defined in packages/nexus-agents/src/agents/experts/expert-factory.ts:61

##### Index

### Constructors

constructor

### Properties

id
role
capabilities
stateMachine
budgetTracker
adapter
logger
config
sharedState
history
systemPrompt
temperature
maxTokens
eventBus
emitMessageEvents
expertConfig

### Accessors

state
name
metadata

### Methods

initialize
execute
handleMessage
cleanup
hasCapability
transformError
complete
addToHistory
getHistory
clearHistory
getPruningMetrics
addContextItem
isContextPruningEnabled
isMemoryEnabled
getMemoryState
getRelevantMemories
flushMemory
recordLearning
recordPattern
recordResolution
findResolutionForError
getTaskLearnings
getTopExecutionPatterns
executeTask
buildPrompt

## Constructors

### constructor

- new Expert(options: BaseAgentOptions, config: ExpertConfig): Expert

  #### Parameters

  - options: BaseAgentOptions
  - config: ExpertConfig

  #### Returns Expert

  Overrides SimpleAgent.constructor

  - Defined in packages/nexus-agents/src/agents/experts/expert-factory.ts:64

## Properties

### `Readonly` id

id: string

Unique agent identifier

Inherited from SimpleAgent.id

- Defined in packages/nexus-agents/src/agents/base-agent.ts:94

### `Readonly` role

role: AgentRole

Agent role

Inherited from SimpleAgent.role

- Defined in packages/nexus-agents/src/agents/base-agent.ts:95

### `Readonly` capabilities

capabilities: readonly AgentCapability[]

Agent capabilities

Inherited from SimpleAgent.capabilities

- Defined in packages/nexus-agents/src/agents/base-agent.ts:96

### `Protected` `Readonly` stateMachine

stateMachine: AgentStateMachine

Inherited from SimpleAgent.stateMachine

- Defined in packages/nexus-agents/src/agents/base-agent.ts:97

### `Protected` `Readonly` budgetTracker

budgetTracker: ITokenBudgetTracker

Inherited from SimpleAgent.budgetTracker

- Defined in packages/nexus-agents/src/agents/base-agent.ts:98

### `Protected` adapter

adapter: IModelAdapter | undefined

Inherited from SimpleAgent.adapter

- Defined in packages/nexus-agents/src/agents/base-agent.ts:99

### `Protected` `Readonly` logger

logger: ILogger

Inherited from SimpleAgent.logger

- Defined in packages/nexus-agents/src/agents/base-agent.ts:100

### `Protected` config

config: AgentConfig | undefined

Inherited from SimpleAgent.config

- Defined in packages/nexus-agents/src/agents/base-agent.ts:101

### `Protected` sharedState

sharedState: Record<string, unknown> = {}

Inherited from SimpleAgent.sharedState

- Defined in packages/nexus-agents/src/agents/base-agent.ts:102

### `Protected` history

history: Message[] = []

Inherited from SimpleAgent.history

- Defined in packages/nexus-agents/src/agents/base-agent.ts:103

### `Protected` `Readonly` systemPrompt

systemPrompt: string | undefined

Inherited from SimpleAgent.systemPrompt

- Defined in packages/nexus-agents/src/agents/base-agent.ts:104

### `Protected` `Readonly` temperature

temperature: number

Inherited from SimpleAgent.temperature

- Defined in packages/nexus-agents/src/agents/base-agent.ts:105

### `Protected` `Readonly` maxTokens

maxTokens: number

Inherited from SimpleAgent.maxTokens

- Defined in packages/nexus-agents/src/agents/base-agent.ts:106

### `Protected` `Readonly` eventBus

eventBus: IEventBus

Inherited from SimpleAgent.eventBus

- Defined in packages/nexus-agents/src/agents/base-agent.ts:107

### `Protected` `Readonly` emitMessageEvents

emitMessageEvents: boolean

Inherited from SimpleAgent.emitMessageEvents

- Defined in packages/nexus-agents/src/agents/base-agent.ts:108

### `Readonly` expertConfig

expertConfig: ExpertConfig

- Defined in packages/nexus-agents/src/agents/experts/expert-factory.ts:62

## Accessors

### state

- get state(): AgentState

  Current state

  #### Returns AgentState

  Inherited from SimpleAgent.state

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:169

### name

- get name(): string

  Get the expert's name.

  #### Returns string

  - Defined in packages/nexus-agents/src/agents/experts/expert-factory.ts:72

### metadata

- get metadata(): Record<string, unknown> | undefined

  Get the expert's metadata.

  #### Returns Record<string, unknown> | undefined

  - Defined in packages/nexus-agents/src/agents/experts/expert-factory.ts:79

## Methods

### initialize

- initialize(ctx: AgentContext): Promise<Result<void, AgentError>>

  Initialize the agent with context.

  #### Parameters

  - ctx: AgentContext

    Agent context

  #### Returns Promise<Result<void, AgentError>>

  Result with void or AgentError

  Inherited from SimpleAgent.initialize

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:198

### execute

- execute(task: Task): Promise<Result<TaskResult, AgentError>>

  Execute a task.

  #### Parameters

  - task: Task

    Task to execute

  #### Returns Promise<Result<TaskResult, AgentError>>

  Result with TaskResult or AgentError

  Inherited from SimpleAgent.execute

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:211

### handleMessage

- handleMessage(msg: AgentMessage): Promise<Result<AgentResponse, AgentError>>

  Handle an inter-agent message.

  #### Parameters

  - msg: AgentMessage

    Message to handle

  #### Returns Promise<Result<AgentResponse, AgentError>>

  Result with AgentResponse or AgentError

  Inherited from SimpleAgent.handleMessage

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:243

### cleanup

- cleanup(): Promise<void>

  Cleanup agent resources.

  #### Returns Promise<void>

  Inherited from SimpleAgent.cleanup

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:258

### hasCapability

- hasCapability(capability: AgentCapability): boolean

  #### Parameters

  - capability: AgentCapability

  #### Returns boolean

  Inherited from SimpleAgent.hasCapability

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:274

### `Protected` transformError

- transformError(error: unknown, taskId: string): AgentError

  #### Parameters

  - error: unknown
  - taskId: string

  #### Returns AgentError

  Inherited from SimpleAgent.transformError

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:281

### `Protected` complete

- complete(
  request: CompletionRequest,
  ): Promise<Result<CompletionResponse, AgentError>>

  #### Parameters

  - request: CompletionRequest

  #### Returns Promise<Result<CompletionResponse, AgentError>>

  Inherited from SimpleAgent.complete

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:285

### `Protected` addToHistory

- addToHistory(message: Message): void

  #### Parameters

  - message: Message

  #### Returns void

  Inherited from SimpleAgent.addToHistory

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:307

### `Protected` getHistory

- getHistory(): Message[]

  #### Returns Message[]

  Inherited from SimpleAgent.getHistory

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:310

### `Protected` clearHistory

- clearHistory(): void

  #### Returns void

  Inherited from SimpleAgent.clearHistory

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:313

### getPruningMetrics

- getPruningMetrics(): Readonly<ContextPruningMetrics>

  #### Returns Readonly<ContextPruningMetrics>

  Inherited from SimpleAgent.getPruningMetrics

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:316

### `Protected` addContextItem

- addContextItem(
  content: string,
  priority?: 20 | 60 | 80 | 100 | 40,
  category?: "system" | "task" | "active",
  ): Promise<void>

  #### Parameters

  - content: string
  - `Optional` priority: 20 | 60 | 80 | 100 | 40
  - `Optional` category: "system" | "task" | "active"

  #### Returns Promise<void>

  Inherited from SimpleAgent.addContextItem

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:320

### isContextPruningEnabled

- isContextPruningEnabled(): boolean

  #### Returns boolean

  Inherited from SimpleAgent.isContextPruningEnabled

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:334

### isMemoryEnabled

- isMemoryEnabled(): boolean

  #### Returns boolean

  Inherited from SimpleAgent.isMemoryEnabled

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:337

### getMemoryState

- getMemoryState(): Readonly<AgentMemoryState> | null

  #### Returns Readonly<AgentMemoryState> | null

  Inherited from SimpleAgent.getMemoryState

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:340

### getRelevantMemories

- getRelevantMemories(): readonly TypedMemoryEntry<MemoryType>[]

  #### Returns readonly TypedMemoryEntry<MemoryType>[]

  Inherited from SimpleAgent.getRelevantMemories

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:343

### flushMemory

- flushMemory(): Promise<Result<void, AgentMemoryError>>

  #### Returns Promise<Result<void, AgentMemoryError>>

  Inherited from SimpleAgent.flushMemory

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:347

### `Protected` recordLearning

- recordLearning(learning: Omit<TaskLearning, "id" | "learnedAt">): void

  #### Parameters

  - learning: Omit<TaskLearning, "id" | "learnedAt">

  #### Returns void

  Inherited from SimpleAgent.recordLearning

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:360

### `Protected` recordPattern

- recordPattern(
  p: Omit<ExecutionPattern, "id" | "lastSeen" | "occurrences">,
  ): void

  #### Parameters

  - p: Omit<ExecutionPattern, "id" | "lastSeen" | "occurrences">

  #### Returns void

  Inherited from SimpleAgent.recordPattern

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:363

### `Protected` recordResolution

- recordResolution(r: Omit<ErrorResolution, "resolvedAt">): void

  #### Parameters

  - r: Omit<ErrorResolution, "resolvedAt">

  #### Returns void

  Inherited from SimpleAgent.recordResolution

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:366

### `Protected` findResolutionForError

- findResolutionForError(errorMessage: string): ErrorResolution | undefined

  #### Parameters

  - errorMessage: string

  #### Returns ErrorResolution | undefined

  Inherited from SimpleAgent.findResolutionForError

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:369

### `Protected` getTaskLearnings

- getTaskLearnings(taskType: string): readonly TaskLearning[]

  #### Parameters

  - taskType: string

  #### Returns readonly TaskLearning[]

  Inherited from SimpleAgent.getTaskLearnings

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:372

### `Protected` getTopExecutionPatterns

- getTopExecutionPatterns(limit?: number): readonly ExecutionPattern[]

  #### Parameters

  - limit: number = 10

  #### Returns readonly ExecutionPattern[]

  Inherited from SimpleAgent.getTopExecutionPatterns

  - Defined in packages/nexus-agents/src/agents/base-agent.ts:375

### `Protected` executeTask

- executeTask(task: Task): Promise<Result<TaskResult, AgentError>>

  Execute a task by sending it to the model.

  #### Parameters

  - task: Task

  #### Returns Promise<Result<TaskResult, AgentError>>

  Inherited from SimpleAgent.executeTask

  - Defined in packages/nexus-agents/src/agents/simple-agent.ts:21

### `Protected` buildPrompt

- buildPrompt(task: Task): Message[]

  Build prompt messages from a task.

  #### Parameters

  - task: Task

  #### Returns Message[]

  Inherited from SimpleAgent.buildPrompt

  - Defined in packages/nexus-agents/src/agents/simple-agent.ts:103