Revert "fix(coding-agent): abort stuck context hooks"
This reverts commit 6757561546.
This commit is contained in:
@@ -10,7 +10,6 @@
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed startup model selection to skip unauthenticated saved defaults so configured local custom models can be selected instead ([#6231](https://github.com/earendil-works/pi/issues/6231)).
|
- Fixed startup model selection to skip unauthenticated saved defaults so configured local custom models can be selected instead ([#6231](https://github.com/earendil-works/pi/issues/6231)).
|
||||||
- Fixed Escape aborts to clear runs stuck in extension context hooks that ignore abort signals ([#6234](https://github.com/earendil-works/pi/issues/6234)).
|
|
||||||
- Fixed the question extension example to run question tool calls sequentially so multiple questions in one assistant turn remain answerable ([#6189](https://github.com/earendil-works/pi/issues/6189)).
|
- Fixed the question extension example to run question tool calls sequentially so multiple questions in one assistant turn remain answerable ([#6189](https://github.com/earendil-works/pi/issues/6189)).
|
||||||
- Fixed `/login` to report auth storage persistence failures instead of claiming credentials were saved when `auth.json` is locked ([#6223](https://github.com/earendil-works/pi/issues/6223)).
|
- Fixed `/login` to report auth storage persistence failures instead of claiming credentials were saved when `auth.json` is locked ([#6223](https://github.com/earendil-works/pi/issues/6223)).
|
||||||
- Fixed split-turn compaction to serialize summary requests so single-concurrency local providers do not fail with 429 errors ([#5536](https://github.com/earendil-works/pi/issues/5536)).
|
- Fixed split-turn compaction to serialize summary requests so single-concurrency local providers do not fail with 429 errors ([#5536](https://github.com/earendil-works/pi/issues/5536)).
|
||||||
|
|||||||
@@ -115,25 +115,6 @@ interface BeforeAgentStartCombinedResult {
|
|||||||
systemPrompt?: string;
|
systemPrompt?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function callContextHandlerAbortable<T>(fn: () => Promise<T> | T, signal: AbortSignal): Promise<T> {
|
|
||||||
if (signal.aborted) {
|
|
||||||
throw new Error("Agent run aborted");
|
|
||||||
}
|
|
||||||
|
|
||||||
let cleanup = () => {};
|
|
||||||
const abortPromise = new Promise<never>((_resolve, reject) => {
|
|
||||||
const onAbort = () => reject(new Error("Agent run aborted"));
|
|
||||||
signal.addEventListener("abort", onAbort, { once: true });
|
|
||||||
cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
return await Promise.race([Promise.resolve().then(fn), abortPromise]);
|
|
||||||
} finally {
|
|
||||||
cleanup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Events handled by the generic emit() method.
|
* Events handled by the generic emit() method.
|
||||||
* Events with dedicated emitXxx() methods are excluded for stronger type safety.
|
* Events with dedicated emitXxx() methods are excluded for stronger type safety.
|
||||||
@@ -945,7 +926,6 @@ export class ExtensionRunner {
|
|||||||
|
|
||||||
async emitContext(messages: AgentMessage[]): Promise<AgentMessage[]> {
|
async emitContext(messages: AgentMessage[]): Promise<AgentMessage[]> {
|
||||||
const ctx = this.createContext();
|
const ctx = this.createContext();
|
||||||
const signal = ctx.signal;
|
|
||||||
let currentMessages = structuredClone(messages);
|
let currentMessages = structuredClone(messages);
|
||||||
|
|
||||||
for (const ext of this.extensions) {
|
for (const ext of this.extensions) {
|
||||||
@@ -955,17 +935,12 @@ export class ExtensionRunner {
|
|||||||
for (const handler of handlers) {
|
for (const handler of handlers) {
|
||||||
try {
|
try {
|
||||||
const event: ContextEvent = { type: "context", messages: currentMessages };
|
const event: ContextEvent = { type: "context", messages: currentMessages };
|
||||||
const handlerResult = signal
|
const handlerResult = await handler(event, ctx);
|
||||||
? await callContextHandlerAbortable(() => handler(event, ctx), signal)
|
|
||||||
: await handler(event, ctx);
|
|
||||||
|
|
||||||
if (handlerResult && (handlerResult as ContextEventResult).messages) {
|
if (handlerResult && (handlerResult as ContextEventResult).messages) {
|
||||||
currentMessages = (handlerResult as ContextEventResult).messages!;
|
currentMessages = (handlerResult as ContextEventResult).messages!;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (signal?.aborted) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
const message = err instanceof Error ? err.message : String(err);
|
const message = err instanceof Error ? err.message : String(err);
|
||||||
const stack = err instanceof Error ? err.stack : undefined;
|
const stack = err instanceof Error ? err.stack : undefined;
|
||||||
this.emitError({
|
this.emitError({
|
||||||
|
|||||||
Reference in New Issue
Block a user