Skip to content

Commit b7470ce

Browse files
authored
Merge pull request #48 from pylon-code/fix/prime-agent-0-7-3-adoption
fix(prime-agent): adopt 0.7.3 and explain a rejected model selection
2 parents c2dc08e + 64e1710 commit b7470ce

5 files changed

Lines changed: 63 additions & 19 deletions

File tree

apps/server/src/provider/prime/PrimeAgentDaemonSessionRuntime.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ function fixture(options?: {
159159
readonly omitRefine?: boolean;
160160
readonly abortCompactionImpl?: () => Promise<unknown>;
161161
readonly setAutoCompactionImpl?: (enabled: boolean) => Promise<unknown>;
162+
readonly setModelImpl?: (provider: string, modelId: string) => Promise<unknown>;
162163
}) {
163164
const captures: Captures = {
164165
order: [],
@@ -412,6 +413,7 @@ function fixture(options?: {
412413
}
413414
setModel(provider: string, modelId: string): Promise<unknown> {
414415
captures.connectionCalls.push({ method: "setModel", args: [provider, modelId] });
416+
if (options?.setModelImpl) return options.setModelImpl(provider, modelId);
415417
return Promise.resolve({
416418
provider,
417419
id: modelId,
@@ -1695,6 +1697,25 @@ describe("PrimeAgentDaemonSessionRuntime", () => {
16951697
),
16961698
);
16971699

1700+
it.effect("reports a rejected model selection without leaking Prime's native error", () =>
1701+
Effect.scoped(
1702+
Effect.gen(function* () {
1703+
// A Prime release can drop a model id the thread still selects durably.
1704+
const { make } = fixture({
1705+
setModelImpl: () =>
1706+
Promise.reject(new Error("unknown model cerebras/zai-glm-4.7 at /native/secret/path")),
1707+
});
1708+
const runtime = yield* make();
1709+
1710+
const error = yield* runtime.setModel("cerebras/zai-glm-4.7").pipe(Effect.flip);
1711+
1712+
expect(error).toMatchObject({ operation: "set-model", reason: "request-failed" });
1713+
expect(error.detail).toContain("no longer exist in Prime Agent's catalog");
1714+
expect(error.detail).not.toContain("/native/secret/path");
1715+
}),
1716+
),
1717+
);
1718+
16981719
it.effect("discovers only configured catalog models and strips native fields", () =>
16991720
Effect.scoped(
17001721
Effect.gen(function* () {

apps/server/src/provider/prime/PrimeAgentDaemonSessionRuntime.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3094,7 +3094,15 @@ export const makePrimeAgentDaemonSessionRuntime = Effect.fn("makePrimeAgentDaemo
30943094
const method = yield* requireMethod("set-model", connection!.setModel);
30953095
const output = yield* Effect.tryPromise({
30963096
try: () => method.call(connection, selected.provider, selected.modelId),
3097-
catch: () => runtimeError("set-model", "request-failed", "The daemon model switch failed."),
3097+
catch: () =>
3098+
runtimeError(
3099+
"set-model",
3100+
"request-failed",
3101+
// A Prime release can drop a model id from its catalog, which rejects a
3102+
// durable Pylon selection here rather than at discovery. Name that cause
3103+
// without copying Prime's native error text across the boundary.
3104+
"Prime Agent rejected the selected model. It may no longer exist in Prime Agent's catalog; select another model.",
3105+
),
30983106
});
30993107
const decoded = decodeModel(output);
31003108
if (Option.isNone(decoded)) {

0 commit comments

Comments
 (0)