Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Refactor run handling to use run object instead of runId #531

Merged
merged 10 commits into from
Jan 10, 2025

Conversation

nadeesha
Copy link
Contributor

@nadeesha nadeesha commented Jan 9, 2025

PR Type

Bug fix, Enhancement, Tests


Description

  • Refactored Run handling to replace runId with run object.

  • Improved type safety by replacing Run type with explicit object definitions.

  • Enhanced database schema with stricter constraints and improved default values.

  • Updated and expanded test cases to align with refactored logic.


Changes walkthrough 📝

Relevant files
Tests
8 files
auth.test.ts
Refactored test cases for extractAuthState and extractCustomAuthState.
+47/-94 
agent.ai.test.ts
Added `modelIdentifier` and other properties to test `run` object.
+11/-0   
edges.test.ts
Updated test cases for `postStartEdge` and `postModelEdge`.
+20/-0   
model-call.test.ts
Refactored test cases for `handleModelCall`.                         
+9/-0     
model-output.test.ts
Updated `buildModelSchema` tests with refactored `run` object.
+36/-26 
tool-call.test.ts
Refactored `handleToolCalls` tests with updated `run` object.
+10/-0   
run.test.ts
Updated `findRelevantTools` and `buildMockTools` tests.   
+9/-2     
index.test.ts
Refactored `assertRunReady` and related tests.                     
+45/-42 
Enhancement
10 files
data.ts
Enhanced database schema for `runs` table.                             
+4/-2     
router.ts
Updated router logic to use `run` object.                               
+23/-18 
agent.ts
Refactored `createRunGraph` to use explicit `run` object.
+15/-2   
tool-call.ts
Refactored `handleToolCall` to use explicit `run` object.
+15/-3   
run.ts
Refactored processRun and related functions to use explicit run
object.
+55/-8   
state.ts
Updated `RunGraphState` to use explicit `run` object.       
+29/-3   
index.ts
Refactored core `Run` handling logic and database operations.
+159/-164
notify.ts
Updated `notifyStatusChange` to use explicit `run` object.
+9/-2     
router.ts
Refactored router logic to align with `run` object changes.
+9/-16   
summarization.ts
Updated `generateTitle` to use explicit `run` object.       
+6/-3     

💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

Copy link
Contributor

qodo-merge-pro bot commented Jan 9, 2025

CI Failure Feedback 🧐

(Checks updated until commit f4632e7)

Action: test-control-plane

Failed stage: Run tests [❌]

Failed test name: src/modules/runs/agent/nodes/model-call.test.ts

Failure summary:

The action failed due to test failures in the file src/modules/runs/agent/nodes/model-call.test.ts.
Two specific test cases failed:

1. "handleModelCall › should ignore done if invocations are provided"
2. "handleModelCall ›
additional tool calls › should add to existing invocations array"

Both failures occurred because the test expected an array of length 1 but received an array of
length 2. The received arrays contained unexpected additional error messages related to invalid
model responses and property validation failures.

Relevant error logs:
1:  ##[group]Operating System
2:  Ubuntu
...

363:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
364:  PASS src/modules/runs/agent/nodes/tool-call.test.ts
365:  ● Console
366:  console.log
367:  {"deployment.version":"unknown","level":"info","message":"Executing tool call","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
368:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
369:  at Array.map (<anonymous>)
370:  console.log
371:  {"deployment.version":"unknown","error":{"message":"Received empty response from tool executor","name":"AgentError","stack":"AgentError: Received empty response from tool executor\n    at _handleToolCall (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:186:13)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at async Promise.all (index 0)\n    at _handleToolCalls (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:56:23)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at Object.<anonymous> (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.test.ts:85:25)"},"level":"error","message":"Failed to invoke tool","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo","toolName":"console_echo"}
372:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
373:  at async Promise.all (index 0)
374:  console.log
375:  {"cluster.id":"test","deployment.version":"unknown","error":{"message":"Region is missing","name":"Error","stack":"Error: Region is missing\n    at default (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:117:11)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/node-config-provider/dist-cjs/index.js:90:104\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:97:33\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at coalesceProvider (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:124:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:135:20\n    at region (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:142:30)\n    at Object.defaultSQSHttpAuthSchemeParametersProvider [as httpAuthSchemeParametersProvider] (/home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/client-sqs/dist-cjs/auth/httpAuthSchemeProvider.js:9:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/core/dist-cjs/index.js:65:5\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-sdk-sqs/dist-cjs/index.js:134:16\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22\n    at attributes.cluster.id (/home/runner/work/inferable/inferable/control-plane/src/modules/track-customer-telemetry.ts:44:26)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at _handleToolCall (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:345:5)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at async Promise.all (index 0)\n    at _handleToolCalls (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:56:23)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at Object.<anonymous> (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.test.ts:85:25)"},"event":{"clusterId":"test","completedAt":1736472088393,"input":{"input":"hello"},"level":"ERROR","output":{"name":"AgentError"},"runId":"test","startedAt":1736472088374,"toolName":"console_echo","type":"toolCall"},"level":"error","message":"Error sending model call event to SQS","queueUrl":"PLACEHOLDER","run.id":"test","sqs.queue.url":"PLACEHOLDER","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
376:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
377:  at async Promise.all (index 0)
378:  console.log
379:  {"deployment.version":"unknown","error":{"message":"Region is missing","name":"Error","stack":"Error: Region is missing\n    at default (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:117:11)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/node-config-provider/dist-cjs/index.js:90:104\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:97:33\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at coalesceProvider (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:124:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:135:20\n    at region (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:142:30)\n    at Object.defaultSQSHttpAuthSchemeParametersProvider [as httpAuthSchemeParametersProvider] (/home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/client-sqs/dist-cjs/auth/httpAuthSchemeProvider.js:9:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/core/dist-cjs/index.js:65:5\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-sdk-sqs/dist-cjs/index.js:134:16\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22\n    at attributes.cluster.id (/home/runner/work/inferable/inferable/control-plane/src/modules/track-customer-telemetry.ts:44:26)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at _handleToolCall (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:345:5)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at async Promise.all (index 0)\n    at _handleToolCalls (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:56:23)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at Object.<anonymous> (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.test.ts:85:25)"},"event":{"clusterId":"test","completedAt":1736472088393,"input":{"input":"hello"},"level":"ERROR","output":{"name":"AgentError"},"runId":"test","startedAt":1736472088374,"toolName":"console_echo","type":"toolCall"},"level":"warn","message":"Error sending customer telemetry event to SQS","queueUrl":"PLACEHOLDER","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
...

383:  {"deployment.version":"unknown","level":"info","message":"Executing tool call","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
384:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
385:  at Array.map (<anonymous>)
386:  console.log
387:  {"deployment.version":"unknown","level":"info","message":"Executing tool call","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
388:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
389:  at Array.map (<anonymous>)
390:  console.log
391:  {"cluster.id":"test","deployment.version":"unknown","error":{"message":"Region is missing","name":"Error","stack":"Error: Region is missing\n    at default (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:117:11)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/node-config-provider/dist-cjs/index.js:90:104\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:97:33\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at coalesceProvider (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:124:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:135:20\n    at region (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:142:30)\n    at Object.defaultSQSHttpAuthSchemeParametersProvider [as httpAuthSchemeParametersProvider] (/home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/client-sqs/dist-cjs/auth/httpAuthSchemeProvider.js:9:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/core/dist-cjs/index.js:65:5\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-sdk-sqs/dist-cjs/index.js:134:16\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22\n    at attributes.cluster.id (/home/runner/work/inferable/inferable/control-plane/src/modules/track-customer-telemetry.ts:44:26)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at _handleToolCall (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:141:5)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at async Promise.all (index 0)\n    at _handleToolCalls (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:56:23)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at Object.<anonymous> (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.test.ts:118:25)"},"event":{"clusterId":"test","completedAt":1736472088417,"input":{"input":"hello"},"level":"ERROR","output":{"name":"NotFoundError","statusCode":404},"runId":"test","startedAt":1736472088417,"toolName":"console_echo","type":"toolCall"},"level":"error","message":"Error sending model call event to SQS","queueUrl":"PLACEHOLDER","run.id":"test","sqs.queue.url":"PLACEHOLDER","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
392:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
393:  at async Promise.all (index 0)
394:  console.log
395:  {"deployment.version":"unknown","error":{"message":"Region is missing","name":"Error","stack":"Error: Region is missing\n    at default (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:117:11)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/node-config-provider/dist-cjs/index.js:90:104\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:97:33\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at coalesceProvider (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:124:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:135:20\n    at region (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:142:30)\n    at Object.defaultSQSHttpAuthSchemeParametersProvider [as httpAuthSchemeParametersProvider] (/home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/client-sqs/dist-cjs/auth/httpAuthSchemeProvider.js:9:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/core/dist-cjs/index.js:65:5\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-sdk-sqs/dist-cjs/index.js:134:16\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22\n    at attributes.cluster.id (/home/runner/work/inferable/inferable/control-plane/src/modules/track-customer-telemetry.ts:44:26)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at _handleToolCall (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:141:5)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at async Promise.all (index 0)\n    at _handleToolCalls (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:56:23)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at Object.<anonymous> (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.test.ts:118:25)"},"event":{"clusterId":"test","completedAt":1736472088417,"input":{"input":"hello"},"level":"ERROR","output":{"name":"NotFoundError","statusCode":404},"runId":"test","startedAt":1736472088417,"toolName":"console_echo","type":"toolCall"},"level":"warn","message":"Error sending customer telemetry event to SQS","queueUrl":"PLACEHOLDER","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
396:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
397:  at async Promise.all (index 0)
398:  console.log
399:  {"deployment.version":"unknown","level":"info","message":"Executing tool call","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
400:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
401:  at Array.map (<anonymous>)
402:  console.log
403:  {"deployment.version":"unknown","error":{"message":"instance requires property \"input\"\ninstance is not allowed to have the additional property \"wrongKey\"","name":"Error","stack":"Error: instance requires property \"input\"\ninstance is not allowed to have the additional property \"wrongKey\"\n    at AgentTool.execute (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/tool.ts:54:13)\n    at execute (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:184:36)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)"},"level":"info","message":"Agent provided invalid tool input","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo","toolName":"console_echo"}
404:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
405:  console.log
406:  {"cluster.id":"test","deployment.version":"unknown","error":{"message":"Region is missing","name":"Error","stack":"Error: Region is missing\n    at default (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:117:11)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/node-config-provider/dist-cjs/index.js:90:104\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:97:33\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at coalesceProvider (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:124:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:135:20\n    at region (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:142:30)\n    at Object.defaultSQSHttpAuthSchemeParametersProvider [as httpAuthSchemeParametersProvider] (/home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/client-sqs/dist-cjs/auth/httpAuthSchemeProvider.js:9:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/core/dist-cjs/index.js:65:5\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-sdk-sqs/dist-cjs/index.js:134:16\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22\n    at attributes.cluster.id (/home/runner/work/inferable/inferable/control-plane/src/modules/track-customer-telemetry.ts:44:26)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)"},"event":{"clusterId":"test","completedAt":1736472088427,"input":{"wrongKey":"something"},"level":"ERROR","runId":"test","startedAt":1736472088426,"toolName":"console_echo","type":"toolCall"},"level":"error","message":"Error sending model call event to SQS","queueUrl":"PLACEHOLDER","run.id":"test","sqs.queue.url":"PLACEHOLDER","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
407:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
408:  console.log
409:  {"deployment.version":"unknown","error":{"message":"Region is missing","name":"Error","stack":"Error: Region is missing\n    at default (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:117:11)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/node-config-provider/dist-cjs/index.js:90:104\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:97:33\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at coalesceProvider (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:124:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:135:20\n    at region (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:142:30)\n    at Object.defaultSQSHttpAuthSchemeParametersProvider [as httpAuthSchemeParametersProvider] (/home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/client-sqs/dist-cjs/auth/httpAuthSchemeProvider.js:9:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/core/dist-cjs/index.js:65:5\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-sdk-sqs/dist-cjs/index.js:134:16\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22\n    at attributes.cluster.id (/home/runner/work/inferable/inferable/control-plane/src/modules/track-customer-telemetry.ts:44:26)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)"},"event":{"clusterId":"test","completedAt":1736472088427,"input":{"wrongKey":"something"},"level":"ERROR","runId":"test","startedAt":1736472088426,"toolName":"console_echo","type":"toolCall"},"level":"warn","message":"Error sending customer telemetry event to SQS","queueUrl":"PLACEHOLDER","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
...

411:  console.log
412:  {"deployment.version":"unknown","level":"info","message":"Found invocation-result message, finding last non-invocation message","timestamp":"2025-01-10 01:21:28","toolCallId":"456"}
413:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
414:  console.log
415:  {"deployment.version":"unknown","level":"info","message":"Executing tool call","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
416:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
417:  at Array.map (<anonymous>)
418:  console.log
419:  {"deployment.version":"unknown","error":{"message":"Received empty response from tool executor","name":"AgentError","stack":"AgentError: Received empty response from tool executor\n    at _handleToolCall (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:186:13)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at async Promise.all (index 0)\n    at _handleToolCalls (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:56:23)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at Object.<anonymous> (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.test.ts:242:27)"},"level":"error","message":"Failed to invoke tool","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo","toolName":"console_echo"}
420:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
421:  at async Promise.all (index 0)
422:  console.log
423:  {"cluster.id":"test","deployment.version":"unknown","error":{"message":"Region is missing","name":"Error","stack":"Error: Region is missing\n    at default (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:117:11)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/node-config-provider/dist-cjs/index.js:90:104\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:97:33\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at coalesceProvider (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:124:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:135:20\n    at region (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:142:30)\n    at Object.defaultSQSHttpAuthSchemeParametersProvider [as httpAuthSchemeParametersProvider] (/home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/client-sqs/dist-cjs/auth/httpAuthSchemeProvider.js:9:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/core/dist-cjs/index.js:65:5\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-sdk-sqs/dist-cjs/index.js:134:16\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22\n    at attributes.cluster.id (/home/runner/work/inferable/inferable/control-plane/src/modules/track-customer-telemetry.ts:44:26)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at _handleToolCall (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:345:5)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at async Promise.all (index 0)\n    at _handleToolCalls (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:56:23)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at Object.<anonymous> (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.test.ts:242:27)"},"event":{"clusterId":"test","completedAt":1736472088437,"input":{"input":"hello"},"level":"ERROR","output":{"name":"AgentError"},"runId":"test","startedAt":1736472088437,"toolName":"console_echo","type":"toolCall"},"level":"error","message":"Error sending model call event to SQS","queueUrl":"PLACEHOLDER","run.id":"test","sqs.queue.url":"PLACEHOLDER","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
424:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
425:  at async Promise.all (index 0)
426:  console.log
427:  {"deployment.version":"unknown","error":{"message":"Region is missing","name":"Error","stack":"Error: Region is missing\n    at default (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:117:11)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/node-config-provider/dist-cjs/index.js:90:104\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:97:33\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at coalesceProvider (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:124:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:135:20\n    at region (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:142:30)\n    at Object.defaultSQSHttpAuthSchemeParametersProvider [as httpAuthSchemeParametersProvider] (/home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/client-sqs/dist-cjs/auth/httpAuthSchemeProvider.js:9:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/core/dist-cjs/index.js:65:5\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-sdk-sqs/dist-cjs/index.js:134:16\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22\n    at attributes.cluster.id (/home/runner/work/inferable/inferable/control-plane/src/modules/track-customer-telemetry.ts:44:26)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at _handleToolCall (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:345:5)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at async Promise.all (index 0)\n    at _handleToolCalls (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.ts:56:23)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)\n    at Object.<anonymous> (/home/runner/work/inferable/inferable/control-plane/src/modules/runs/agent/nodes/tool-call.test.ts:242:27)"},"event":{"clusterId":"test","completedAt":1736472088437,"input":{"input":"hello"},"level":"ERROR","output":{"name":"AgentError"},"runId":"test","startedAt":1736472088437,"toolName":"console_echo","type":"toolCall"},"level":"warn","message":"Error sending customer telemetry event to SQS","queueUrl":"PLACEHOLDER","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
...

431:  {"deployment.version":"unknown","level":"info","message":"Executing tool call","timestamp":"2025-01-10 01:21:28","tool.call.id":"123","tool.name":"console_echo"}
432:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
433:  at Array.map (<anonymous>)
434:  console.log
435:  {"deployment.version":"unknown","level":"info","message":"Executing tool call","timestamp":"2025-01-10 01:21:28","tool.call.id":"456","tool.name":"console_echo"}
436:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
437:  at Array.map (<anonymous>)
438:  console.log
439:  {"cluster.id":"test","deployment.version":"unknown","error":{"message":"Region is missing","name":"Error","stack":"Error: Region is missing\n    at default (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:117:11)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/node-config-provider/dist-cjs/index.js:90:104\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:97:33\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at coalesceProvider (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:124:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:135:20\n    at region (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:142:30)\n    at Object.defaultSQSHttpAuthSchemeParametersProvider [as httpAuthSchemeParametersProvider] (/home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/client-sqs/dist-cjs/auth/httpAuthSchemeProvider.js:9:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/core/dist-cjs/index.js:65:5\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-sdk-sqs/dist-cjs/index.js:134:16\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22\n    at attributes.cluster.id (/home/runner/work/inferable/inferable/control-plane/src/modules/track-customer-telemetry.ts:44:26)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)"},"event":{"clusterId":"test","completedAt":1736472088445,"input":{"input":"world"},"level":"DEFAULT","output":{"result":{},"resultType":"resolution","status":"success"},"runId":"test","startedAt":1736472088444,"toolName":"console_echo","type":"toolCall"},"level":"error","message":"Error sending model call event to SQS","queueUrl":"PLACEHOLDER","run.id":"test","sqs.queue.url":"PLACEHOLDER","timestamp":"2025-01-10 01:21:28","tool.call.id":"456","tool.name":"console_echo"}
440:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
441:  console.log
442:  {"deployment.version":"unknown","error":{"message":"Region is missing","name":"Error","stack":"Error: Region is missing\n    at default (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:117:11)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/node-config-provider/dist-cjs/index.js:90:104\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:97:33\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at coalesceProvider (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:124:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/property-provider/dist-cjs/index.js:135:20\n    at region (/home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/config-resolver/dist-cjs/index.js:142:30)\n    at Object.defaultSQSHttpAuthSchemeParametersProvider [as httpAuthSchemeParametersProvider] (/home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/client-sqs/dist-cjs/auth/httpAuthSchemeProvider.js:9:18)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@smithy/core/dist-cjs/index.js:65:5\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-sdk-sqs/dist-cjs/index.js:134:16\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22\n    at attributes.cluster.id (/home/runner/work/inferable/inferable/control-plane/src/modules/track-customer-telemetry.ts:44:26)\n    at handler (/home/runner/work/inferable/inferable/control-plane/src/modules/observability/tracer.ts:49:16)"},"event":{"clusterId":"test","completedAt":1736472088445,"input":{"input":"world"},"level":"DEFAULT","output":{"result":{},"resultType":"resolution","status":"success"},"runId":"test","startedAt":1736472088444,"toolName":"console_echo","type":"toolCall"},"level":"warn","message":"Error sending customer telemetry event to SQS","queueUrl":"PLACEHOLDER","timestamp":"2025-01-10 01:21:28","tool.call.id":"456","tool.name":"console_echo"}
...

456:  ● Console
457:  console.log
458:  {"deployment.version":"unknown","level":"warn","message":"Model context window not set, defaulting to 100_000","timestamp":"2025-01-10 01:21:26"}
459:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
460:  console.log
461:  {"deployment.version":"unknown","level":"warn","message":"Model context window not set, defaulting to 100_000","timestamp":"2025-01-10 01:21:27"}
462:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
463:  console.log
464:  {"deployment.version":"unknown","errors":[{"argument":"reasoning","instance":{"input":{"message":"A message"},"reasoning":"notify the system","toolName":"notify"},"message":"is not allowed to have the additional property \"reasoning\"","name":"additionalProperties","path":["invocations",0],"property":"instance.invocations[0]","schema":{"additionalProperties":false,"properties":{"input":{"additionalProperties":true,"description":"Arbitrary input parameters for the tool call.","type":"object"},"toolName":{"enum":["testTool","notify"],"type":"string"}},"required":["toolName","input"],"type":"object"},"stack":"instance.invocations[0] is not allowed to have the additional property \"reasoning\""}],"level":"info","message":"Model provided invalid response object","timestamp":"2025-01-10 01:21:27"}
...

474:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
475:  console.log
476:  {"deployment.version":"unknown","level":"info","message":"Model returned done with no result","timestamp":"2025-01-10 01:21:28"}
477:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
478:  console.log
479:  {"deployment.version":"unknown","level":"warn","message":"Model context window not set, defaulting to 100_000","timestamp":"2025-01-10 01:21:28"}
480:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
481:  console.log
482:  {"deployment.version":"unknown","errors":[{"argument":"randomStuff","instance":{"randomStuff":"123"},"message":"is not allowed to have the additional property \"randomStuff\"","name":"additionalProperties","path":[],"property":"instance","schema":{"additionalProperties":false,"properties":{"done":{"description":"Whether the workflow is done. All tasks have been completed or you can not progress further.","type":"boolean"},"invocations":{"description":"Any tool calls you need to make. If multiple are provided, they will be executed in parallel. DO NOT describe previous tool calls.","items":{"additionalProperties":false,"properties":{"input":{"additionalProperties":true,"description":"Arbitrary input parameters for the tool call.","type":"object"},"toolName":{"enum":["testTool","notify"],"type":"string"}},"required":["toolName","input"],"type":"object"},"type":"array"},"issue":{"description":"Describe any issues you have encountered in this step. Specifically related to the tools you are using. If none, keep this field empty.","type":"string"},"message":{"description":"A message describing the current state or next steps.","type":"string"}},"type":"object"},"stack":"instance is not allowed to have the additional property \"randomStuff\""}],"level":"info","message":"Model provided invalid response object","timestamp":"2025-01-10 01:21:29"}
...

486:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
487:  console.log
488:  {"additional":["notify"],"deployment.version":"unknown","level":"info","message":"Structured output attempted to call additional tools","timestamp":"2025-01-10 01:21:29"}
489:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
490:  console.log
491:  {"deployment.version":"unknown","level":"warn","message":"Model context window not set, defaulting to 100_000","timestamp":"2025-01-10 01:21:29"}
492:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
493:  console.log
494:  {"deployment.version":"unknown","errors":[{"argument":"reasoning","instance":{"input":{"message":"the first notification"},"reasoning":"notify the system","toolName":"notify"},"message":"is not allowed to have the additional property \"reasoning\"","name":"additionalProperties","path":["invocations",0],"property":"instance.invocations[0]","schema":{"additionalProperties":false,"properties":{"input":{"additionalProperties":true,"description":"Arbitrary input parameters for the tool call.","type":"object"},"toolName":{"enum":["testTool","notify"],"type":"string"}},"required":["toolName","input"],"type":"object"},"stack":"instance.invocations[0] is not allowed to have the additional property \"reasoning\""}],"level":"info","message":"Model provided invalid response object","timestamp":"2025-01-10 01:21:30"}
495:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
496:  ● handleModelCall › should ignore done if invocations are provided
497:  expect(received).toHaveLength(expected)
498:  Expected length: 1
499:  Received length: 2
500:  Received array:  [{"clusterId": "test-cluster", "createdAt": 2025-01-10T01:21:27.814Z, "data": {"details": {"content": []}, "message": "Invalid model response."}, "id": "01JH6WTK85PRM0FJDB0M2NGQ8B", "runId": "test-run", "type": "agent-invalid"}, {"clusterId": "test-cluster", "createdAt": 2025-01-10T01:21:27.814Z, "data": {"details": {"errors": [{"argument": "reasoning", "instance": {"input": {"message": "A message"}, "reasoning": "notify the system", "toolName": "notify"}, "message": "is not allowed to have the additional property \"reasoning\"", "name": "additionalProperties", "path": ["invocations", 0], "property": "instance.invocations[0]", "schema": {"additionalProperties": false, "properties": {"input": {"additionalProperties": true, "description": "Arbitrary input parameters for the tool call.", "type": "object"}, "toolName": {"enum": ["testTool", "notify"], "type": "string"}}, "required": ["toolName", "input"], "type": "object"}, "stack": "instance.invocations[0] is not allowed to have the additional property \"reasoning\""}]}, "message": "Provided object was invalid, check your input"}, "id": "01JH6WTK86TEE305QC10S08GQ2", "runId": "test-run", "type": "supervisor"}]
...

529:  �[90m 313 |�[39m         {
530:  �[90m 314 |�[39m           id�[33m:�[39m expect�[33m.�[39many(�[33mString�[39m)�[33m,�[39m
531:  �[90m 315 |�[39m           toolName�[33m:�[39m �[32m"notify"�[39m�[33m,�[39m�[0m
532:  at Object.toHaveProperty (src/modules/runs/agent/nodes/model-call.test.ts:312:33)
533:  ● handleModelCall › additional tool calls › should add to existing invocations array
534:  expect(received).toHaveLength(expected)
535:  Expected length: 1
536:  Received length: 2
537:  Received array:  [{"clusterId": "test-cluster", "createdAt": 2025-01-10T01:21:30.003Z, "data": {"details": {"content": [{"input": {"done": false}, "name": "extract", "type": "tool_use"}, {"input": {"message": "A message to another system"}, "name": "notify", "type": "tool_use"}]}, "message": "Invalid model response."}, "id": "01JH6WTNCKW36D18MS8KCPBN8P", "runId": "test-run", "type": "agent-invalid"}, {"clusterId": "test-cluster", "createdAt": 2025-01-10T01:21:30.003Z, "data": {"details": {"errors": [{"argument": "reasoning", "instance": {"input": {"message": "the first notification"}, "reasoning": "notify the system", "toolName": "notify"}, "message": "is not allowed to have the additional property \"reasoning\"", "name": "additionalProperties", "path": ["invocations", 0], "property": "instance.invocations[0]", "schema": {"additionalProperties": false, "properties": {"input": {"additionalProperties": true, "description": "Arbitrary input parameters for the tool call.", "type": "object"}, "toolName": {"enum": ["testTool", "notify"], "type": "string"}}, "required": ["toolName", "input"], "type": "object"}, "stack": "instance.invocations[0] is not allowed to have the additional property \"reasoning\""}]}, "message": "Provided object was invalid, check your input"}, "id": "01JH6WTNCK9QJ9D32PMQ3HXABX", "runId": "test-run", "type": "supervisor"}]
...

544:  �[90m 364 |�[39m       expect(result�[33m.�[39mmessages�[33m!�[39m[�[35m0�[39m])�[33m.�[39mtoHaveProperty(�[32m"type"�[39m�[33m,�[39m �[32m"agent"�[39m)�[33m;�[39m�[0m
545:  at Object.toHaveLength (src/modules/runs/agent/nodes/model-call.test.ts:361:31)
546:  PASS src/modules/runs/agent/overflow.test.ts
547:  ● Console
548:  console.log
549:  {"deployment.version":"unknown","inputTokenCount":900,"level":"info","message":"Run history exceeds context window, early messages have been truncated","outputTokenCount":300,"removedMessageIds":[null,null,null],"systemPromptTokenCount":200,"timestamp":"2025-01-10 01:21:30"}
550:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
551:  console.log
552:  {"deployment.version":"unknown","level":"error","message":"A single message exceeds context window","timestamp":"2025-01-10 01:21:30"}
...

558:  {"deployment.version":"unknown","inputTokenCount":1000,"level":"info","message":"Run history exceeds context window, early messages have been truncated","outputTokenCount":600,"removedMessageIds":["456","123"],"systemPromptTokenCount":200,"timestamp":"2025-01-10 01:21:30"}
559:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
560:  console.log
561:  {"deployment.version":"unknown","inputTokenCount":1000,"level":"info","message":"Run history exceeds context window, early messages have been truncated","outputTokenCount":600,"removedMessageIds":["789","123"],"systemPromptTokenCount":200,"timestamp":"2025-01-10 01:21:30"}
562:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
563:  PASS src/modules/service-definitions.test.ts
564:  ● Console
565:  console.log
566:  {"args":[{}],"deployment.version":"unknown","level":"error","message":"Invalid job arguments","timestamp":"2025-01-10 01:21:31"}
567:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
568:  console.log
569:  {"args":1,"deployment.version":"unknown","level":"error","message":"Invalid job arguments","timestamp":"2025-01-10 01:21:31"}
...

697:  {"deployment.version":"unknown","level":"warn","message":"Skipping run resume. NODE_ENV is set to 'test'.","timestamp":"2025-01-10 01:21:42"}
698:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
699:  console.log
700:  {"deployment.version":"unknown","jobId":"01JH6WV1VM7RBP7AGEZT32GEZH","level":"warn","message":"Job result was not persisted","timestamp":"2025-01-10 01:21:42"}
701:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
702:  PASS src/modules/models/index.test.ts
703:  ● Console
704:  console.log
705:  {"attempt":1,"deployment.version":"unknown","error":{"message":"","name":"RetryableError","stack":"RetryableError: \n    at Object.<anonymous> (/home/runner/work/inferable/inferable/control-plane/src/modules/models/index.test.ts:33:15)\n    at /home/runner/work/inferable/inferable/control-plane/node_modules/jest-mock/build/index.js:397:39\n    at Object.<anonymous> (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-mock/build/index.js:404:13)\n    at Object.mockConstructor [as create] (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-mock/build/index.js:148:19)\n    at create (/home/runner/work/inferable/inferable/control-plane/src/modules/models/index.ts:136:67)\n    at RetryOperation.runAttempt [as _fn] (/home/runner/work/inferable/inferable/control-plane/node_modules/async-retry/lib/index.js:42:15)\n    at RetryOperation.Object.<anonymous>.RetryOperation.attempt (/home/runner/work/inferable/inferable/control-plane/node_modules/retry/lib/retry_operation.js:116:8)\n    at run (/home/runner/work/inferable/inferable/control-plane/node_modules/async-retry/lib/index.js:55:8)\n    at new Promise (<anonymous>)\n    at retry (/home/runner/work/inferable/inferable/control-plane/node_modules/async-retry/lib/index.js:58:10)\n    at Object.call (/home/runner/work/inferable/inferable/control-plane/src/modules/models/index.ts:97:40)\n    at Object.call (/home/runner/work/inferable/inferable/control-plane/src/modules/models/index.test.ts:40:19)\n    at Promise.then.completed (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/utils.js:298:28)\n    at new Promise (<anonymous>)\n    at callAsyncCircusFn (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/utils.js:231:10)\n    at _callCircusTest (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:316:40)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at _runTest (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:252:3)\n    at _runTestsForDescribeBlock (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:126:9)\n    at _runTestsForDescribeBlock (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:121:9)\n    at _runTestsForDescribeBlock (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:121:9)\n    at run (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:71:3)\n    at runAndTransformResultsToJestFormat (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)\n    at jestAdapter (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)\n    at runTestInternal (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-runner/build/runTest.js:367:16)\n    at runTest (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-runner/build/runTest.js:444:34)\n    at Object.worker (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-runner/build/testWorker.js:106:12)"},"level":"warn","message":"Model call failed with retryable error","timestamp":"2025-01-10 01:21:41"}
706:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
707:  console.log
708:  {"deployment.version":"unknown","level":"warn","message":"No cluster id provided, usage tracking will be skipped","timestamp":"2025-01-10 01:21:42"}
709:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
710:  console.log
711:  {"attempt":1,"deployment.version":"unknown","error":{"message":"","name":"Error","stack":"Error: \n    at Object.<anonymous> (/home/runner/work/inferable/inferable/control-plane/src/modules/models/index.test.ts:59:21)\n    at Promise.then.completed (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/utils.js:298:28)\n    at new Promise (<anonymous>)\n    at callAsyncCircusFn (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/utils.js:231:10)\n    at _callCircusTest (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:316:40)\n    at _runTest (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:252:3)\n    at _runTestsForDescribeBlock (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:126:9)\n    at _runTestsForDescribeBlock (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:121:9)\n    at _runTestsForDescribeBlock (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:121:9)\n    at run (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:71:3)\n    at runAndTransformResultsToJestFormat (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)\n    at jestAdapter (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)\n    at runTestInternal (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-runner/build/runTest.js:367:16)\n    at runTest (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-runner/build/runTest.js:444:34)\n    at Object.worker (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-runner/build/testWorker.js:106:12)"},"level":"error","message":"Model call failed with non-retryable error","timestamp":"2025-01-10 01:21:42"}
...

723:  console.log
724:  {"clusterId":"test-cluster-0.1289972305563425","deployment.version":"unknown","level":"info","message":"Activating Slack integration","timestamp":"2025-01-10 01:21:44"}
725:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
726:  at Array.map (<anonymous>)
727:  PASS src/modules/clusters.test.ts
728:  PASS src/modules/auth/clerk.test.ts
729:  ● Console
730:  console.log
731:  {"deployment.version":"unknown","error":{"message":"jwt malformed","name":"JsonWebTokenError","stack":"JsonWebTokenError: jwt malformed\n    at Object.<anonymous>.module.exports [as verify] (/home/runner/work/inferable/inferable/control-plane/node_modules/jsonwebtoken/verify.js:70:17)\n    at verify (/home/runner/work/inferable/inferable/control-plane/src/modules/auth/clerk.ts:41:9)\n    at new Promise (<anonymous>)\n    at Object.verify (/home/runner/work/inferable/inferable/control-plane/src/modules/auth/clerk.ts:40:10)\n    at Object.verify (/home/runner/work/inferable/inferable/control-plane/src/modules/auth/clerk.test.ts:32:28)\n    at Promise.then.completed (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/utils.js:298:28)\n    at new Promise (<anonymous>)\n    at callAsyncCircusFn (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/utils.js:231:10)\n    at _callCircusTest (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:316:40)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at _runTest (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:252:3)\n    at _runTestsForDescribeBlock (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:126:9)\n    at _runTestsForDescribeBlock (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:121:9)\n    at run (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/run.js:71:3)\n    at runAndTransformResultsToJestFormat (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)\n    at jestAdapter (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)\n    at runTestInternal (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-runner/build/runTest.js:367:16)\n    at runTest (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-runner/build/runTest.js:444:34)\n    at Object.worker (/home/runner/work/inferable/inferable/control-plane/node_modules/jest-runner/build/testWorker.js:106:12)"},"level":"info","message":"Error verifying JWT token","timestamp":"2025-01-10 01:21:44"}
732:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
733:  PASS src/modules/machines.test.ts
734:  PASS src/modules/auth/cluster.test.ts
735:  PASS src/modules/embeddings/embeddings.test.ts
736:  PASS src/modules/runs/tags.test.ts
737:  PASS src/modules/util.test.ts
738:  PASS src/utilities/errors.test.ts
...

740:  PASS src/modules/router.test.ts
741:  PASS src/modules/auth/custom.test.ts (21.813 s)
742:  ● Console
743:  console.log
744:  {"deployment.version":"unknown","level":"warn","message":"Skipping run resume. NODE_ENV is set to 'test'.","timestamp":"2025-01-10 01:21:35"}
745:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
746:  at async Promise.allSettled (index 0)
747:  console.log
748:  {"deployment.version":"unknown","error":{"message":"The client is closed","name":"Error","stack":"Error: The client is closed\n    at Commander._RedisClient_sendCommand (/home/runner/work/inferable/inferable/control-plane/node_modules/@redis/client/dist/lib/client/index.js:520:31)\n    at Commander.commandsExecutor (/home/runner/work/inferable/inferable/control-plane/node_modules/@redis/client/dist/lib/client/index.js:190:154)\n    at Commander.BaseClass.<computed> [as set] (/home/runner/work/inferable/inferable/control-plane/node_modules/@redis/client/dist/lib/commander.js:8:29)\n    at Object.set (/home/runner/work/inferable/inferable/control-plane/src/utilities/cache.ts:38:11)\n    at set (/home/runner/work/inferable/inferable/control-plane/src/modules/auth/custom.ts:120:34)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at Object.<anonymous> (/home/runner/work/inferable/inferable/control-plane/src/modules/auth/custom.test.ts:87:20)"},"key":"3bf437a588f11bb9dcd55939f73cc5e2b3f82f445f055a55109ee0fa1b2676f8","level":"error","message":"Error setting cache","timestamp":"2025-01-10 01:21:35","value":{"result":"{\"value\":{\"userId\":\"test-user\",\"roles\":[\"admin\"]}}","resultType":"resolution","service":"authService","status":"success"}}
749:  at Console.log (node_modules/winston/lib/winston/transports/console.js:87:23)
750:  A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
751:  Summary of all failing tests
752:  FAIL src/modules/runs/agent/nodes/model-call.test.ts (8.939 s)
753:  ● handleModelCall › should ignore done if invocations are provided
754:  expect(received).toHaveLength(expected)
755:  Expected length: 1
756:  Received length: 2
757:  Received array:  [{"clusterId": "test-cluster", "createdAt": 2025-01-10T01:21:27.814Z, "data": {"details": {"content": []}, "message": "Invalid model response."}, "id": "01JH6WTK85PRM0FJDB0M2NGQ8B", "runId": "test-run", "type": "agent-invalid"}, {"clusterId": "test-cluster", "createdAt": 2025-01-10T01:21:27.814Z, "data": {"details": {"errors": [{"argument": "reasoning", "instance": {"input": {"message": "A message"}, "reasoning": "notify the system", "toolName": "notify"}, "message": "is not allowed to have the additional property \"reasoning\"", "name": "additionalProperties", "path": ["invocations", 0], "property": "instance.invocations[0]", "schema": {"additionalProperties": false, "properties": {"input": {"additionalProperties": true, "description": "Arbitrary input parameters for the tool call.", "type": "object"}, "toolName": {"enum": ["testTool", "notify"], "type": "string"}}, "required": ["toolName", "input"], "type": "object"}, "stack": "instance.invocations[0] is not allowed to have the additional property \"reasoning\""}]}, "message": "Provided object was invalid, check your input"}, "id": "01JH6WTK86TEE305QC10S08GQ2", "runId": "test-run", "type": "supervisor"}]
...

786:  �[90m 313 |�[39m         {
787:  �[90m 314 |�[39m           id�[33m:�[39m expect�[33m.�[39many(�[33mString�[39m)�[33m,�[39m
788:  �[90m 315 |�[39m           toolName�[33m:�[39m �[32m"notify"�[39m�[33m,�[39m�[0m
789:  at Object.toHaveProperty (src/modules/runs/agent/nodes/model-call.test.ts:312:33)
790:  ● handleModelCall › additional tool calls › should add to existing invocations array
791:  expect(received).toHaveLength(expected)
792:  Expected length: 1
793:  Received length: 2
794:  Received array:  [{"clusterId": "test-cluster", "createdAt": 2025-01-10T01:21:30.003Z, "data": {"details": {"content": [{"input": {"done": false}, "name": "extract", "type": "tool_use"}, {"input": {"message": "A message to another system"}, "name": "notify", "type": "tool_use"}]}, "message": "Invalid model response."}, "id": "01JH6WTNCKW36D18MS8KCPBN8P", "runId": "test-run", "type": "agent-invalid"}, {"clusterId": "test-cluster", "createdAt": 2025-01-10T01:21:30.003Z, "data": {"details": {"errors": [{"argument": "reasoning", "instance": {"input": {"message": "the first notification"}, "reasoning": "notify the system", "toolName": "notify"}, "message": "is not allowed to have the additional property \"reasoning\"", "name": "additionalProperties", "path": ["invocations", 0], "property": "instance.invocations[0]", "schema": {"additionalProperties": false, "properties": {"input": {"additionalProperties": true, "description": "Arbitrary input parameters for the tool call.", "type": "object"}, "toolName": {"enum": ["testTool", "notify"], "type": "string"}}, "required": ["toolName", "input"], "type": "object"}, "stack": "instance.invocations[0] is not allowed to have the additional property \"reasoning\""}]}, "message": "Provided object was invalid, check your input"}, "id": "01JH6WTNCK9QJ9D32PMQ3HXABX", "runId": "test-run", "type": "supervisor"}]
795:  �[0m �[90m 359 |�[39m
796:  �[90m 360 |�[39m       expect(result)�[33m.�[39mtoBeDefined()�[33m;�[39m
797:  �[31m�[1m>�[22m�[39m�[90m 361 |�[39m       expect(result�[33m.�[39mmessages)�[33m.�[39mtoHaveLength(�[35m1�[39m)�[33m;�[39m
798:  �[90m     |�[39m                               �[31m�[1m^�[22m�[39m
799:  �[90m 362 |�[39m       expect(result�[33m.�[39mstatus)�[33m.�[39mtoBe(�[32m"running"�[39m)�[33m;�[39m
800:  �[90m 363 |�[39m
801:  �[90m 364 |�[39m       expect(result�[33m.�[39mmessages�[33m!�[39m[�[35m0�[39m])�[33m.�[39mtoHaveProperty(�[32m"type"�[39m�[33m,�[39m �[32m"agent"�[39m)�[33m;�[39m�[0m
802:  at Object.toHaveLength (src/modules/runs/agent/nodes/model-call.test.ts:361:31)
803:  Test Suites: 1 failed, 31 passed, 32 total
804:  Tests:       3 failed, 1 skipped, 168 passed, 172 total
805:  Snapshots:   0 total
806:  Time:        36.079 s
807:  Ran all test suites matching /src/i.
808:  Force exiting Jest: Have you considered using `--detectOpenHandles` to detect async operations that kept running after all tests finished?
809:  ##[error]Process completed with exit code 1.
...

816:  [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
817:  [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
818:  [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
819:  http.https://github.com/.extraheader
820:  [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
821:  [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
822:  Print service container logs: fe4e43bc8c2d4252974eca97445ac6e0_redis_0572a3
823:  ##[command]/usr/bin/docker logs --details 2eb38777d9726744fac4a1aa0d8e3d32a5d01f8f8299f5e99e63e9947af9564c
824:  1:C 10 Jan 2025 01:20:33.450 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

✨ CI feedback usage guide:

The CI feedback tool (/checks) automatically triggers when a PR has a failed check.
The tool analyzes the failed checks and provides several feedbacks:

  • Failed stage
  • Failed test name
  • Failure summary
  • Relevant error logs

In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:

/checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}"

where {repo_name} is the name of the repository, {run_number} is the run number of the failed check, and {job_number} is the job number of the failed check.

Configuration options

  • enable_auto_checks_feedback - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
  • excluded_checks_list - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
  • enable_help_text - if set to true, the tool will provide a help message with the feedback. Default is true.
  • persistent_comment - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true.
  • final_update_message - if persistent_comment is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true.

See more information about the checks tool in the docs.


if (!run) {
throw new Error("Failed to create run");
}

// Insert tags if provided
if (tags) {
await db.insert(runTags).values(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should still be possible to do this within the transaction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about not doing a transaction here?

The tags would only be used in a small minority, whereas applying the transaction would apply to all.

We can do a if (tags) transaction, but that's a bit too much code?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any disadvantage to doing this transactionally though?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess there would be some performance difference but that would be pretty marginal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the run row is extremely contentious right now, especially in the middle of a run. (asserting run ready etc). So, it's more to do with deadlocks and lags right now.

I think it's best to stay away from database transactions as much as you could, and instead rely on the database schema for atomic updates.

In hindsight, I think there's an opportunity here to reintegrate run tags into the workflow table.

nadeesha and others added 7 commits January 10, 2025 11:37
* fix: Remove knowledge artifact related code and components

* fix: Minor changes 2025-01-09-22:23:43

* fix: Minor changes 2025-01-09-23:20:58

* fix: Minor changes 2025-01-09-23:20:58

* fix: Minor changes 2025-01-09-23:20:58

* fix: Minor changes 2025-01-09-23:20:58
@nadeesha nadeesha marked this pull request as ready for review January 10, 2025 01:36
Copy link
Contributor

Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Type Safety

The refactoring introduces more explicit type definitions but some functions like addMessageAndResumeWithRun still use partial type definitions that could be made more complete for better type safety.

export const addMessageAndResumeWithRun = async ({
  userId,
  id,
  clusterId,
  message,
  type,
  metadata,
  skipAssert,
  run,
}: {
  userId?: string;
  id: string;
  clusterId: string;
  message: string;
  type: "human" | "template" | "supervisor";
  metadata?: RunMessageMetadata;
  skipAssert?: boolean;
  run: {
    id: string;
    name: string | null;
    status: string;
    interactive: boolean;
    clusterId: string;
  };
}) => {
Schema Change

The status field in the runs table is being modified to be non-null with a default value of 'pending'. This schema change should be validated to ensure it doesn't break existing code that expects null values.

status: text("status", {
  enum: ["pending", "running", "paused", "done", "failed"],
})
  .default("pending")
  .notNull(),

Copy link
Contributor

Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Score
Possible issue
Improve type safety by properly defining the run parameter type with specific status values

The type declaration for run in addMessageAndResumeWithRun is too loose. It should
be properly typed to ensure type safety and prevent runtime errors. Consider
creating a dedicated interface or type for the run parameter.

control-plane/src/modules/runs/index.ts [533-539]

-run: {
+run: RunInput;
+
+interface RunInput {
   id: string;
-  name: string | null; 
-  status: string;
+  name: string | null;
+  status: "pending" | "running" | "paused" | "done" | "failed";
   interactive: boolean;
   clusterId: string;
 }
  • Apply this suggestion
Suggestion importance[1-10]: 7

Why: The suggestion improves type safety by replacing loose string type with a union of specific status values, reducing potential runtime errors and making the code more maintainable.

7
Replace unsafe 'any' type with proper type definitions

The any type used for run1 and run2 variables should be replaced with a proper type
definition to ensure type safety and prevent potential runtime errors.

control-plane/src/modules/runs/index.ts [315-316]

-let run1: any;
-let run2: any;
+let run1: Run;
+let run2: Run;
  • Apply this suggestion
Suggestion importance[1-10]: 7

Why: Using 'any' type bypasses TypeScript's type checking and can lead to runtime errors. Replacing it with a proper type definition enhances code safety and maintainability.

7
Improve null value handling in feedback update to prevent unintended database updates

The feedback update in updateRun() is missing proper null handling which could lead
to unintended updates. Add explicit null checks and proper type handling.

control-plane/src/modules/runs/router.ts [249-255]

 await updateRun({
   id: runId,
   clusterId,
-  feedbackComment: comment ?? undefined,
-  feedbackScore: score ?? undefined,
+  ...(comment !== null ? { feedbackComment: comment } : {}),
+  ...(score !== null ? { feedbackScore: score } : {}),
   status: null,
 });
  • Apply this suggestion
Suggestion importance[1-10]: 6

Why: The suggestion provides more explicit null handling using spread operators, which prevents unintended database updates when feedback values are null.

6
General
Extract duplicated type definition into a shared interface to improve code maintainability

The run object type is duplicated in multiple function signatures. Create a shared
interface for the run object to improve code maintainability and reduce duplication.

control-plane/src/modules/runs/agent/nodes/tool-call.ts [91-97]

-run: {
+interface RunContext {
   id: string;
   clusterId: string;
   modelIdentifier: ChatIdentifiers | null;
   resultSchema: unknown | null;
   debug: boolean;
-},
+}
 
+run: RunContext,
+
  • Apply this suggestion
Suggestion importance[1-10]: 7

Why: The suggestion addresses significant code duplication across multiple files and would improve type safety, maintainability, and reduce potential inconsistencies in the run object structure.

7
Reorder column constraints to follow consistent schema definition patterns with 'notNull' before 'default'

The 'status' column in the 'runs' table should have its 'notNull' constraint defined
before the 'default' value to maintain consistent schema definition patterns and
ensure data integrity.

control-plane/src/modules/data.ts [305-309]

 status: text("status", {
   enum: ["pending", "running", "paused", "done", "failed"],
 })
-  .default("pending")
-  .notNull(),
+  .notNull()
+  .default("pending"),
  • Apply this suggestion
Suggestion importance[1-10]: 3

Why: While the suggestion is technically valid for maintaining consistent code style, it's a minor improvement that doesn't affect functionality since both orderings achieve the same database schema.

3

@nadeesha nadeesha merged commit ef7651c into main Jan 10, 2025
27 checks passed
@nadeesha nadeesha deleted the nadeesha/refactor-run-handling-dk6l branch January 10, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants