fix(agent): guard afterToolCall hook errors in finalization
closes #3084
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed parallel tool-call finalization to convert `afterToolCall` hook throws into error tool results instead of aborting the batch ([#3084](https://github.com/badlogic/pi-mono/issues/3084))
|
||||||
|
|
||||||
## [0.67.6] - 2026-04-16
|
## [0.67.6] - 2026-04-16
|
||||||
|
|
||||||
## [0.67.5] - 2026-04-16
|
## [0.67.5] - 2026-04-16
|
||||||
|
|||||||
@@ -571,6 +571,7 @@ async function finalizeExecutedToolCall(
|
|||||||
let isError = executed.isError;
|
let isError = executed.isError;
|
||||||
|
|
||||||
if (config.afterToolCall) {
|
if (config.afterToolCall) {
|
||||||
|
try {
|
||||||
const afterResult = await config.afterToolCall(
|
const afterResult = await config.afterToolCall(
|
||||||
{
|
{
|
||||||
assistantMessage,
|
assistantMessage,
|
||||||
@@ -589,6 +590,10 @@ async function finalizeExecutedToolCall(
|
|||||||
};
|
};
|
||||||
isError = afterResult.isError ?? isError;
|
isError = afterResult.isError ?? isError;
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
result = createErrorToolResult(error instanceof Error ? error.message : String(error));
|
||||||
|
isError = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return await emitToolCallOutcome(prepared.toolCall, result, isError, emit);
|
return await emitToolCallOutcome(prepared.toolCall, result, isError, emit);
|
||||||
|
|||||||
Reference in New Issue
Block a user