feat: emit tool outputs for full verbose

This commit is contained in:
Peter Steinberger
2026-01-17 05:40:21 +00:00
parent 99dd428862
commit 68d35be383
3 changed files with 16 additions and 8 deletions

View File

@@ -39,7 +39,7 @@ read_when:
- Inline directive affects only that message; session/global defaults apply otherwise.
- 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 `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)
- Levels: `on|off|stream`.

View File

@@ -12,8 +12,6 @@ import {
} from "./pi-embedded-subscribe.tools.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 {
const normalized = toolName.trim().toLowerCase();
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}`,
);
if (
ctx.params.onToolResult &&
ctx.shouldEmitToolOutput() &&
TOOL_OUTPUT_ALLOWLIST.has(toolName.trim().toLowerCase())
) {
if (ctx.params.onToolResult && ctx.shouldEmitToolOutput()) {
const outputText = extractToolResultText(sanitizedResult);
if (outputText) {
ctx.emitToolOutput(toolName, meta, outputText);

View File

@@ -178,5 +178,19 @@ describe("subscribeEmbeddedPiSession", () => {
const output = onToolResult.mock.calls[1][0];
expect(output.text).toContain("hello");
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");
});
});