Stop Pi metadata tasks from cluttering session history (#1999)
* fix: 避免内部 Pi Agent 持久化会话 * test: 聚焦 Pi 会话持久化行为
This commit is contained in:
@@ -82,6 +82,29 @@ test("forwards launch-context env to the Pi process launch", async () => {
|
|||||||
await session.close();
|
await session.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("starts internal Pi agents without persisting a native session", async () => {
|
||||||
|
const pi = new FakePi();
|
||||||
|
const client = createClient(pi);
|
||||||
|
const session = await client.createSession(createConfig({ internal: true }));
|
||||||
|
|
||||||
|
expect(pi.recordedLaunches[0]).toMatchObject({
|
||||||
|
noSession: true,
|
||||||
|
argv: expect.arrayContaining(["--no-session"]),
|
||||||
|
});
|
||||||
|
|
||||||
|
await session.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("keeps normal Pi agent sessions persisted", async () => {
|
||||||
|
const pi = new FakePi();
|
||||||
|
const client = createClient(pi);
|
||||||
|
const session = await client.createSession(createConfig());
|
||||||
|
|
||||||
|
expect(pi.recordedLaunches[0]?.argv).not.toContain("--no-session");
|
||||||
|
|
||||||
|
await session.close();
|
||||||
|
});
|
||||||
|
|
||||||
class SessionEvents {
|
class SessionEvents {
|
||||||
private readonly events: AgentStreamEvent[] = [];
|
private readonly events: AgentStreamEvent[] = [];
|
||||||
private readonly waiters: Array<{
|
private readonly waiters: Array<{
|
||||||
|
|||||||
@@ -1996,6 +1996,7 @@ export class PiRpcAgentClient implements AgentClient {
|
|||||||
model: config.model,
|
model: config.model,
|
||||||
thinkingOptionId:
|
thinkingOptionId:
|
||||||
normalizePiThinkingOption(config.thinkingOptionId) ?? DEFAULT_PI_THINKING_LEVEL,
|
normalizePiThinkingOption(config.thinkingOptionId) ?? DEFAULT_PI_THINKING_LEVEL,
|
||||||
|
noSession: config.internal === true,
|
||||||
systemPrompt: composeSystemPromptParts(
|
systemPrompt: composeSystemPromptParts(
|
||||||
config.systemPrompt,
|
config.systemPrompt,
|
||||||
config.daemonAppendSystemPrompt,
|
config.daemonAppendSystemPrompt,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export interface PiRuntimeLaunch {
|
|||||||
model?: string;
|
model?: string;
|
||||||
thinkingOptionId?: string;
|
thinkingOptionId?: string;
|
||||||
session?: string;
|
session?: string;
|
||||||
|
noSession?: boolean;
|
||||||
systemPrompt?: string;
|
systemPrompt?: string;
|
||||||
mcpConfigPath?: string;
|
mcpConfigPath?: string;
|
||||||
extensionPaths?: string[];
|
extensionPaths?: string[];
|
||||||
@@ -26,6 +27,7 @@ export interface PiStartSessionInput {
|
|||||||
model?: string;
|
model?: string;
|
||||||
thinkingOptionId?: string;
|
thinkingOptionId?: string;
|
||||||
session?: string;
|
session?: string;
|
||||||
|
noSession?: boolean;
|
||||||
systemPrompt?: string;
|
systemPrompt?: string;
|
||||||
mcpConfigPath?: string;
|
mcpConfigPath?: string;
|
||||||
extensionPaths?: string[];
|
extensionPaths?: string[];
|
||||||
@@ -79,7 +81,9 @@ export function buildPiLaunch(input: {
|
|||||||
if (input.session.thinkingOptionId) {
|
if (input.session.thinkingOptionId) {
|
||||||
argv.push("--thinking", input.session.thinkingOptionId);
|
argv.push("--thinking", input.session.thinkingOptionId);
|
||||||
}
|
}
|
||||||
if (input.session.session) {
|
if (input.session.noSession) {
|
||||||
|
argv.push("--no-session");
|
||||||
|
} else if (input.session.session) {
|
||||||
argv.push("--session", input.session.session);
|
argv.push("--session", input.session.session);
|
||||||
}
|
}
|
||||||
const systemPrompt = input.session.systemPrompt?.trim();
|
const systemPrompt = input.session.systemPrompt?.trim();
|
||||||
@@ -106,6 +110,7 @@ export function buildPiLaunch(input: {
|
|||||||
model: input.session.model,
|
model: input.session.model,
|
||||||
thinkingOptionId: input.session.thinkingOptionId,
|
thinkingOptionId: input.session.thinkingOptionId,
|
||||||
session: input.session.session,
|
session: input.session.session,
|
||||||
|
noSession: input.session.noSession,
|
||||||
systemPrompt,
|
systemPrompt,
|
||||||
mcpConfigPath: input.session.mcpConfigPath,
|
mcpConfigPath: input.session.mcpConfigPath,
|
||||||
extensionPaths: input.session.extensionPaths,
|
extensionPaths: input.session.extensionPaths,
|
||||||
|
|||||||
Reference in New Issue
Block a user