@mcoda/codali 0.1.122 → 0.1.124

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.
@@ -1 +1 @@
1
- {"version":3,"file":"LocalGatewayTaskRunner.d.ts","sourceRoot":"","sources":["../../src/gateway/LocalGatewayTaskRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EAGT,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,KAAK,EAEV,+BAA+B,EAC/B,gCAAgC,EAChC,6BAA6B,EAE9B,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAe1C,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,IAAI,CAAC;CACxD;AAED,MAAM,MAAM,2BAA2B,GACnC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,GAClF;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAClE;IACE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AAS,6BAA6B,KACrC,sBAA6D,CAAC;AAEjE,eAAO,MAAM,aAAa,UA3bD,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CA2b7B,CAAC"}
@@ -65,6 +65,34 @@ const toolDefinitionsFor = (registry, allowedTools) => registry.catalog(allowedT
65
65
  description: descriptor.description,
66
66
  inputSchema: descriptor.inputSchema,
67
67
  }));
68
+ /**
69
+ * Markers of a model describing tool activity that never happened.
70
+ *
71
+ * A worker offered tools and asked for evidence will sometimes write what a
72
+ * successful transcript looks like instead of calling anything — tool names,
73
+ * call ids, `"status": "success"`, and rows of data underneath. Observed in a
74
+ * timesheet product: employee ids and hours that exist nowhere, carrying a
75
+ * `tool_call_id` and labelled successful, against a connector that received no
76
+ * request at all.
77
+ *
78
+ * Prose is not the problem. A worker may legitimately answer "the results do
79
+ * not cover this" without calling anything. What must never pass is a claim of
80
+ * execution, because the evidence normalizer reads structures like
81
+ * `evidence_items` and would take invented rows for retrieved ones.
82
+ */
83
+ const FABRICATED_TOOL_RESULT_MARKERS = [
84
+ /"?tool_call_id"?\s*[:=]/i,
85
+ /"?evidence_items"?\s*[:=]/i,
86
+ /"?raw_data_excerpt"?\s*[:=]/i,
87
+ /"?tool_name"?\s*[:=]/i,
88
+ /"?status"?\s*[:=]\s*"?success"?/i,
89
+ ];
90
+ const claimsToolExecution = (output) => {
91
+ if (!output)
92
+ return false;
93
+ // Two independent markers, so a passing mention of a tool name is not enough.
94
+ return FABRICATED_TOOL_RESULT_MARKERS.filter((marker) => marker.test(output)).length >= 2;
95
+ };
68
96
  const buildTaskMessages = (input, hasTools) => {
69
97
  const system = [
70
98
  "You are a Codali gateway worker.",
@@ -79,6 +107,10 @@ const buildTaskMessages = (input, hasTools) => {
79
107
  // seven more calls unspent.
80
108
  "One search is rarely enough. In the same batch, add the tools that cover what a search cannot: listing a directory's files, reading a named file, or looking up a symbol's definition.",
81
109
  "Prefer several complementary calls over one broad one — unused calls cost nothing, a missing one costs the answer.",
110
+ // A worker asked for evidence has been observed writing what a
111
+ // successful transcript looks like — call ids, statuses and rows of
112
+ // invented data — instead of calling anything.
113
+ "Never describe a tool result you did not receive. If you call nothing, say what you could not determine; do not write out call ids, statuses, or example rows as though a tool had returned them.",
82
114
  ].join("\n")
83
115
  : "No tools are available. Answer from the task description alone or state what is missing.",
84
116
  "Report only what the tool results actually support. Never invent file paths, identifiers, figures, or quotations.",
@@ -179,6 +211,24 @@ export class LocalGatewayTaskRunner {
179
211
  // and we return rather than looping to look for more work.
180
212
  if (requested.length === 0) {
181
213
  const output = selection.message.content.trim();
214
+ // A worker that was given tools, called none, and then described tool
215
+ // results has invented them. Passing that on as a successful task makes
216
+ // fabricated rows indistinguishable from retrieved ones by the time the
217
+ // normalizer sees them, so it fails here instead.
218
+ if (toolDefinitions.length > 0 && claimsToolExecution(output)) {
219
+ return finish({
220
+ status: "failed",
221
+ errorCode: "GATEWAY_WORKER_FABRICATED_TOOL_RESULT",
222
+ errorMessage: "The worker reported tool results without calling any tool. Its output has been " +
223
+ "discarded rather than treated as evidence.",
224
+ metadata: {
225
+ pass: "direct",
226
+ modelCallCount: modelCalls.length,
227
+ toolCallCount: 0,
228
+ fabricatedToolResult: true,
229
+ },
230
+ });
231
+ }
182
232
  return finish({
183
233
  status: "succeeded",
184
234
  output,
@@ -186,6 +236,9 @@ export class LocalGatewayTaskRunner {
186
236
  pass: "direct",
187
237
  modelCallCount: modelCalls.length,
188
238
  toolCallCount: 0,
239
+ // Nothing was retrieved, so nothing downstream may treat this as
240
+ // having been.
241
+ ...(toolDefinitions.length > 0 ? { noToolsExecuted: true } : {}),
189
242
  ...(droppedForBudget > 0 ? { droppedToolCalls: droppedForBudget } : {}),
190
243
  },
191
244
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcoda/codali",
3
- "version": "0.1.122",
3
+ "version": "0.1.124",
4
4
  "description": "Standalone tool-runner adapter for mcoda.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -35,8 +35,8 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@modelcontextprotocol/sdk": "1.30.0",
38
- "@mcoda/db": "0.1.122",
39
- "@mcoda/shared": "0.1.122"
38
+ "@mcoda/db": "0.1.124",
39
+ "@mcoda/shared": "0.1.124"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "tsc -p tsconfig.json",