Keep progress writes outside model deadlines
This commit is contained in:
@@ -13,7 +13,6 @@ import (
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/runner"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/structuredoutput"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/modules"
|
||||
pk "go.maximumdirect.net/promptkit"
|
||||
)
|
||||
|
||||
func executePipeline(ctx context.Context, loaded *processInputs, prepared *preparedProcess, normalized *schema.Transcript, warn func(error), progress func(string)) (processResult, error) {
|
||||
@@ -28,12 +27,8 @@ func executePipeline(ctx context.Context, loaded *processInputs, prepared *prepa
|
||||
hooks = observer.Hooks()
|
||||
}
|
||||
if progress != nil {
|
||||
observe := hooks.OnEventWithCall
|
||||
hooks.OnEventWithCall = func(callID uint64, coordinates structuredoutput.DiagnosticContext, event pk.ExecutionEvent) {
|
||||
if observe != nil {
|
||||
observe(callID, coordinates, event)
|
||||
}
|
||||
reportModelProgress(progress, coordinates, event)
|
||||
hooks.OnProgress = func(coordinates structuredoutput.DiagnosticContext, counts *outcomes.ExecutionCounts, err error) {
|
||||
reportModelProgress(progress, coordinates, counts, err)
|
||||
}
|
||||
}
|
||||
for i := range specs {
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/core/reporting"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/outcomes"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/runner"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/structuredoutput"
|
||||
pk "go.maximumdirect.net/promptkit"
|
||||
)
|
||||
|
||||
func runnerProgress(progress func(string)) func(runner.Progress) {
|
||||
@@ -31,8 +31,8 @@ func runnerProgress(progress func(string)) func(runner.Progress) {
|
||||
}
|
||||
}
|
||||
|
||||
func reportModelProgress(progress func(string), coordinates structuredoutput.DiagnosticContext, event pk.ExecutionEvent) {
|
||||
if coordinates.StageIndex == nil || (event.Kind != pk.ExecutionStarted && event.Kind != pk.ExecutionFinished) {
|
||||
func reportModelProgress(progress func(string), coordinates structuredoutput.DiagnosticContext, counts *outcomes.ExecutionCounts, err error) {
|
||||
if coordinates.StageIndex == nil {
|
||||
return
|
||||
}
|
||||
location := progressLocation(*coordinates.StageIndex, coordinates.ModuleKey, coordinates.StageID, coordinates.SectionIndex)
|
||||
@@ -49,11 +49,18 @@ func reportModelProgress(progress func(string), coordinates structuredoutput.Dia
|
||||
}
|
||||
operation += fmt.Sprintf(" turn %d", *coordinates.RepairAttempt)
|
||||
}
|
||||
if event.Kind == pk.ExecutionStarted {
|
||||
if counts == nil {
|
||||
progress(fmt.Sprintf("%s %s started", location, operation))
|
||||
} else {
|
||||
progress(fmt.Sprintf("%s %s finished (%s, %d provider attempts)", location, operation, event.Outcome, event.Attempts))
|
||||
return
|
||||
}
|
||||
outcome := "completed"
|
||||
if err != nil {
|
||||
outcome = "failed"
|
||||
}
|
||||
if counts.Available {
|
||||
outcome += fmt.Sprintf(", %d provider attempts", counts.ProviderAttempts)
|
||||
}
|
||||
progress(fmt.Sprintf("%s %s finished (%s)", location, operation, outcome))
|
||||
}
|
||||
|
||||
func progressLocation(index int, module string, id *string, section *int) string {
|
||||
|
||||
Reference in New Issue
Block a user