diff --git a/src/domain/analysisErrorProjection.ts b/src/domain/analysisErrorProjection.ts index 7bbc8477c54..a03c72f9f92 100644 --- a/src/domain/analysisErrorProjection.ts +++ b/src/domain/analysisErrorProjection.ts @@ -83,6 +83,21 @@ const relatedInputDetails = ( : { related_providers: [...related.providers] }), }); +const projectTopLevelError = ( + error: AnalysisError, + callerLifetime: AnalysisCallerLifetime, + omit?: "captured-output" | "partial-observation", +): AnalysisErrorProjection => + projectError( + error, + { + capturedOutput: omit !== "captured-output", + partialObservation: omit !== "partial-observation", + secondary: true, + }, + callerLifetime, + ); + /** * Project expected failures into exhaustive, secret-safe caller fields. The * default describes a continuing caller, such as an MCP connection, and is @@ -93,46 +108,21 @@ const relatedInputDetails = ( export const projectAnalysisError = ( error: AnalysisError, callerLifetime: AnalysisCallerLifetime = "continuing", -): AnalysisErrorProjection => - projectError( - error, - { - capturedOutput: true, - partialObservation: true, - secondary: true, - }, - callerLifetime, - ); +): AnalysisErrorProjection => projectTopLevelError(error, callerLifetime); /** Cleanup history references output retained by its enclosing error owner. */ export const projectAnalysisErrorWithoutCapturedOutput = ( error: AnalysisError, callerLifetime: AnalysisCallerLifetime = "continuing", ): AnalysisErrorProjection => - projectError( - error, - { - capturedOutput: false, - partialObservation: true, - secondary: true, - }, - callerLifetime, - ); + projectTopLevelError(error, callerLifetime, "captured-output"); /** Bounded fallback when the completed observation itself cannot be delivered. */ export const projectAnalysisErrorWithoutPartialObservation = ( error: AnalysisError, callerLifetime: AnalysisCallerLifetime = "continuing", ): AnalysisErrorProjection => - projectError( - error, - { - capturedOutput: true, - partialObservation: false, - secondary: true, - }, - callerLifetime, - ); + projectTopLevelError(error, callerLifetime, "partial-observation"); export interface UnretainedEvidenceCandidate { readonly field: "partial_observation" | "completed_observation";