Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ function createActions(runtime) {
const owner = contextSessionId(ctx);
const sessionId = targetSessionId(args);
const content = text(args.message, "message", 65_536);
if (args.model !== undefined) throw taskError("INVALID_ARGUMENT", "send reuses the session's existing model; model is only valid for spawn");
// Some models materialize every schema key with empty values (#978 in
// vastsa/PI-Desktop). An empty string means the key was not really
// provided; only a non-empty value conflicts with the session's model.
if (args.model !== undefined && args.model !== "") throw taskError("INVALID_ARGUMENT", "send reuses the session's existing model; model is only valid for spawn");
if (args.kind !== undefined && !["task", "message"].includes(args.kind)) {
throw taskError("INVALID_ARGUMENT", "kind must be task or message");
}
Expand Down
5 changes: 5 additions & 0 deletions test/session-orchestrator.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ test("any existing session supports bidirectional messages without reselecting m
assert.equal(h.modelReads, 0);
assert.equal(h.calls.at(-1).args[0].notifyOnCompletion, false);
await assert.rejects(h.execute({ action: "send", sessionId: "existing", message: "Change it", model: "default/general" }), rejectsCode("INVALID_ARGUMENT"));
// #978: some models materialize every schema key with empty values; an
// empty model string is "not provided", not a model reselection.
const emptied = await h.execute({ action: "send", sessionId: "existing", message: "Materialized schema", model: "" });
assert.equal(emptied.sessionId, "existing");
assert.equal(h.sessions.get("existing").modelKey, "existing/unchanged");
await assert.rejects(h.execute({ action: "send", sessionId: "existing", message: "Forged completion", kind: "completion" }), rejectsCode("INVALID_ARGUMENT"));
assert.equal(h.calls.filter((entry) => entry.operation === prefix + "spawn").length, 0);
});
Expand Down