Skip to content

add unit test coverage for agent-service workflow-crud-tools (add / modify / delete operator tools) #6375

Description

@mengw15

Task Summary

agent-service/src/agent/tools/workflow-crud-tools.ts (codecov ~22%) exports createAddOperatorTool, createModifyOperatorTool, createDeleteOperatorTool — factories returning AI-SDK tools whose execute(args) mutate an in-memory WorkflowState. Unit-testable with bun test: construct a real WorkflowState, build the tool, call tool.execute(args), assert the state change + returned result. Only mock is context.metadataStore.validateOperatorProperties for the validation branches — no network. See tools/tools-utility.spec.ts for the pattern.

Behavior to cover

createDeleteOperatorTool

  • operator exists -> removes it (and connected links); returns "Deleted operator: {operatorId}"
  • operator absent -> createErrorResult("Operator {operatorId} not found")

createAddOperatorTool

  • unknown operatorType (no schema entry) -> error
  • operatorId not matching /^op\d+$/ -> error
  • operatorId already present -> error ("... already exists. Use modifyOperator ...")
  • properties failing validation -> error carrying the validation messages
  • inputOperatorIds referencing a missing source operator -> error ("Source operator ... not found")
  • target port index NaN / negative / >= inputPorts.length -> error
  • valid args -> adds operator + creates links; returns success

createModifyOperatorTool

  • operator not found -> createErrorResult("Operator {operatorId} not found ...")
  • merged properties failing validation -> error via formatValidationErrors(validation)
  • valid args -> updates the operator's properties; returns success

Task Type

  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions