Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ concurrency:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v5
- uses: oven-sh/setup-bun@v2
Expand Down
Binary file modified bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
},
"dependencies": {
"@clack/prompts": "^1.3.0",
"@earendil-works/pi-agent-core": "^0.74.1",
"@earendil-works/pi-ai": "^0.79.7",
"@earendil-works/pi-coding-agent": "^0.79.7",
"@earendil-works/pi-agent-core": "0.84.4",
"@earendil-works/pi-ai": "0.84.4",
"@earendil-works/pi-coding-agent": "0.84.4",
"discord.js": "^14.16.3",
"mdast-util-from-markdown": "^2.0.3",
"remark-gfm": "^4.0.1",
Expand Down
11 changes: 11 additions & 0 deletions src/agent/installStreamingSender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ export function installStreamingSender(args: {
const stopReason = (message as { stopReason?: string }).stopReason;
const errorMessage = (message as { errorMessage?: string }).errorMessage;
if (stopReason === "error" && errorMessage) {
// Log to journal too — the channel-side "agent error" line is
// easy to miss (no debug-channel copy, no stderr) so operators
// digging into `journalctl -u …` after the fact see nothing.
// Include provider/model for post-mortem: 401/403s here almost
// always trace back to a specific provider's credential or a
// stale models.json format (e.g. the pi 0.79→0.84 config-value
// syntax change).
const provider = (message as { provider?: string }).provider;
const model = (message as { model?: string }).model;
const modelTag = provider || model ? ` [${provider ?? "?"}/${model ?? "?"}]` : "";
console.error(`[stream] agent turn errored${modelTag}: ${errorMessage}`);
sender
.sendError(new Error(errorMessage))
.catch((error) => console.error("[stream] sendError failed:", error));
Expand Down
2 changes: 1 addition & 1 deletion src/createAgentPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export function createAgentPool(args: {
// match.
const sessionModel =
defaultProvider && defaultModel
? services.modelRegistry?.find(defaultProvider, defaultModel) ?? undefined
? services.modelRuntime?.getModel(defaultProvider, defaultModel) ?? undefined
: undefined;

const { session } = await createAgentSessionFromServices({
Expand Down
42 changes: 42 additions & 0 deletions src/io/createDebugLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,51 @@ export function createDebugLogger(args: {
const startLog = pendingCompactionStartLog;
pendingCompactionStartLog = null;
postCompactionEnd(event, startLog);
return;
}
// Surface model-turn errors (auth failures, provider 5xx, malformed
// responses) into the debug channel. The channel-facing `sendError`
// is a single terse line in the *user* channel; without a copy here,
// operators monitoring debug have no signal that anything went wrong.
if (event.type === "turn_end" && isAssistantMessageEnd(event.message)) {
const msg = event.message as {
stopReason?: string;
errorMessage?: string;
provider?: string;
model?: string;
};
if (msg.stopReason === "error" && msg.errorMessage) {
postTurnError({
errorMessage: msg.errorMessage,
provider: msg.provider,
model: msg.model,
}).catch((error) => console.error("[debugLogger] turn-error post failed:", error));
}
}
});

async function postTurnError(args: {
errorMessage: string;
provider?: string;
model?: string;
}): Promise<void> {
const channel = await getDebugChannel();
if (!channel) return;
const link = sourceMessageUrl ?? (await getChannelLink());
const head = link ? `[agent error](<${link}>)` : "agent error";
const modelTag =
args.provider || args.model ? ` · ${args.provider ?? "?"}/${args.model ?? "?"}` : "";
const text = `-# ⚠️ ${head}${modelTag}: ${sanitizeBackticks(args.errorMessage)}`.slice(
0,
hardCharLimit,
);
await sendDebugMessage({
channel,
content: text,
errorContext: "turn-error post failed",
});
}

async function postCompactionStart(reason: string): Promise<string | null> {
const channel = await getDebugChannel();
if (!channel) return null;
Expand Down