mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 17:51:22 +00:00
fix: use target agent dir for directive persistence
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
clearRuntimeAuthProfileStoreSnapshots,
|
||||
replaceRuntimeAuthProfileStoreSnapshots,
|
||||
} from "../../agents/auth-profiles.js";
|
||||
import { resolveAgentDir, resolveSessionAgentId } from "../../agents/agent-scope.js";
|
||||
import type { ModelAliasIndex } from "../../agents/model-selection.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import type { SessionEntry } from "../../config/sessions.js";
|
||||
@@ -105,6 +106,8 @@ beforeEach(() => {
|
||||
store: { version: 1, profiles: {} },
|
||||
},
|
||||
]);
|
||||
vi.mocked(resolveAgentDir).mockReset().mockReturnValue(TEST_AGENT_DIR);
|
||||
vi.mocked(resolveSessionAgentId).mockReset().mockReturnValue("main");
|
||||
liveModelSwitchMocks.requestLiveSessionModelSwitch.mockReset().mockReturnValue(false);
|
||||
queueMocks.refreshQueuedFollowupSession.mockReset();
|
||||
});
|
||||
@@ -475,6 +478,23 @@ describe("/model chat UX", () => {
|
||||
expect(sessionEntry.authProfileOverride).toBe(OPENAI_DATE_PROFILE_ID);
|
||||
});
|
||||
|
||||
it("resolves agentDir from the target session agent before wrapper agentDir", async () => {
|
||||
vi.mocked(resolveSessionAgentId).mockReturnValue("target");
|
||||
vi.mocked(resolveAgentDir).mockReturnValue("/tmp/target-agent");
|
||||
|
||||
await persistModelDirectiveForTest({
|
||||
command: "/model openai/gpt-4o hello",
|
||||
allowedModelKeys: ["openai/gpt-4o"],
|
||||
sessionEntry: createSessionEntry(),
|
||||
});
|
||||
|
||||
expect(resolveSessionAgentId).toHaveBeenCalledWith({
|
||||
sessionKey: "agent:main:dm:1",
|
||||
config: expect.any(Object),
|
||||
});
|
||||
expect(resolveAgentDir).toHaveBeenCalledWith(expect.any(Object), "target");
|
||||
});
|
||||
|
||||
it("persists explicit auth profiles after @YYYYMMDD version suffixes in mixed-content messages", async () => {
|
||||
const { sessionEntry } = await persistModelDirectiveForTest({
|
||||
command: `/model custom/vertex-ai_claude-haiku-4-5@${OPENAI_DATE_PROFILE_ID}@work hello`,
|
||||
|
||||
@@ -76,7 +76,7 @@ export async function persistInlineDirectives(params: {
|
||||
const activeAgentId = sessionKey
|
||||
? resolveSessionAgentId({ sessionKey, config: cfg })
|
||||
: resolveDefaultAgentId(cfg);
|
||||
const agentDir = params.agentDir ?? resolveAgentDir(cfg, activeAgentId);
|
||||
const agentDir = resolveAgentDir(cfg, activeAgentId) ?? params.agentDir;
|
||||
|
||||
if (sessionEntry && sessionStore && sessionKey) {
|
||||
const prevElevatedLevel =
|
||||
|
||||
Reference in New Issue
Block a user