feat: log warnings and errors

old-agentic-v1^2
Philipp Burckhardt 2023-06-30 14:33:11 -04:00
rodzic c09c24ac66
commit 1273af0b06
2 zmienionych plików z 31 dodań i 15 usunięć

Wyświetl plik

@ -228,7 +228,7 @@ export class TerminalTaskTracker {
case TaskStatus.FAILED:
return [SYMBOLS.CROSS, red]
case TaskStatus.RETRYING:
return [SYMBOLS.WARNING, yellow]
return [this.getSpinnerSymbol(), yellow]
case TaskStatus.RUNNING:
default:
return [this.getSpinnerSymbol(), cyan]
@ -268,20 +268,24 @@ export class TerminalTaskTracker {
line = indent + gray(SYMBOLS.BAR_END)
}
if (output) {
if (status === TaskStatus.COMPLETED) {
const formattedOutput = this.stringify(output)
line +=
indent +
' ' +
gray(SYMBOLS.RIGHT_ARROW + SPACE + formattedOutput)
} else if (status === TaskStatus.FAILED) {
line +=
indent + ' ' + gray(SYMBOLS.RIGHT_ARROW + SPACE + red(output))
} else if (status === TaskStatus.RETRYING) {
line +=
indent + ' ' + gray(SYMBOLS.RIGHT_ARROW + SPACE + yellow(output))
}
const formattedOutput = this.stringify(output || '')
if (status === TaskStatus.COMPLETED) {
line +=
indent + ' ' + gray(SYMBOLS.RIGHT_ARROW + SPACE + formattedOutput)
} else if (status === TaskStatus.FAILED) {
line +=
indent +
' ' +
gray(SYMBOLS.RIGHT_ARROW) +
SPACE +
red(formattedOutput)
} else if (status === TaskStatus.RETRYING) {
line +=
indent +
' ' +
yellow(SYMBOLS.WARNING) +
SPACE +
gray(formattedOutput)
}
lines.push(line)

Wyświetl plik

@ -360,6 +360,12 @@ export abstract class BaseTask<
ctx.attemptNumber = err.attemptNumber + 1
ctx.metadata.error = err
this._eventEmitter.emit(TaskStatus.RETRYING, {
taskInputs: input,
taskOutput: err,
...ctx.metadata
})
if (err instanceof errors.ZodOutputValidationError) {
ctx.retryMessage = err.message
return
@ -383,6 +389,12 @@ export abstract class BaseTask<
// task for now.
return
} else {
this._eventEmitter.emit(TaskStatus.FAILED, {
taskInputs: input,
taskOutput: err,
...ctx.metadata
})
throw err
}
}