fix(logging): quiet embedded run console logs
This commit is contained in:
@@ -31,7 +31,7 @@ import {
|
||||
type enqueueCommand,
|
||||
enqueueCommandInLane,
|
||||
} from "../process/command-queue.js";
|
||||
import { defaultRuntime } from "../runtime.js";
|
||||
import { createSubsystemLogger } from "../logging.js";
|
||||
import { CONFIG_DIR, resolveUserPath } from "../utils.js";
|
||||
import { resolveClawdisAgentDir } from "./agent-paths.js";
|
||||
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "./defaults.js";
|
||||
@@ -94,6 +94,8 @@ type EmbeddedPiQueueHandle = {
|
||||
abort: () => void;
|
||||
};
|
||||
|
||||
const log = createSubsystemLogger("agent/embedded");
|
||||
|
||||
const ACTIVE_EMBEDDED_RUNS = new Map<string, EmbeddedPiQueueHandle>();
|
||||
|
||||
const OAUTH_FILENAME = "oauth.json";
|
||||
@@ -383,7 +385,7 @@ export async function runEmbeddedPiAgent(params: {
|
||||
|
||||
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"}`,
|
||||
);
|
||||
|
||||
@@ -515,14 +517,14 @@ export async function runEmbeddedPiAgent(params: {
|
||||
let abortWarnTimer: NodeJS.Timeout | undefined;
|
||||
const abortTimer = setTimeout(
|
||||
() => {
|
||||
defaultRuntime.log(
|
||||
log.warn(
|
||||
`embedded run timeout: runId=${params.runId} sessionId=${params.sessionId} timeoutMs=${params.timeoutMs}`,
|
||||
);
|
||||
abortRun();
|
||||
if (!abortWarnTimer) {
|
||||
abortWarnTimer = setTimeout(() => {
|
||||
if (!session.isStreaming) return;
|
||||
defaultRuntime.log(
|
||||
log.warn(
|
||||
`embedded run abort still streaming: runId=${params.runId} sessionId=${params.sessionId}`,
|
||||
);
|
||||
}, 10_000);
|
||||
@@ -548,7 +550,7 @@ export async function runEmbeddedPiAgent(params: {
|
||||
let promptError: unknown = null;
|
||||
try {
|
||||
const promptStartedAt = Date.now();
|
||||
defaultRuntime.log?.(
|
||||
log.debug(
|
||||
`embedded run prompt start: runId=${params.runId} sessionId=${params.sessionId}`,
|
||||
);
|
||||
try {
|
||||
@@ -556,7 +558,7 @@ export async function runEmbeddedPiAgent(params: {
|
||||
} catch (err) {
|
||||
promptError = err;
|
||||
} finally {
|
||||
defaultRuntime.log?.(
|
||||
log.debug(
|
||||
`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),
|
||||
);
|
||||
|
||||
defaultRuntime.log?.(
|
||||
log.debug(
|
||||
`embedded run done: runId=${params.runId} sessionId=${params.sessionId} durationMs=${Date.now() - started} aborted=${aborted}`,
|
||||
);
|
||||
return {
|
||||
|
||||
@@ -4,8 +4,8 @@ import type { AgentSession } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
import { formatToolAggregate } from "../auto-reply/tool-meta.js";
|
||||
import { emitAgentEvent } from "../infra/agent-events.js";
|
||||
import { createSubsystemLogger } from "../logging.js";
|
||||
import { splitMediaFromOutput } from "../media/parse.js";
|
||||
import { defaultRuntime } from "../runtime.js";
|
||||
import {
|
||||
extractAssistantText,
|
||||
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_CLOSE_RE = /<\s*\/\s*think(?:ing)?\s*>/i;
|
||||
const TOOL_RESULT_MAX_CHARS = 8000;
|
||||
const log = createSubsystemLogger("agent/embedded");
|
||||
|
||||
export type BlockReplyChunking = {
|
||||
minChars: number;
|
||||
@@ -324,7 +325,7 @@ export function subscribeEmbeddedPiSession(params: {
|
||||
const args = (evt as AgentEvent & { args: unknown }).args;
|
||||
const meta = inferToolMetaFromArgs(toolName, args);
|
||||
toolMetaById.set(toolCallId, meta);
|
||||
defaultRuntime.log?.(
|
||||
log.debug(
|
||||
`embedded run tool start: runId=${params.runId} tool=${toolName} toolCallId=${toolCallId}`,
|
||||
);
|
||||
|
||||
@@ -590,19 +591,19 @@ export function subscribeEmbeddedPiSession(params: {
|
||||
const toolCallId = String(
|
||||
(evt as AgentEvent & { toolCallId: string }).toolCallId,
|
||||
);
|
||||
defaultRuntime.log?.(
|
||||
log.debug(
|
||||
`embedded run tool end: runId=${params.runId} tool=${toolName} toolCallId=${toolCallId}`,
|
||||
);
|
||||
}
|
||||
|
||||
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") {
|
||||
compactionInFlight = true;
|
||||
ensureCompactionPromise();
|
||||
defaultRuntime.log?.(
|
||||
log.debug(
|
||||
`embedded run compaction start: runId=${params.runId}`,
|
||||
);
|
||||
}
|
||||
@@ -613,7 +614,7 @@ export function subscribeEmbeddedPiSession(params: {
|
||||
if (willRetry) {
|
||||
noteCompactionRetry();
|
||||
resetForCompactionRetry();
|
||||
defaultRuntime.log?.(
|
||||
log.debug(
|
||||
`embedded run compaction retry: runId=${params.runId}`,
|
||||
);
|
||||
} else {
|
||||
@@ -622,7 +623,7 @@ export function subscribeEmbeddedPiSession(params: {
|
||||
}
|
||||
|
||||
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) {
|
||||
resolveCompactionRetry();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user