turn(Parametersinput,options?):Promise<HarnessTurnResult<HarnessParsedOutput<OutputDefinition>>>
Returns
Promise<HarnessTurnResult<HarnessParsedOutput<OutputDefinition>>>
HarnessTurnOptions
Per-turn transport-neutral observation callbacks. Type Parameters
Properties
callbacks?
AI SDK lifecycle callbacks, chained after harness persistence work. onCancel?optionalcallbacks?:Readonly<{onFinish?:GenerateTextOnFinishCallback<TOOLS>;onStart?:GenerateTextOnStartCallback;onStepFinish?:GenerateTextOnStepFinishCallback<TOOLS>;onStepStart?:GenerateTextOnStepStartCallback<TOOLS>;onToolCallFinish?:GenerateTextOnToolCallFinishCallback<TOOLS>;onToolCallStart?:GenerateTextOnToolCallStartCallback<TOOLS>; }>
Runs once after cleanup when the caller-owned signal cancels a turn. ParametersoptionalonCancel?: (error) =>void|Promise<void>
Returns
void | Promise<void>
onError?
Runs once after cleanup for non-cancellation failures. ParametersoptionalonError?: (error) =>void|Promise<void>
Returns
void | Promise<void>
onOutput?
Runs once after the complete successful output has been persistently journaled. ParametersoptionalonOutput?: (output) =>void|Promise<void>
Returns
void | Promise<void>
onStepCommitted?
Runs after the completed step has been persistently journaled. ParametersoptionalonStepCommitted?: (step) =>void|Promise<void>
Returns
void | Promise<void>
signal?
Caller-owned cancellation signal passed to AI SDK without transport coupling. steps?optionalsignal?:AbortSignal
Persistent context supplied only by the harness run ledger.optionalsteps?:HarnessStepContext
HarnessTurnResult
Transport-neutral result of a completed turn. Type Parameters
Properties
finishReason
journalThroughreadonlyfinishReason:FinishReason
output?readonlyjournalThrough:number
Parsed AI SDK output when a structured output mode is configured. stepCountreadonlyoptionaloutput?:Output
textreadonlystepCount:number
usagereadonlytext:string
readonlyusage:HarnessUsage
HarnessUsage
Transport-safe aggregate token usage for a completed turn. Properties inputTokensoutputTokensreadonlyinputTokens:number|undefined
totalTokensreadonlyoutputTokens:number|undefined
readonlytotalTokens:number|undefined
HarnessStep
One completed model step, excluding provider request/response bodies and metadata. Properties finishReason
finishReason: FinishReason
journalThrough
journalThrough: number
number
number: number
text
text: string
toolCalls
toolCalls: readonlytoolResultsReadonly<{id:string;input:unknown;name:string; }>[]
toolResults: readonlyReadonly<{id:string;isError:boolean;name:string;output:unknown; }>[]
HarnessStepLimitError
Raised after the final allowed model step still requests executable tools. Constructors Constructornew HarnessStepLimitError(ParametersmaxSteps,completedSteps,lastToolCalls):HarnessStepLimitError
Returns
HarnessStepLimitError
Properties
cause?
codeoptionalcause?:unknown
completedStepsreadonlycode:"HARNESS_STEP_LIMIT"
lastToolCallsreadonlycompletedSteps:number
maxStepsreadonlylastToolCalls: readonlyReadonly<{id:string;name:string; }>[]
messagereadonlymaxSteps:number
message: string
name
name: string
stack?
stackTraceLimitoptionalstack?:string
ThestaticstackTraceLimit:number
Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.
Methods
captureStackTrace()
Creates astaticcaptureStackTrace(targetObject,constructorOpt?):void
.stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
Returns
void
prepareStackTrace()
ParametersstaticprepareStackTrace(err,stackTraces):any
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
HarnessProviderError
Stable provider-boundary error containing only allowlisted diagnostics. Constructors Constructornew HarnessProviderError(Parametersdiagnostics):HarnessProviderError
Returns
HarnessProviderError
Properties
cause?
codeoptionalcause?:unknown
diagnosticsreadonlycode:"HARNESS_PROVIDER_ERROR"
messagereadonlydiagnostics:HarnessProviderDiagnostics
message: string
name
name: string
stack?
stackTraceLimitoptionalstack?:string
ThestaticstackTraceLimit:number
Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.
Methods
captureStackTrace()
Creates astaticcaptureStackTrace(targetObject,constructorOpt?):void
.stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
Returns
void
prepareStackTrace()
ParametersstaticprepareStackTrace(err,stackTraces):any
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
HarnessProviderDiagnostics
Safe provider failure fields. Raw causes, URLs, headers, and bodies are never retained. Properties causeNamemodelIdreadonlycauseName:string
providerreadonlymodelId:string
retryable?readonlyprovider:string
statusCode?readonlyoptionalretryable?:boolean
readonlyoptionalstatusCode?:number
HarnessToolOutputError
Local tool failure used when a successful execution returns an unsafe output. Constructors Constructornew HarnessToolOutputError(ParameterstoolName):HarnessToolOutputError
Returns
HarnessToolOutputError
Properties
cause?
codeoptionalcause?:unknown
messagereadonlycode:"HARNESS_TOOL_OUTPUT_ERROR"
message: string
name
name: string
stack?
toolNameoptionalstack?:string
stackTraceLimitreadonlytoolName:string
ThestaticstackTraceLimit:number
Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.
Methods
captureStackTrace()
Creates astaticcaptureStackTrace(targetObject,constructorOpt?):void
.stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
Returns
void
prepareStackTrace()
ParametersstaticprepareStackTrace(err,stackTraces):any
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
HarnessCancellationError
Stable cancellation classification for an aborted caller-owned turn signal. Constructors Constructor
new HarnessCancellationError(): HarnessCancellationError
Returns
HarnessCancellationError
Properties
cause?
codeoptionalcause?:unknown
messagereadonlycode:"HARNESS_CANCELLED"
message: string
name
name: string
stack?
stackTraceLimitoptionalstack?:string
ThestaticstackTraceLimit:number
Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.
Methods
captureStackTrace()
Creates astaticcaptureStackTrace(targetObject,constructorOpt?):void
.stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
Returns
void
prepareStackTrace()
ParametersstaticprepareStackTrace(err,stackTraces):any
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
HarnessObserverError
Stable aggregate retaining a primary turn failure when its observer also fails. Constructors Constructornew HarnessObserverError(Parametersprimary,observer,phase):HarnessObserverError
Returns
HarnessObserverError
Properties
cause?
codeoptionalcause?:unknown
messagereadonlycode:"HARNESS_OBSERVER_ERROR"
message: string
name
name: string
observer
phasereadonlyobserver:unknown
primaryreadonlyphase:"cancel"|"error"
stack?readonlyprimary:unknown
stackTraceLimitoptionalstack?:string
ThestaticstackTraceLimit:number
Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.
Methods
captureStackTrace()
Creates astaticcaptureStackTrace(targetObject,constructorOpt?):void
.stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
Returns
void
prepareStackTrace()
ParametersstaticprepareStackTrace(err,stackTraces):any
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces