MCPcopy
hub / github.com/coder/mux / handleModelRefusalCompletion

Method handleModelRefusalCompletion

src/node/services/streamManager.ts:1964–1988  ·  view source on GitHub ↗
(
    workspaceId: WorkspaceId,
    streamInfo: WorkspaceStreamInfo,
    refusalFinishReason: string,
    fallbackNote?: string
  )

Source from the content-addressed store, hash-verified

1962 }
1963
1964 private async handleModelRefusalCompletion(
1965 workspaceId: WorkspaceId,
1966 streamInfo: WorkspaceStreamInfo,
1967 refusalFinishReason: string,
1968 fallbackNote?: string
1969 ): Promise<void> {
1970 const workspaceLog = this.getWorkspaceLogger(workspaceId, streamInfo);
1971 const streamMeta = await this.getStreamMetadata(streamInfo);
1972
1973 workspaceLog.error("Stream ended with a terminal refusal", {
1974 messageId: streamInfo.messageId,
1975 model: streamInfo.model,
1976 finishReason: streamInfo.terminalFinishReason,
1977 rawFinishReason: streamInfo.terminalRawFinishReason,
1978 durationMs: streamMeta.duration,
1979 partsCount: streamInfo.parts.length,
1980 fallbackNote,
1981 });
1982
1983 await this.handleStreamFailure(
1984 workspaceId,
1985 streamInfo,
1986 new ModelRefusalError(streamInfo.model, refusalFinishReason, fallbackNote)
1987 );
1988 }
1989
1990 private async getRefusalUsageSnapshot(streamInfo: WorkspaceStreamInfo): Promise<{
1991 usage?: LanguageModelV2Usage;

Callers 1

Calls 3

getWorkspaceLoggerMethod · 0.95
getStreamMetadataMethod · 0.95
handleStreamFailureMethod · 0.95

Tested by

no test coverage detected