feat: emit tool outputs for full verbose
This commit is contained in:
@@ -39,7 +39,7 @@ read_when:
|
|||||||
- Inline directive affects only that message; session/global defaults apply otherwise.
|
- Inline directive affects only that message; session/global defaults apply otherwise.
|
||||||
- Send `/verbose` (or `/verbose:`) with no argument to see the current verbose level.
|
- Send `/verbose` (or `/verbose:`) with no argument to see the current verbose level.
|
||||||
- When verbose is on, agents that emit structured tool results (Pi, other JSON agents) send each tool call back as its own metadata-only message, prefixed with `<emoji> <tool-name>: <arg>` when available (path/command). These tool summaries are sent as soon as each tool starts (separate bubbles), not as streaming deltas.
|
- When verbose is on, agents that emit structured tool results (Pi, other JSON agents) send each tool call back as its own metadata-only message, prefixed with `<emoji> <tool-name>: <arg>` when available (path/command). These tool summaries are sent as soon as each tool starts (separate bubbles), not as streaming deltas.
|
||||||
- When verbose is `full`, exec/process tool outputs are also forwarded after completion (separate bubble, truncated to a safe length). If you toggle `/verbose on|full|off` while a run is in-flight, subsequent tool bubbles honor the new setting.
|
- When verbose is `full`, tool outputs are also forwarded after completion (separate bubble, truncated to a safe length). If you toggle `/verbose on|full|off` while a run is in-flight, subsequent tool bubbles honor the new setting.
|
||||||
|
|
||||||
## Reasoning visibility (/reasoning)
|
## Reasoning visibility (/reasoning)
|
||||||
- Levels: `on|off|stream`.
|
- Levels: `on|off|stream`.
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ import {
|
|||||||
} from "./pi-embedded-subscribe.tools.js";
|
} from "./pi-embedded-subscribe.tools.js";
|
||||||
import { inferToolMetaFromArgs } from "./pi-embedded-utils.js";
|
import { inferToolMetaFromArgs } from "./pi-embedded-utils.js";
|
||||||
|
|
||||||
const TOOL_OUTPUT_ALLOWLIST = new Set(["exec", "bash", "process"]);
|
|
||||||
|
|
||||||
function extendExecMeta(toolName: string, args: unknown, meta?: string): string | undefined {
|
function extendExecMeta(toolName: string, args: unknown, meta?: string): string | undefined {
|
||||||
const normalized = toolName.trim().toLowerCase();
|
const normalized = toolName.trim().toLowerCase();
|
||||||
if (normalized !== "exec" && normalized !== "bash") return meta;
|
if (normalized !== "exec" && normalized !== "bash") return meta;
|
||||||
@@ -202,11 +200,7 @@ export function handleToolExecutionEnd(
|
|||||||
`embedded run tool end: runId=${ctx.params.runId} tool=${toolName} toolCallId=${toolCallId}`,
|
`embedded run tool end: runId=${ctx.params.runId} tool=${toolName} toolCallId=${toolCallId}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (ctx.params.onToolResult && ctx.shouldEmitToolOutput()) {
|
||||||
ctx.params.onToolResult &&
|
|
||||||
ctx.shouldEmitToolOutput() &&
|
|
||||||
TOOL_OUTPUT_ALLOWLIST.has(toolName.trim().toLowerCase())
|
|
||||||
) {
|
|
||||||
const outputText = extractToolResultText(sanitizedResult);
|
const outputText = extractToolResultText(sanitizedResult);
|
||||||
if (outputText) {
|
if (outputText) {
|
||||||
ctx.emitToolOutput(toolName, meta, outputText);
|
ctx.emitToolOutput(toolName, meta, outputText);
|
||||||
|
|||||||
@@ -178,5 +178,19 @@ describe("subscribeEmbeddedPiSession", () => {
|
|||||||
const output = onToolResult.mock.calls[1][0];
|
const output = onToolResult.mock.calls[1][0];
|
||||||
expect(output.text).toContain("hello");
|
expect(output.text).toContain("hello");
|
||||||
expect(output.text).toContain("```txt");
|
expect(output.text).toContain("```txt");
|
||||||
|
|
||||||
|
handler?.({
|
||||||
|
type: "tool_execution_end",
|
||||||
|
toolName: "read",
|
||||||
|
toolCallId: "tool-read-1",
|
||||||
|
isError: false,
|
||||||
|
result: { content: [{ type: "text", text: "file data" }] },
|
||||||
|
});
|
||||||
|
|
||||||
|
await Promise.resolve();
|
||||||
|
|
||||||
|
expect(onToolResult).toHaveBeenCalledTimes(3);
|
||||||
|
const readOutput = onToolResult.mock.calls[2][0];
|
||||||
|
expect(readOutput.text).toContain("file data");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user