batchstore: surface backend errors from Submit as failed job status
executeJob was only capturing 'assistant' events from core.Submit. Backend errors emit an 'error' event that was silently dropped, causing jobs with nonexistent models to show status=done with empty result instead of status=failed.
This commit is contained in:
parent
9a51d287f7
commit
181e629009
|
|
@ -288,10 +288,13 @@ func (s *BatchStore) executeJob(ctx context.Context, job *batchJob) (string, err
|
|||
prompt += "\n\nRespond with valid JSON only, no prose."
|
||||
}
|
||||
|
||||
var replyBuf strings.Builder
|
||||
var replyBuf, errBuf strings.Builder
|
||||
core.Submit(ctx, prompt, func(ev agent.Event) {
|
||||
if ev.Role == "assistant" {
|
||||
switch ev.Role {
|
||||
case "assistant":
|
||||
replyBuf.WriteString(ev.Content)
|
||||
case "error":
|
||||
errBuf.WriteString(ev.Content)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -306,6 +309,9 @@ func (s *BatchStore) executeJob(ctx context.Context, job *batchJob) (string, err
|
|||
if ctx.Err() != nil {
|
||||
return "", ctx.Err()
|
||||
}
|
||||
if errBuf.Len() > 0 {
|
||||
return "", fmt.Errorf("%s", strings.TrimSpace(errBuf.String()))
|
||||
}
|
||||
return replyBuf.String(), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in New Issue