feat(coding-agent): expose session metadata to bash tools (#6967)
This commit is contained in:
@@ -92,4 +92,40 @@ describe("createAgentSession session manager defaults", () => {
|
||||
|
||||
session.dispose();
|
||||
});
|
||||
|
||||
it("exposes current session state to the built-in bash tool", async () => {
|
||||
const model = getModel("anthropic", "claude-sonnet-4-5");
|
||||
expect(model).toBeTruthy();
|
||||
|
||||
const { session } = await createAgentSession({
|
||||
cwd,
|
||||
agentDir,
|
||||
model: model!,
|
||||
thinkingLevel: "high",
|
||||
});
|
||||
expect(session.sessionFile).toBeTruthy();
|
||||
expect(session.systemPrompt).toContain(
|
||||
"Inspect PI_* environment variables for current model and session details.",
|
||||
);
|
||||
|
||||
const bashTool = session.agent.state.tools.find((tool) => tool.name === "bash");
|
||||
expect(bashTool).toBeTruthy();
|
||||
const result = await bashTool!.execute("test", {
|
||||
command: `printf '%s\\n' "$PI_SESSION_ID" "$PI_SESSION_FILE" "$PI_PROVIDER" "$PI_MODEL" "$PI_REASONING_LEVEL"`,
|
||||
});
|
||||
const output = result.content
|
||||
.filter((item): item is { type: "text"; text: string } => item.type === "text")
|
||||
.map((item) => item.text)
|
||||
.join("");
|
||||
|
||||
expect(output.trim().split("\n")).toEqual([
|
||||
session.sessionId,
|
||||
session.sessionFile,
|
||||
model!.provider,
|
||||
model!.id,
|
||||
session.thinkingLevel,
|
||||
]);
|
||||
|
||||
session.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user