Capture completed conversation exchanges

This commit is contained in:
2026-11-14 01:18:55 +00:00
parent 26530808e0
commit 04569e44df
7 changed files with 126 additions and 4 deletions

View File

@@ -165,7 +165,7 @@ func (r *Runner) Run(ctx context.Context, req domain.RunRequest) (*domain.RunRes
}
directAPIKey := state.effectiveModel.APIKey
return r.executePreparedRun(ctx, operation.run, directAPIKey, state.transientRetries, runID, start, func(
return r.executePreparedRun(ctx, operation.run, operation.capture, operation.parent, directAPIKey, state.transientRetries, runID, start, func(
ctx context.Context,
artifact *domain.Artifact,
attemptsUsed int,
@@ -185,6 +185,8 @@ type preparedValidationFunc func(
func (r *Runner) executePreparedRun(
ctx context.Context,
prepared *domain.PreparedRun,
capture bool,
parent *domain.Exchange,
directAPIKey string,
transientRetries uint64,
runID string,
@@ -254,8 +256,14 @@ func (r *Runner) executePreparedRun(
end := time.Now().UTC()
executionTarget.APIKey = ""
var exchange *domain.Exchange
if capture {
exchange = domain.CaptureExchange(parent, runID, prepared.Messages[parent.MessageCount():], genResp.Content)
}
return &domain.RunResult{
Exchange: exchange,
ParentRunID: prepared.ParentRunID,
RunID: runID,
Artifact: outputArtifact,
RawOutput: genResp.Content,