@@ -247,6 +247,8 @@ import {
247247 shouldPreemptivelyCompactBeforePrompt ,
248248} from "./preemptive-compaction.js" ;
249249import 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
251253export {
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 ) {
0 commit comments