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,23 +571,28 @@ async function finalizeExecutedToolCall(
|
|||||||
let isError = executed.isError;
|
let isError = executed.isError;
|
||||||
|
|
||||||
if (config.afterToolCall) {
|
if (config.afterToolCall) {
|
||||||
const afterResult = await config.afterToolCall(
|
try {
|
||||||
{
|
const afterResult = await config.afterToolCall(
|
||||||
assistantMessage,
|
{
|
||||||
toolCall: prepared.toolCall,
|
assistantMessage,
|
||||||
args: prepared.args,
|
toolCall: prepared.toolCall,
|
||||||
result,
|
args: prepared.args,
|
||||||
isError,
|
result,
|
||||||
context: currentContext,
|
isError,
|
||||||
},
|
context: currentContext,
|
||||||
signal,
|
},
|
||||||
);
|
signal,
|
||||||
if (afterResult) {
|
);
|
||||||
result = {
|
if (afterResult) {
|
||||||
content: afterResult.content ?? result.content,
|
result = {
|
||||||
details: afterResult.details ?? result.details,
|
content: afterResult.content ?? result.content,
|
||||||
};
|
details: afterResult.details ?? result.details,
|
||||||
isError = afterResult.isError ?? isError;
|
};
|
||||||
|
isError = afterResult.isError ?? isError;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
result = createErrorToolResult(error instanceof Error ? error.message : String(error));
|
||||||
|
isError = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user