@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
31 lines • 1.32 kB
JavaScript
import { redactSecrets } from "../sensitive-output.js";
const EXCERPT_LIMIT = 500;
/**
* A model configuration error is never retried or fallen back: another model would answer a request the caller did
* not make (senpi#4282). The provider stream classified the raw body and redacted it (`sanitizeProviderErrorMessage`
* in pi-ai), so only the typed cause is read here, never the redacted text.
*/
export function isModelConfigFailure(message) {
return message.errorCause?.type === "model_config";
}
export function createModelConfigErrorReporter(logger, emit) {
const reported = new Set();
return {
report(message, sessionId) {
const model = `${message.provider}/${message.model}`;
const key = `${sessionId}\u0000${model}`;
if (reported.has(key))
return;
reported.add(key);
const errorMessage = redactSecrets(message.errorMessage ?? "");
logger.warn("model_config_error", { model, provider: message.provider, errorMessage });
emit({
type: "model_config_error",
model,
provider: message.provider,
errorExcerpt: errorMessage.slice(0, EXCERPT_LIMIT),
});
},
};
}
//# sourceMappingURL=model-config-error.js.map