Skip to content

Commit 3fb871e

Browse files
committed
chore: auto-commit before merge (2026-04-18 04:46)
1 parent 4a6a289 commit 3fb871e

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

src/agents/pi-embedded-helpers/errors.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,11 @@ function classifyFailoverClassificationFromMessage(
717717
if (isPeriodicUsageLimitErrorMessage(raw)) {
718718
return toReasonClassification(isBillingErrorMessage(raw) ? "billing" : "rate_limit");
719719
}
720+
// FORK: Early billing check for Anthropic spending cap — must come BEFORE
721+
// rateLimit because "usage limits" also matches rate_limit patterns.
722+
if (/regain access/i.test(raw) || /specified.*usage limits/i.test(raw)) {
723+
return toReasonClassification("billing");
724+
}
720725
if (isRateLimitErrorMessage(raw)) {
721726
return toReasonClassification("rate_limit");
722727
}

src/agents/pi-embedded-runner/run/attempt.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ import {
247247
shouldPreemptivelyCompactBeforePrompt,
248248
} from "./preemptive-compaction.js";
249249
import type { EmbeddedRunAttemptParams, EmbeddedRunAttemptResult } from "./types.js";
250+
import { getRetrievalRuntime } from "../../pi-extensions/retrieval-runtime.js"; // FORK: still used inline for retrieval pack
251+
import * as _forkAttemptHooks from "../../../fork/attempt-hooks.js"; // FORK: single hook entry point
250252

251253
export {
252254
appendAttemptCacheTtlIfNeeded,
@@ -2090,7 +2092,19 @@ export async function runEmbeddedAttempt(
20902092
inFlightPrompt: effectivePrompt,
20912093
});
20922094

2093-
// Only pass images option if there are actually images to pass
2095+
// FORK: mid-context persona re-injection when SyncScore drops
2096+
{
2097+
const reinjectResult = _forkAttemptHooks.applyMidContextReinjectHook(
2098+
activeSession as unknown as import("@mariozechner/pi-coding-agent").SessionManager,
2099+
systemPromptText ?? "",
2100+
log,
2101+
);
2102+
if (reinjectResult.reinjected && systemPromptText != null) {
2103+
systemPromptText = reinjectResult.systemPromptText;
2104+
}
2105+
}
2106+
2107+
// Only pass images option if there are actually images to pass
20942108
// This avoids potential issues with models that don't expect the images parameter
20952109
if (imageResult.images.length > 0) {
20962110
await abortable(
@@ -2384,6 +2398,24 @@ export async function runEmbeddedAttempt(
23842398
log.warn(`agent_end hook failed: ${err}`);
23852399
});
23862400
}
2401+
2402+
// FORK: text-tool-call interception for local providers (ollama/lmstudio/vllm)
2403+
if (!promptError && !aborted && tools.length > 0) {
2404+
const ttcResult = await _forkAttemptHooks.interceptTextToolCalls({
2405+
provider: params.provider,
2406+
activeSession: activeSession as never,
2407+
tools: tools as never,
2408+
toolMetas: toolMetas as never,
2409+
promptError,
2410+
aborted,
2411+
abortSignal: params.abortSignal,
2412+
abortable,
2413+
log,
2414+
});
2415+
if (ttcResult.promptError) {
2416+
promptError = ttcResult.promptError;
2417+
}
2418+
}
23872419
} finally {
23882420
clearTimeout(abortTimer);
23892421
if (abortWarnTimer) {

src/agents/pi-embedded-subscribe.types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,10 @@ export type SubscribeEmbeddedPiSessionParams = {
4646
*/
4747
builtinToolNames?: ReadonlySet<string>;
4848
internalEvents?: AgentInternalEvent[];
49+
/** Auth profile ID for lifecycle event tracking. */
50+
authProfileId?: string;
51+
/** FORK: Model ID for lifecycle event tracking (e.g. "claude-sonnet-4-6"). */
52+
modelId?: string;
53+
/** FORK: Provider name for lifecycle event tracking (e.g. "anthropic"). */
54+
modelProvider?: string;
4955
};

src/canvas-host/a2ui/.bundle.hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
629b58884bd16319085c45d5d60249ed5fc50765038b347f20692e6f7a748d64
1+
36ffb6134ed280d655b687af8310d118e011f9b2fdd638ebbc99875ee7723c3d

0 commit comments

Comments
 (0)