mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
define and surface an error for malformed tool responses
This commit is contained in:
1 parent
c48288f9e6
commit
8b5cf72356
2 files changed
+54
-3
No files matched your search
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Error thrown when an AI provider sends a malformed tool call response
|
||||
* (e.g., missing function name in the streaming response)
|
||||
*/
|
||||
export class MalformedToolCallError extends Error {
|
||||
public readonly code = 'malformed_tool_call' as const;
|
||||
public readonly toolCallId: string;
|
||||
public readonly providerModel: string;
|
||||
|
||||
constructor(message: string, toolCallId: string, providerModel: string) {
|
||||
super(message);
|
||||
this.name = 'MalformedToolCallError';
|
||||
this.toolCallId = toolCallId;
|
||||
this.providerModel = providerModel;
|
||||
|
||||
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, MalformedToolCallError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user