mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-01 22:23:07 +00:00
fix(server): an option a session drops when opening is not brought back by a configured default
The opening snapshot merged defaults over the options after the session's openOptionsPatch had removed a key. Defaults now merge into what the session was given and the patch applies after.
This commit is contained in:
@@ -12895,6 +12895,15 @@ describe("agent options", () => {
|
||||
expect(published.every((options) => options?.service_tier === "slow")).toBe(true);
|
||||
});
|
||||
|
||||
test("an option the session dropped when opening does not come back from a configured default", async () => {
|
||||
const { manager, agentId } = await createOptionsAgent(undefined, { service_tier: null });
|
||||
|
||||
const agent = manager.getAgent(agentId);
|
||||
expect(agent?.effectiveOptions).toEqual({});
|
||||
await manager.markAgentUnread(agentId);
|
||||
expect(toAgentPayload(manager.getAgent(agentId)!).options).toEqual({});
|
||||
});
|
||||
|
||||
test("an option without a control is settable through the patch and readable in the snapshot", async () => {
|
||||
const { manager, client, storage, agentId } = await createOptionsAgent();
|
||||
|
||||
|
||||
@@ -3910,6 +3910,12 @@ export class AgentManager {
|
||||
resolvedAgentId,
|
||||
session,
|
||||
config,
|
||||
// Defaults merge into what the session was given; what it reports it ended up with comes
|
||||
// after, so an option it dropped does not come back from a default.
|
||||
effectiveOptions: applyProviderOptionsPatch({
|
||||
options: this.effectiveOptionsFor(openedConfig.provider, openedConfig.providerOptions),
|
||||
patch: session.openOptionsPatch ?? {},
|
||||
}),
|
||||
now,
|
||||
durableTimelineHasRows,
|
||||
options,
|
||||
@@ -4054,6 +4060,7 @@ export class AgentManager {
|
||||
resolvedAgentId: string;
|
||||
session: AgentSession;
|
||||
config: AgentSessionConfig;
|
||||
effectiveOptions: ProviderOptions;
|
||||
now: Date;
|
||||
durableTimelineHasRows: boolean;
|
||||
options:
|
||||
@@ -4073,7 +4080,15 @@ export class AgentManager {
|
||||
}
|
||||
| undefined;
|
||||
}): ActiveManagedAgent {
|
||||
const { resolvedAgentId, session, config, now, durableTimelineHasRows, options } = params;
|
||||
const {
|
||||
resolvedAgentId,
|
||||
session,
|
||||
config,
|
||||
effectiveOptions,
|
||||
now,
|
||||
durableTimelineHasRows,
|
||||
options,
|
||||
} = params;
|
||||
return {
|
||||
id: resolvedAgentId,
|
||||
provider: config.provider,
|
||||
@@ -4085,7 +4100,7 @@ export class AgentManager {
|
||||
capabilities: session.capabilities,
|
||||
config,
|
||||
// What the session opened with. Provider defaults edited later reach it when it next opens.
|
||||
effectiveOptions: this.effectiveOptionsFor(config.provider, config.providerOptions),
|
||||
effectiveOptions,
|
||||
runtimeInfo: undefined,
|
||||
lifecycle: "initializing",
|
||||
createdAt: options?.createdAt ?? now,
|
||||
|
||||
Reference in New Issue
Block a user