@sema-agent/core 1.437.0 → 1.438.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3405,15 +3405,16 @@ export class Runner {
3405
3405
  emitCommitted(eid, "toolResult", pendingAction.toolCallId);
3406
3406
  return;
3407
3407
  }
3408
- emitEnd(false);
3409
- onResolvedToolSuccess?.(canonicalToolName(pendingAction.toolName), res.details);
3408
+ const executedIsError = res.isError === true;
3409
+ emitEnd(executedIsError);
3410
+ onResolvedToolSuccess?.(canonicalToolName(pendingAction.toolName), executedIsError ? undefined : res.details);
3410
3411
  const eid = await prepared.session.appendMessage({
3411
3412
  role: "toolResult",
3412
3413
  toolCallId: pendingAction.toolCallId,
3413
3414
  toolName: pendingAction.toolName,
3414
3415
  content: res.content,
3415
3416
  details: res.details,
3416
- isError: false,
3417
+ isError: executedIsError,
3417
3418
  timestamp: Date.now(),
3418
3419
  });
3419
3420
  emitCommitted(eid, "toolResult", pendingAction.toolCallId);
@@ -59,8 +59,10 @@ export function makePlaceholderTool(info) {
59
59
  description: `${info.hint} — deferred: call ${TOOL_SEARCH_NAME}({"query":"select:${sn}"}) to load its parameters before use.`,
60
60
  parameters: EMPTY_PARAMS,
61
61
  effect: "read",
62
- execute: () => `Tool "${sn}" is not active yet. Call ${TOOL_SEARCH_NAME} with {"query":"select:${sn}"} ` +
63
- `(or a keyword \`query\`) to load its full schema, then call ${sn} with the proper arguments.`,
62
+ execute: () => {
63
+ throw new Error(`Tool "${sn}" is not active yet. Call ${TOOL_SEARCH_NAME} with {"query":"select:${sn}"} ` +
64
+ `(or a keyword \`query\`) to load its full schema, then call ${sn} with the proper arguments.`);
65
+ },
64
66
  });
65
67
  }
66
68
  export function scoreToolMatch(query, info) {
@@ -3,11 +3,11 @@ import { formatToolError, formatZodValidationError } from "./tool-errors.js";
3
3
  import { attachToolContract } from "../prompt-assembly/tool-catalog.js";
4
4
  function normalizeContent(ret) {
5
5
  if (typeof ret === "string") {
6
- return { content: [{ type: "text", text: ret }], details: undefined, terminate: false };
6
+ return { content: [{ type: "text", text: ret }], details: undefined, terminate: false, isError: false };
7
7
  }
8
8
  const raw = ret.content;
9
9
  const content = typeof raw === "string" ? [{ type: "text", text: raw }] : raw;
10
- return { content, details: ret.details, terminate: ret.terminate ?? false };
10
+ return { content, details: ret.details, terminate: ret.terminate ?? false, isError: ret.isError === true };
11
11
  }
12
12
  function isEmptyToolContent(content) {
13
13
  if (content.length === 0)
@@ -45,11 +45,11 @@ export function defineTool(spec) {
45
45
  catch (err) {
46
46
  throw new Error(formatToolError(err));
47
47
  }
48
- const { content, details, terminate } = normalizeContent(ret);
48
+ const { content, details, terminate, isError } = normalizeContent(ret);
49
49
  const guarded = isEmptyToolContent(content)
50
- ? [{ type: "text", text: `(${spec.name} completed with no output)` }]
50
+ ? [{ type: "text", text: isError ? `(${spec.name} reported an error with no further output)` : `(${spec.name} completed with no output)` }]
51
51
  : content;
52
- return { content: guarded, details, terminate };
52
+ return { content: guarded, details, terminate, ...(isError ? { isError: true } : {}) };
53
53
  },
54
54
  };
55
55
  if (spec.contract) {
@@ -57,6 +57,7 @@ export type ToolReturn = string | {
57
57
  content: Array<TextContent | ImageContent | DocumentContent> | string;
58
58
  details?: unknown;
59
59
  terminate?: boolean;
60
+ isError?: boolean;
60
61
  };
61
62
  export interface ToolExecuteContext {
62
63
  toolCallId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/core",
3
- "version": "1.437.0",
3
+ "version": "1.438.0",
4
4
  "description": "Stateless, task-oriented AI agent core",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",