fix(logging): quiet embedded run console logs
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
- Control UI: generate UUIDs when `crypto.randomUUID()` is unavailable over HTTP — thanks @ratulsarna.
|
- Control UI: generate UUIDs when `crypto.randomUUID()` is unavailable over HTTP — thanks @ratulsarna.
|
||||||
- Control UI: stream live tool output cards in Chat (agent events include sessionKey).
|
- Control UI: stream live tool output cards in Chat (agent events include sessionKey).
|
||||||
- Agent: add soft block-stream chunking (800–1200 chars default) with paragraph/newline preference.
|
- Agent: add soft block-stream chunking (800–1200 chars default) with paragraph/newline preference.
|
||||||
|
- Agent: route embedded run lifecycle logs through subsystem console formatting and reduce log noise.
|
||||||
- Agent tools: scope the Discord tool to Discord surface runs.
|
- Agent tools: scope the Discord tool to Discord surface runs.
|
||||||
- Agent tools: format verbose tool summaries without brackets, with unique emojis and `tool: detail` style.
|
- Agent tools: format verbose tool summaries without brackets, with unique emojis and `tool: detail` style.
|
||||||
- Agent tools: emit verbose tool summaries at tool start (no debounce).
|
- Agent tools: emit verbose tool summaries at tool start (no debounce).
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import {
|
|||||||
type enqueueCommand,
|
type enqueueCommand,
|
||||||
enqueueCommandInLane,
|
enqueueCommandInLane,
|
||||||
} from "../process/command-queue.js";
|
} from "../process/command-queue.js";
|
||||||
import { defaultRuntime } from "../runtime.js";
|
import { createSubsystemLogger } from "../logging.js";
|
||||||
import { CONFIG_DIR, resolveUserPath } from "../utils.js";
|
import { CONFIG_DIR, resolveUserPath } from "../utils.js";
|
||||||
import { resolveClawdisAgentDir } from "./agent-paths.js";
|
import { resolveClawdisAgentDir } from "./agent-paths.js";
|
||||||
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "./defaults.js";
|
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "./defaults.js";
|
||||||
@@ -94,6 +94,8 @@ type EmbeddedPiQueueHandle = {
|
|||||||
abort: () => void;
|
abort: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const log = createSubsystemLogger("agent/embedded");
|
||||||
|
|
||||||
const ACTIVE_EMBEDDED_RUNS = new Map<string, EmbeddedPiQueueHandle>();
|
const ACTIVE_EMBEDDED_RUNS = new Map<string, EmbeddedPiQueueHandle>();
|
||||||
|
|
||||||
const OAUTH_FILENAME = "oauth.json";
|
const OAUTH_FILENAME = "oauth.json";
|
||||||
@@ -383,7 +385,7 @@ export async function runEmbeddedPiAgent(params: {
|
|||||||
|
|
||||||
const thinkingLevel = mapThinkingLevel(params.thinkLevel);
|
const thinkingLevel = mapThinkingLevel(params.thinkLevel);
|
||||||
|
|
||||||
defaultRuntime.log?.(
|
log.debug(
|
||||||
`embedded run start: runId=${params.runId} sessionId=${params.sessionId} provider=${provider} model=${modelId} surface=${params.surface ?? "unknown"}`,
|
`embedded run start: runId=${params.runId} sessionId=${params.sessionId} provider=${provider} model=${modelId} surface=${params.surface ?? "unknown"}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -515,14 +517,14 @@ export async function runEmbeddedPiAgent(params: {
|
|||||||
let abortWarnTimer: NodeJS.Timeout | undefined;
|
let abortWarnTimer: NodeJS.Timeout | undefined;
|
||||||
const abortTimer = setTimeout(
|
const abortTimer = setTimeout(
|
||||||
() => {
|
() => {
|
||||||
defaultRuntime.log(
|
log.warn(
|
||||||
`embedded run timeout: runId=${params.runId} sessionId=${params.sessionId} timeoutMs=${params.timeoutMs}`,
|
`embedded run timeout: runId=${params.runId} sessionId=${params.sessionId} timeoutMs=${params.timeoutMs}`,
|
||||||
);
|
);
|
||||||
abortRun();
|
abortRun();
|
||||||
if (!abortWarnTimer) {
|
if (!abortWarnTimer) {
|
||||||
abortWarnTimer = setTimeout(() => {
|
abortWarnTimer = setTimeout(() => {
|
||||||
if (!session.isStreaming) return;
|
if (!session.isStreaming) return;
|
||||||
defaultRuntime.log(
|
log.warn(
|
||||||
`embedded run abort still streaming: runId=${params.runId} sessionId=${params.sessionId}`,
|
`embedded run abort still streaming: runId=${params.runId} sessionId=${params.sessionId}`,
|
||||||
);
|
);
|
||||||
}, 10_000);
|
}, 10_000);
|
||||||
@@ -548,7 +550,7 @@ export async function runEmbeddedPiAgent(params: {
|
|||||||
let promptError: unknown = null;
|
let promptError: unknown = null;
|
||||||
try {
|
try {
|
||||||
const promptStartedAt = Date.now();
|
const promptStartedAt = Date.now();
|
||||||
defaultRuntime.log?.(
|
log.debug(
|
||||||
`embedded run prompt start: runId=${params.runId} sessionId=${params.sessionId}`,
|
`embedded run prompt start: runId=${params.runId} sessionId=${params.sessionId}`,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
@@ -556,7 +558,7 @@ export async function runEmbeddedPiAgent(params: {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
promptError = err;
|
promptError = err;
|
||||||
} finally {
|
} finally {
|
||||||
defaultRuntime.log?.(
|
log.debug(
|
||||||
`embedded run prompt end: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - promptStartedAt}`,
|
`embedded run prompt end: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - promptStartedAt}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -645,7 +647,7 @@ export async function runEmbeddedPiAgent(params: {
|
|||||||
p.text || p.mediaUrl || (p.mediaUrls && p.mediaUrls.length > 0),
|
p.text || p.mediaUrl || (p.mediaUrls && p.mediaUrls.length > 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
defaultRuntime.log?.(
|
log.debug(
|
||||||
`embedded run done: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - started} aborted=${aborted}`,
|
`embedded run done: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - started} aborted=${aborted}`,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import type { AgentSession } from "@mariozechner/pi-coding-agent";
|
|||||||
|
|
||||||
import { formatToolAggregate } from "../auto-reply/tool-meta.js";
|
import { formatToolAggregate } from "../auto-reply/tool-meta.js";
|
||||||
import { emitAgentEvent } from "../infra/agent-events.js";
|
import { emitAgentEvent } from "../infra/agent-events.js";
|
||||||
|
import { createSubsystemLogger } from "../logging.js";
|
||||||
import { splitMediaFromOutput } from "../media/parse.js";
|
import { splitMediaFromOutput } from "../media/parse.js";
|
||||||
import { defaultRuntime } from "../runtime.js";
|
|
||||||
import {
|
import {
|
||||||
extractAssistantText,
|
extractAssistantText,
|
||||||
inferToolMetaFromArgs,
|
inferToolMetaFromArgs,
|
||||||
@@ -15,6 +15,7 @@ const THINKING_TAG_RE = /<\s*\/?\s*think(?:ing)?\s*>/gi;
|
|||||||
const THINKING_OPEN_RE = /<\s*think(?:ing)?\s*>/i;
|
const THINKING_OPEN_RE = /<\s*think(?:ing)?\s*>/i;
|
||||||
const THINKING_CLOSE_RE = /<\s*\/\s*think(?:ing)?\s*>/i;
|
const THINKING_CLOSE_RE = /<\s*\/\s*think(?:ing)?\s*>/i;
|
||||||
const TOOL_RESULT_MAX_CHARS = 8000;
|
const TOOL_RESULT_MAX_CHARS = 8000;
|
||||||
|
const log = createSubsystemLogger("agent/embedded");
|
||||||
|
|
||||||
export type BlockReplyChunking = {
|
export type BlockReplyChunking = {
|
||||||
minChars: number;
|
minChars: number;
|
||||||
@@ -324,7 +325,7 @@ export function subscribeEmbeddedPiSession(params: {
|
|||||||
const args = (evt as AgentEvent & { args: unknown }).args;
|
const args = (evt as AgentEvent & { args: unknown }).args;
|
||||||
const meta = inferToolMetaFromArgs(toolName, args);
|
const meta = inferToolMetaFromArgs(toolName, args);
|
||||||
toolMetaById.set(toolCallId, meta);
|
toolMetaById.set(toolCallId, meta);
|
||||||
defaultRuntime.log?.(
|
log.debug(
|
||||||
`embedded run tool start: runId=${params.runId} tool=${toolName} toolCallId=${toolCallId}`,
|
`embedded run tool start: runId=${params.runId} tool=${toolName} toolCallId=${toolCallId}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -590,19 +591,19 @@ export function subscribeEmbeddedPiSession(params: {
|
|||||||
const toolCallId = String(
|
const toolCallId = String(
|
||||||
(evt as AgentEvent & { toolCallId: string }).toolCallId,
|
(evt as AgentEvent & { toolCallId: string }).toolCallId,
|
||||||
);
|
);
|
||||||
defaultRuntime.log?.(
|
log.debug(
|
||||||
`embedded run tool end: runId=${params.runId} tool=${toolName} toolCallId=${toolCallId}`,
|
`embedded run tool end: runId=${params.runId} tool=${toolName} toolCallId=${toolCallId}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt.type === "agent_start") {
|
if (evt.type === "agent_start") {
|
||||||
defaultRuntime.log?.(`embedded run agent start: runId=${params.runId}`);
|
log.debug(`embedded run agent start: runId=${params.runId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt.type === "auto_compaction_start") {
|
if (evt.type === "auto_compaction_start") {
|
||||||
compactionInFlight = true;
|
compactionInFlight = true;
|
||||||
ensureCompactionPromise();
|
ensureCompactionPromise();
|
||||||
defaultRuntime.log?.(
|
log.debug(
|
||||||
`embedded run compaction start: runId=${params.runId}`,
|
`embedded run compaction start: runId=${params.runId}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -613,7 +614,7 @@ export function subscribeEmbeddedPiSession(params: {
|
|||||||
if (willRetry) {
|
if (willRetry) {
|
||||||
noteCompactionRetry();
|
noteCompactionRetry();
|
||||||
resetForCompactionRetry();
|
resetForCompactionRetry();
|
||||||
defaultRuntime.log?.(
|
log.debug(
|
||||||
`embedded run compaction retry: runId=${params.runId}`,
|
`embedded run compaction retry: runId=${params.runId}`,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -622,7 +623,7 @@ export function subscribeEmbeddedPiSession(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (evt.type === "agent_end") {
|
if (evt.type === "agent_end") {
|
||||||
defaultRuntime.log?.(`embedded run agent end: runId=${params.runId}`);
|
log.debug(`embedded run agent end: runId=${params.runId}`);
|
||||||
if (pendingCompactionRetry > 0) {
|
if (pendingCompactionRetry > 0) {
|
||||||
resolveCompactionRetry();
|
resolveCompactionRetry();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user