Skip to content

Commit 69ac5dc

Browse files
ScottN-PVclaude
andcommitted
fix(server): bound the model name a generation failure carries
The configured model name has no length limit, and error attributes stay bounded, so the error keeps at most its first 128 characters. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 95bbe59 commit 69ac5dc

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

‎apps/server/src/git/GitManager.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,40 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
973973
}),
974974
);
975975

976+
it.effect("generation failures bound a long configured model name", () =>
977+
Effect.gen(function* () {
978+
const repoDir = yield* makeTempDir("t3code-git-manager-");
979+
yield* initRepo(repoDir);
980+
NodeFS.writeFileSync(NodePath.join(repoDir, "README.md"), "changed\n");
981+
const model = `long-${"m".repeat(300)}`;
982+
const { manager } = yield* makeManager({
983+
serverSettings: {
984+
textGenerationModelSelection: {
985+
...DEFAULT_SERVER_SETTINGS.textGenerationModelSelection,
986+
model,
987+
},
988+
},
989+
textGeneration: {
990+
generateCommitMessage: () =>
991+
Effect.fail(
992+
new TextGenerationError({
993+
operation: "generateCommitMessage",
994+
detail: "Unsupported model",
995+
}),
996+
),
997+
},
998+
});
999+
const error = yield* runStackedAction(manager, { cwd: repoDir, action: "commit" }).pipe(
1000+
Effect.flip,
1001+
);
1002+
1003+
expect(error).toMatchObject({
1004+
_tag: "TextGenerationError",
1005+
modelSelection: { model: model.slice(0, 128) },
1006+
});
1007+
}),
1008+
);
1009+
9761010
it.effect("PR generation failures carry model context without creating a PR", () =>
9771011
Effect.gen(function* () {
9781012
const repoDir = yield* makeTempDir("t3code-git-manager-");

‎apps/server/src/git/GitManager.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ interface SourceControlTextGenerationSettings {
104104
readonly style: SourceControlWritingStyleSettings;
105105
}
106106

107+
// Error attributes stay bounded, and the configured model name has no length limit.
108+
const MAX_ERROR_MODEL_LENGTH = 128;
109+
107110
/** Adds the attempted model and the setting that chose it to a generation failure. */
108111
function withTextGenerationContext(
109112
error: TextGenerationError,
@@ -115,7 +118,7 @@ function withTextGenerationContext(
115118
...(error.cause !== undefined ? { cause: error.cause } : {}),
116119
modelSelection: {
117120
instanceId: settings.modelSelection.instanceId,
118-
model: settings.modelSelection.model,
121+
model: settings.modelSelection.model.slice(0, MAX_ERROR_MODEL_LENGTH).trimEnd(),
119122
},
120123
modelSetting: settings.modelSetting,
121124
});

0 commit comments

Comments
 (0)