@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `pi.getAllTools()` to expose each tool's `promptGuidelines` for extensions that need per-tool guideline attribution ([#4879](https://github.com/earendil-works/pi/issues/4879)).
|
||||||
- Fixed follow-up messages queued by `agent_end` extension handlers to drain before the agent becomes idle ([#5115](https://github.com/earendil-works/pi-mono/pull/5115) by [@DanielThomas](https://github.com/DanielThomas)).
|
- Fixed follow-up messages queued by `agent_end` extension handlers to drain before the agent becomes idle ([#5115](https://github.com/earendil-works/pi-mono/pull/5115) by [@DanielThomas](https://github.com/DanielThomas)).
|
||||||
- Fixed extension input events to report `streamingBehavior` only for prompts actually queued during streaming ([#5107](https://github.com/earendil-works/pi-mono/pull/5107)).
|
- Fixed extension input events to report `streamingBehavior` only for prompts actually queued during streaming ([#5107](https://github.com/earendil-works/pi-mono/pull/5107)).
|
||||||
- Fixed fenced `diff` code blocks and other highlight.js scopes to keep theme-aware syntax colors after the `cli-highlight` replacement ([#5092](https://github.com/earendil-works/pi/issues/5092)).
|
- Fixed fenced `diff` code blocks and other highlight.js scopes to keep theme-aware syntax colors after the `cli-highlight` replacement ([#5092](https://github.com/earendil-works/pi/issues/5092)).
|
||||||
|
|||||||
@@ -1493,7 +1493,8 @@ const all = pi.getAllTools();
|
|||||||
// [{
|
// [{
|
||||||
// name: "read",
|
// name: "read",
|
||||||
// description: "Read file contents...",
|
// description: "Read file contents...",
|
||||||
// parameters: ...,
|
// parameters: ...,
|
||||||
|
// promptGuidelines: ["Use read to examine files instead of cat or sed."],
|
||||||
// sourceInfo: { path: "<builtin:read>", source: "builtin", scope: "temporary", origin: "top-level" }
|
// sourceInfo: { path: "<builtin:read>", source: "builtin", scope: "temporary", origin: "top-level" }
|
||||||
// }, ...]
|
// }, ...]
|
||||||
const names = all.map(t => t.name);
|
const names = all.map(t => t.name);
|
||||||
@@ -1502,7 +1503,7 @@ const extensionTools = all.filter((t) => t.sourceInfo.source !== "builtin" && t.
|
|||||||
pi.setActiveTools(["read", "bash"]); // Switch to read-only
|
pi.setActiveTools(["read", "bash"]); // Switch to read-only
|
||||||
```
|
```
|
||||||
|
|
||||||
`pi.getAllTools()` returns `name`, `description`, `parameters`, and `sourceInfo`.
|
`pi.getAllTools()` returns `name`, `description`, `parameters`, `promptGuidelines`, and `sourceInfo`.
|
||||||
|
|
||||||
Typical `sourceInfo.source` values:
|
Typical `sourceInfo.source` values:
|
||||||
- `builtin` for built-in tools
|
- `builtin` for built-in tools
|
||||||
|
|||||||
@@ -759,13 +759,14 @@ export class AgentSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all configured tools with name, description, parameter schema, and source metadata.
|
* Get all configured tools with name, description, parameter schema, prompt guidelines, and source metadata.
|
||||||
*/
|
*/
|
||||||
getAllTools(): ToolInfo[] {
|
getAllTools(): ToolInfo[] {
|
||||||
return Array.from(this._toolDefinitions.values()).map(({ definition, sourceInfo }) => ({
|
return Array.from(this._toolDefinitions.values()).map(({ definition, sourceInfo }) => ({
|
||||||
name: definition.name,
|
name: definition.name,
|
||||||
description: definition.description,
|
description: definition.description,
|
||||||
parameters: definition.parameters,
|
parameters: definition.parameters,
|
||||||
|
promptGuidelines: definition.promptGuidelines,
|
||||||
sourceInfo,
|
sourceInfo,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1213,7 +1213,7 @@ export interface ExtensionAPI {
|
|||||||
/** Get the list of currently active tool names. */
|
/** Get the list of currently active tool names. */
|
||||||
getActiveTools(): string[];
|
getActiveTools(): string[];
|
||||||
|
|
||||||
/** Get all configured tools with parameter schema and source metadata. */
|
/** Get all configured tools with parameter schema, prompt guidelines, and source metadata. */
|
||||||
getAllTools(): ToolInfo[];
|
getAllTools(): ToolInfo[];
|
||||||
|
|
||||||
/** Set the active tools by name. */
|
/** Set the active tools by name. */
|
||||||
@@ -1424,8 +1424,8 @@ export type GetSessionNameHandler = () => string | undefined;
|
|||||||
|
|
||||||
export type GetActiveToolsHandler = () => string[];
|
export type GetActiveToolsHandler = () => string[];
|
||||||
|
|
||||||
/** Tool info with name, description, parameter schema, and source metadata */
|
/** Tool info with name, description, parameter schema, prompt guidelines, and source metadata. */
|
||||||
export type ToolInfo = Pick<ToolDefinition, "name" | "description" | "parameters"> & {
|
export type ToolInfo = Pick<ToolDefinition, "name" | "description" | "parameters" | "promptGuidelines"> & {
|
||||||
sourceInfo: SourceInfo;
|
sourceInfo: SourceInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ describe("AgentSession dynamic tool registration", () => {
|
|||||||
const readTool = allTools.find((tool) => tool.name === "read");
|
const readTool = allTools.find((tool) => tool.name === "read");
|
||||||
|
|
||||||
expect(allTools.map((tool) => tool.name)).toContain("dynamic_tool");
|
expect(allTools.map((tool) => tool.name)).toContain("dynamic_tool");
|
||||||
|
expect(dynamicTool?.promptGuidelines).toEqual([
|
||||||
|
"Use dynamic_tool when the user asks for dynamic behavior tests.",
|
||||||
|
]);
|
||||||
expect(dynamicTool?.sourceInfo).toMatchObject({
|
expect(dynamicTool?.sourceInfo).toMatchObject({
|
||||||
path: "<inline:1>",
|
path: "<inline:1>",
|
||||||
source: "inline",
|
source: "inline",
|
||||||
|
|||||||
Reference in New Issue
Block a user