Identify built-in generation preparation failures
This commit is contained in:
@@ -498,7 +498,7 @@ func TestRunnerRunPreparedReleasesAdmissionAcrossExecutionErrors(t *testing.T) {
|
||||
}},
|
||||
},
|
||||
repairer: &fakeRepairer{err: repairInvalidRequest},
|
||||
wantError: ErrInvalidRequest,
|
||||
wantError: ErrLLMGenerate,
|
||||
wantSource: repairInvalidRequest,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"go.maximumdirect.net/promptkit/internal/capacity"
|
||||
"go.maximumdirect.net/promptkit/internal/defaults"
|
||||
"go.maximumdirect.net/promptkit/internal/domain"
|
||||
"go.maximumdirect.net/promptkit/internal/generation"
|
||||
"go.maximumdirect.net/promptkit/internal/jsonvalue"
|
||||
"go.maximumdirect.net/promptkit/internal/llm"
|
||||
"go.maximumdirect.net/promptkit/internal/observation"
|
||||
@@ -269,6 +270,9 @@ func (r *Runner) executePreparedRun(
|
||||
}
|
||||
|
||||
func wrapGenerationError(err error) error {
|
||||
if _, ok := err.(*generation.PreparationError); ok {
|
||||
return &OperationError{Category: ErrInvalidRequest, Cause: err}
|
||||
}
|
||||
return &OperationError{Category: ErrLLMGenerate, Cause: err}
|
||||
}
|
||||
|
||||
|
||||
@@ -2074,7 +2074,7 @@ func TestRunnerRunCancellationPreservesGenerationCategory(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunnerRunLLMInvalidRequestMapsToUsecaseInvalidRequest(t *testing.T) {
|
||||
func TestRunnerRunInjectedInvalidRequestRemainsGenerationFailure(t *testing.T) {
|
||||
runner := NewRunner(
|
||||
&fakePromptRepo{def: promptDef(domain.FormatText, domain.ValidationNone, 0)},
|
||||
&fakeExecutionProfileRepo{profiles: map[string]*domain.ExecutionProfile{"exec": defaultExecutionProfile()}},
|
||||
@@ -2089,11 +2089,8 @@ func TestRunnerRunLLMInvalidRequestMapsToUsecaseInvalidRequest(t *testing.T) {
|
||||
ProfileID: "exec",
|
||||
Inputs: singleInputRef(),
|
||||
})
|
||||
if !errors.Is(err, ErrInvalidRequest) {
|
||||
t.Fatalf("expected ErrInvalidRequest, got %v", err)
|
||||
}
|
||||
if errors.Is(err, ErrLLMGenerate) {
|
||||
t.Fatalf("did not expect ErrLLMGenerate, got %v", err)
|
||||
if !errors.Is(err, ErrLLMGenerate) || !errors.Is(err, llm.ErrInvalidRequest) {
|
||||
t.Fatalf("expected generation error retaining cause, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -210,6 +210,9 @@ func (t *SmokeTester) runInference(
|
||||
report.Failure = generation.ClassifyFailure(contextErr)
|
||||
return finish(contextErr)
|
||||
}
|
||||
if evidence.PreparationFailed && generationErr != nil {
|
||||
return nil, &OperationError{Category: ErrInvalidRequest, Cause: generationErr}
|
||||
}
|
||||
if generationErr != nil {
|
||||
report.Failure = generation.ClassifyFailure(generationErr)
|
||||
report.Completed = true
|
||||
|
||||
Reference in New Issue
Block a user