豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit df59cbf

Browse files
fix(checks): tighten checkToolErrorSpan to require non-ok span status (#141)
Simplify the tool error span check to focus on what matters: the span status field must be set and must not be "ok". Previously the check looked for a grab-bag of error indicators (data.error, data.exception, gen_ai.tool.error, tags.error) in addition to status, which was overly lenient — a span could pass by having any random error-like data key even if the status itself was wrong. The new check requires that span.status is present and is not "ok" (e.g. "internal_error", "error"). This catches frameworks like Python LangGraph where the tool span status is unset despite the tool raising an exception.
1 parent 1dd9ee2 commit df59cbf

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/test-cases/agents/tool-error.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,16 @@ const checkToolErrorSpan: Check = {
5353
);
5454
}
5555

56-
// Check for error indicators
57-
const hasError =
58-
toolSpan.status === "error" ||
59-
toolSpan.status === "internal_error" ||
60-
toolSpan.data?.["error"] !== undefined ||
61-
toolSpan.data?.["exception"] !== undefined ||
62-
toolSpan.data?.["gen_ai.tool.error"] !== undefined ||
63-
(toolSpan.tags && toolSpan.tags["error"] === true);
64-
65-
if (!hasError) {
56+
// The tool raised an error, so the span status must not be "ok" or unset.
57+
// Valid error statuses: "internal_error", "error", etc.
58+
const status = toolSpan.status;
59+
if (!status || status === "ok") {
6660
throw new CheckError(
67-
"Tool span should have an error indicator (status=error, data.error, data.exception, gen_ai.tool.error, or tags.error)",
61+
`Tool span status should indicate an error (e.g. "internal_error") but got "${status ?? "undefined"}"`,
6862
[{
6963
spanId: toolSpan.span_id,
70-
message: `Tool span has status="${toolSpan.status}" with no error indicators`,
64+
attribute: "status",
65+
message: `Tool span status is "${status ?? "undefined"}", expected a non-ok error status`,
7166
}],
7267
);
7368
}

0 commit comments

Comments
 (0)