fix(server): send Hermes model selection via session/set_model
The real hermes acp binary treats session/set_config_option (configId
"model") as a silent no-op — it returns {"configOptions": []} for both
valid and invalid values — so routing model selection through it never
actually changed the active model. Switch applyHermesAcpModelSelection
to the unstable session/set_model capability (runtime.setSessionModel),
matching how GrokAcpSupport already selects its models.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
3 files changed
+26
-15
No files matched your search
@@ -55,9 +55,10 @@ describe("applyHermesAcpModelSelection", () => {
|
||||
Effect.gen(function* () {
|
||||
const modelCalls: Array<string> = [];
|
||||
const runtime = {
|
||||
setModel: (model: string) =>
|
||||
setSessionModel: (modelId: string) =>
|
||||
Effect.sync(() => {
|
||||
modelCalls.push(model);
|
||||
modelCalls.push(modelId);
|
||||
return {};
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -78,7 +79,7 @@ describe("applyHermesAcpModelSelection", () => {
|
||||
cause: new Error("set_model exploded"),
|
||||
});
|
||||
const runtime = {
|
||||
setModel: () => Effect.fail(acpFailure),
|
||||
setSessionModel: () => Effect.fail(acpFailure),
|
||||
};
|
||||
|
||||
const failure = yield* Effect.flip(
|
||||
|
||||
@@ -63,21 +63,27 @@ export interface HermesAcpModelSelectionErrorContext {
|
||||
readonly cause: EffectAcpErrors.AcpError;
|
||||
}
|
||||
|
||||
interface HermesAcpModelSelectionRuntime {
|
||||
readonly setModel: (model: string) => Effect.Effect<unknown, EffectAcpErrors.AcpError>;
|
||||
}
|
||||
type HermesAcpModelSelectionRuntime = Pick<
|
||||
AcpSessionRuntime.AcpSessionRuntime["Service"],
|
||||
"setSessionModel"
|
||||
>;
|
||||
|
||||
/**
|
||||
* Applies a model selection to a live Hermes ACP session. Hermes model ids
|
||||
* (e.g. `anthropic:claude-fable-5`) go to `session/set_model` verbatim —
|
||||
* there is no trait suffix to strip and no config-option fanout.
|
||||
* there is no trait suffix to strip and no reasoning metadata to attach.
|
||||
*
|
||||
* `session/set_config_option` is not usable here: the real `hermes acp`
|
||||
* binary treats configId `"model"` as a silent no-op (it always returns
|
||||
* `{ configOptions: [] }`, even for invalid values), so model changes must
|
||||
* go through the unstable `session/set_model` capability instead.
|
||||
*/
|
||||
export function applyHermesAcpModelSelection<E>(input: {
|
||||
readonly runtime: HermesAcpModelSelectionRuntime;
|
||||
readonly model: string;
|
||||
readonly mapError: (context: HermesAcpModelSelectionErrorContext) => E;
|
||||
}): Effect.Effect<void, E> {
|
||||
return input.runtime.setModel(input.model).pipe(
|
||||
return input.runtime.setSessionModel(input.model).pipe(
|
||||
Effect.asVoid,
|
||||
Effect.mapError((cause) => input.mapError({ cause })),
|
||||
);
|
||||
|
||||
@@ -113,7 +113,12 @@ it.layer(HermesTextGenerationTestLayer)("HermesTextGeneration", (it) => {
|
||||
stagedSummary: "M apps/server/src/textGeneration/HermesTextGeneration.ts",
|
||||
stagedPatch:
|
||||
"diff --git a/apps/server/src/textGeneration/HermesTextGeneration.ts b/apps/server/src/textGeneration/HermesTextGeneration.ts",
|
||||
modelSelection: createModelSelection(ProviderInstanceId.make("hermes"), "composer-2"),
|
||||
// The shared acp-mock-agent only allowlists grok-* ids for
|
||||
// session/set_model, so Hermes tests reuse them.
|
||||
modelSelection: createModelSelection(
|
||||
ProviderInstanceId.make("hermes"),
|
||||
"grok-mock-alt",
|
||||
),
|
||||
});
|
||||
|
||||
expect(generated.subject).toBe("Add generated commit message");
|
||||
@@ -136,9 +141,8 @@ it.layer(HermesTextGenerationTestLayer)("HermesTextGeneration", (it) => {
|
||||
expect(
|
||||
requests.some(
|
||||
(request) =>
|
||||
request.method === "session/set_config_option" &&
|
||||
request.params?.configId === "model" &&
|
||||
request.params?.value === "composer-2",
|
||||
request.method === "session/set_model" &&
|
||||
request.params?.modelId === "grok-mock-alt",
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
@@ -172,7 +176,7 @@ it.layer(HermesTextGenerationTestLayer)("HermesTextGeneration", (it) => {
|
||||
stagedPatch: "diff --git a/README.md b/README.md",
|
||||
modelSelection: {
|
||||
instanceId: ProviderInstanceId.make("hermes"),
|
||||
model: "default",
|
||||
model: "grok-build",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -196,7 +200,7 @@ it.layer(HermesTextGenerationTestLayer)("HermesTextGeneration", (it) => {
|
||||
message: "Fix the reconnect spinner after a resumed session.",
|
||||
modelSelection: {
|
||||
instanceId: ProviderInstanceId.make("hermes"),
|
||||
model: "default",
|
||||
model: "grok-build",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -229,7 +233,7 @@ it.layer(HermesTextGenerationTestLayer)("HermesTextGeneration", (it) => {
|
||||
"diff --git a/apps/server/src/textGeneration/HermesTextGeneration.ts b/apps/server/src/textGeneration/HermesTextGeneration.ts",
|
||||
modelSelection: {
|
||||
instanceId: ProviderInstanceId.make("hermes"),
|
||||
model: "default",
|
||||
model: "grok-build",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user