Skip to content

Add diagnostic validation guard in TaskWrite tool before task completion #2023

@RNViththagan

Description

@RNViththagan

Current Limitation

Currently, the TaskWrite tool allows tasks to be marked as completed without enforcing diagnostic checks for compilation errors. While the system prompt instructs the agent to use the diagnostics tool before marking tasks as completed, this is only a recommendation and not enforced programmatically.

Current behavior:

  • System prompt instructs: "Before marking the task as completed, use the diagnostics tool to check for compilation errors and fix them"
  • Agent may or may not follow this instruction
  • Tasks can be marked as completed even with compilation errors present
  • No validation guard exists in the task completion flow

Location:

  • File: workspaces/ballerina/ballerina-extension/src/features/ai/service/libs/task_write_tool.ts
  • Function: handleTaskCompletion (line 304)

Suggested Improvement

Add a validation guard in the handleTaskCompletion function that:

  1. Automatically runs diagnostic checks before allowing task completion
  2. Blocks task completion if compilation errors are detected
  3. Returns feedback to the agent indicating errors must be fixed before proceeding
  4. Optionally creates a subtask to fix errors if the agent attempts to complete with errors

Implementation approach:

  • Insert validation after line 313 (after detecting newly completed tasks)
  • Before integration (line 315), call the diagnostics tool
  • If errors found, return error result to agent with error details
  • Only proceed with integration if no compilation errors exist

Benefits:

  • Prevents incomplete implementations from being marked as done
  • Enforces code quality at the task level
  • Makes diagnostic checking mandatory rather than optional
  • Provides clear feedback loop for error resolution

Version

No Version

Metadata

Metadata

Assignees

Labels

Area/AIIssues related to general AI features, except AI ArtifactsType/Improvement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions