Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

improvement: separate Agent Definition and Prompt in Sub-Agent node#687

Merged
breaking-brake merged 4 commits intomainbreaking-brake/cc-wf-studio:mainfrom
improvement/separate-agent-definition-and-promptbreaking-brake/cc-wf-studio:improvement/separate-agent-definition-and-promptCopy head branch name to clipboard
Mar 26, 2026
Merged

improvement: separate Agent Definition and Prompt in Sub-Agent node#687
breaking-brake merged 4 commits intomainbreaking-brake/cc-wf-studio:mainfrom
improvement/separate-agent-definition-and-promptbreaking-brake/cc-wf-studio:improvement/separate-agent-definition-and-promptCopy head branch name to clipboard

Conversation

@breaking-brake
Copy link
Copy Markdown
Owner

@breaking-brake breaking-brake commented Mar 26, 2026

Summary

Separate the Sub-Agent node's single "Prompt" field into two distinct fields: Agent Definition (what the agent IS) and Prompt (what to tell the agent to do). Also improve AI generation guidance to prioritize built-in agents and slim down the schema.

What Changed

Before

  • Single "Prompt" field served dual purpose: agent definition and task instructions
  • AI generation guidance allowed creating new custom agents freely
  • SubAgent schema section was ~6.4KB with verbose descriptions
  • Selecting a built-in/existing agent added it to canvas immediately without prompt input

After

  • Agent Definition: describes agent capabilities/role → exported as .md file body
  • Prompt: task instructions → exported in execution instructions
  • AI generation defaults to built-in agents (explore/plan/general-purpose), custom agents only when user explicitly specifies
  • SubAgent schema section slimmed to ~3.5KB (44% reduction)
  • All Sub-Agent creation flows route through edit form for prompt input
  • Canvas node shows agent name + prompt preview instead of description + agent definition

Changes

  • src/shared/types/workflow-definition.ts - Add agentDefinition field to SubAgentData
  • src/shared/types/messages.ts - Add agentDefinition to CreateSubAgentPayload
  • src/shared/constants/built-in-sub-agents.ts - Add defaultAgentDefinitionKey to presets
  • resources/workflow-schema.json - Add agentDefinition field, slim down guidance, prioritize built-in agents
  • resources/ai-editing-skill-template.md - Remove list_available_agents from default flow
  • src/webview/src/components/dialogs/SubAgentFormDialog.tsx - Add Agent Definition + Prompt dual fields
  • src/webview/src/components/dialogs/SubAgentCreationDialog.tsx - Route all selections through form dialog, parse YAML frontmatter
  • src/webview/src/components/nodes/SubAgentNode.tsx - Show agent name + prompt preview, simplify built-in badge
  • src/webview/src/components/PropertyOverlay.tsx - Display both Agent Definition and Prompt
  • src/webview/src/components/NodePalette.tsx - Update handlers for new data flow
  • src/webview/src/utils/agent-frontmatter.ts - Extract shared frontmatter parser
  • src/extension/services/export-service.ts - Use agentDefinition for .md file body
  • src/webview/src/i18n/translation-keys.ts + 5 language files - Add new translation keys

Testing

  • Manual E2E testing completed
  • Build passes (npm run format && npm run lint && npm run check && npm run build)

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added Agent Definition field to sub-agents, now separate from task prompts for clearer agent configuration.
    • Built-in sub-agents now include pre-configured agent definitions.
    • Enhanced sub-agent creation/editing UI to support the new Agent Definition field with validation.
    • Added multi-language support for the new Agent Definition field.
  • Documentation

    • Updated workflow schema and AI editing templates to reflect the new Agent Definition field structure.

breaking-brake and others added 3 commits March 26, 2026 20:53
… node

- Add agentDefinition field to SubAgentData for agent role/capabilities (exported as .md file body)
- Add prompt field for task instructions (exported in execution instructions)
- Route all Sub-Agent creation flows through SubAgentFormDialog for prompt input
- Show agent name + prompt preview on canvas node instead of description + agent definition
- Parse YAML frontmatter when selecting existing commands (extract model/tools/memory)
- Add i18n support for new fields across all 5 languages

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove new agent auto-creation path from aiGenerationGuidance steps
- Add useCases and whenToUse for each built-in agent type (explore/plan/general-purpose)
- Remove list_available_agents from default AI editing flow
- Custom agents only used when user explicitly specifies one

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove verbose field descriptions (type/enum sufficient)
- Simplify builtInAgents to flat useCases arrays
- Remove frontmatterFormat, workflow key, whenToUse
- Remove custom agent example (built-in only)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

This PR introduces a new required agentDefinition field to sub-agents, separating agent system prompts from task-specific prompts. Changes span schema definitions, type declarations, UI forms with validation, export logic, and internationalization support across five languages.

Changes

Cohort / File(s) Summary
Schema Definitions
resources/workflow-schema.json, resources/workflow-schema.toon
Added required agentDefinition field (string, maxLength 10000) to subAgent node schema; updated guidance to favor built-in agents with explicit agentDefinition usage; removed examples showing custom agents via commandFilePath/commandScope.
Workflow AI Template
resources/ai-editing-skill-template.md
Adjusted conversational flow to request user input before discovering custom sub-agents; changed defaults to built-in sub-agents; conditionally call list_available_agents only when explicitly requested.
Type Definitions
src/shared/types/workflow-definition.ts, src/shared/types/messages.ts
Extended SubAgentData and CreateSubAgentPayload interfaces with required agentDefinition: string field; added validation rules with min/max length constraints (1–10000).
Built-in Sub-Agent Configuration
src/shared/constants/built-in-sub-agents.ts
Updated BuiltInSubAgentPreset interface to include defaultAgentDefinitionKey; extended i18n union with three new default-agent-definition keys for generalPurpose, explore, and plan presets; populated all preset entries with the new field.
Service Layer
src/extension/commands/command-operations.ts, src/extension/services/export-service.ts, src/extension/services/mcp-server-tools.ts
Modified handleCreateSubAgent to pass agentDefinition to file generation; updated generateSubAgentFile to append agentDefinition instead of prompt to markdown body; extended planSubAgentFiles to recognize and propagate the new field.
Sub-Agent Creation Dialog
src/webview/src/components/dialogs/SubAgentCreationDialog.tsx
Enhanced SubAgentCreationDialogProps callback signatures to include SubAgentFormData; added form pre-fill logic for built-in presets and existing commands via frontmatter parsing; routes form submission to onSelectBuiltInPreset(type, data) or onSelectCommand(command, data).
Sub-Agent Form Dialog
src/webview/src/components/dialogs/SubAgentFormDialog.tsx
Added agentDefinition: string to SubAgentFormData state; implemented validation requiring non-empty agentDefinition; introduced dedicated editing control and read-only blocks for built-in vs. custom agents; adjusted prompt textarea height from 8 to 6 rows.
Node Components
src/webview/src/components/NodePalette.tsx, src/webview/src/components/PropertyOverlay.tsx, src/webview/src/components/nodes/SubAgentNode.tsx
Removed local parseAgentFrontmatter from NodePalette and imported from utils; updated node creation flows to propagate formData.agentDefinition; added read-only "Agent Definition" display in PropertyOverlay; modified SubAgentNode to render built-in preset names instead of descriptions.
Utilities
src/webview/src/utils/agent-frontmatter.ts
Added exported parseAgentFrontmatter(content) function to extract YAML frontmatter and markdown body from command content.
Translation Keys
src/webview/src/i18n/translation-keys.ts
Extended WebviewTranslationKeys with new form labels, placeholders, and validation error keys for agentDefinition; added preset default-agent-definition keys for all three built-in types.
Internationalization
src/webview/src/i18n/translations/*.ts
Added translations for subAgent.form.agentDefinitionLabel/Placeholder/error.agentDefinitionRequired and preset default agent definitions across English, Japanese, Korean, Simplified Chinese, and Traditional Chinese; updated prompt placeholder wording and built-in description formatting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • #676: Modifies SubAgentCreationDialog component and dialog translation keys, sharing the same UI surface and code paths.
  • #686: Updates subAgent schema, built-in-presets constants, and export/generation code paths that directly integrate with the agentDefinition field additions.
  • #646: Modifies sub-agent creation/workflow logic and frontmatter parsing in overlapping code paths (generateSubAgentFile, handleCreateSubAgent, planSubAgentFiles).

Suggested labels

released

Poem

🐰 An agent takes form, with prompt split in two,
One definition to guide, one task to pursue.
Through dialogs and schemas, the field spreads wide,
From schema to schema, it multiplies with pride.
Now English, Japanese, Korean voices ring true—
A new agentDefinition, our gift unto you!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: separating Agent Definition and Prompt into two distinct fields in Sub-Agent nodes, which is the core objective of this PR.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improvement/separate-agent-definition-and-prompt

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
resources/workflow-schema.json (1)

967-971: ⚠️ Potential issue | 🟡 Minor

Example subAgent nodes are missing the new required agentDefinition field.

The schema declares agentDefinition as required (line 52), but the example workflows contain subAgent nodes without this field. This inconsistency will cause confusion for AI generation and validation.

Affected examples:

  • Line 967-971: "analyzer" agent in "Simple Data Analysis"
  • Line 1017-1019: "scanner" in "Code Review with Priority"
  • Line 1039-1044, 1049-1055: "critical-fixer" and "all-fixer"
  • Line 1109-1114, 1133-1138, 1143-1148: agents in "Document Processing Pipeline"
  • Line 1167-1171, 1177-1181, 1187-1190: format agents
🔧 Example fix for the "analyzer" agent
           "data": {
             "description": "Analyze data",
+            "agentDefinition": "General-purpose data analysis agent with full tool access.",
             "prompt": "Analyze data and generate insights.",
             "model": "sonnet",
             "outputPorts": 1
           }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@resources/workflow-schema.json` around lines 967 - 971, The example subAgent
nodes (e.g., the "analyzer" node in "Simple Data Analysis", "scanner" in "Code
Review with Priority", "critical-fixer" and "all-fixer", and the various
Document Processing and format agents) are missing the required agentDefinition
field; update each subAgent entry to include an agentDefinition object that
conforms to the schema (e.g., include fields such as name, description,
type/model and any required config keys) so examples validate against the
declared schema; locate the subAgent objects by their "id" or "data.name" values
("analyzer", "scanner", "critical-fixer", "all-fixer", etc.) and add the
appropriate agentDefinition payload to each example node.
🧹 Nitpick comments (1)
resources/ai-editing-skill-template.md (1)

9-11: Make Step 4 explicitly include required sub-agent fields.

To reduce validation/retry churn, explicitly require subAgent.data.agentDefinition and subAgent.data.prompt in generated JSON.

Suggested wording tweak
-4. Generate workflow JSON: use built-in sub-agents (builtInType: explore/plan/general-purpose) by default. Only call `list_available_agents` when the user explicitly asks to use an existing custom sub-agent.
+4. Generate workflow JSON: use built-in sub-agents (builtInType: explore/plan/general-purpose) by default. For every `subAgent` node, include required `data.agentDefinition` and `data.prompt`. Only call `list_available_agents` when the user explicitly asks to use an existing custom sub-agent.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@resources/ai-editing-skill-template.md` around lines 9 - 11, Update Step 4
text so the generated workflow JSON explicitly requires the sub-agent fields
subAgent.data.agentDefinition and subAgent.data.prompt (in addition to using
builtInType: explore/plan/general-purpose by default), and only invoke
list_available_agents when the user explicitly requests an existing custom
sub-agent; wording should state these fields are mandatory and should be
included in the generated JSON to avoid validation/retry churn, and reference
the builtInType default and list_available_agents behavior for clarity.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/extension/services/export-service.ts`:
- Around line 275-278: The export currently sets agentDefinition =
data.agentDefinition || '' which can produce an empty agent body; change the
return logic in export-service.ts to fall back to the legacy prompt when
agentDefinition is missing by using data.prompt (or data.agent?.prompt) as a
fallback, e.g., build the body as (data.agentDefinition ?? data.prompt ?? '')
and return frontmatter.join('\n') + that body so legacy sub-agents that only
have prompt export a valid agent file; update references to agentDefinition
accordingly.

In `@src/shared/types/workflow-definition.ts`:
- Around line 115-118: The workflow type now requires agentDefinition but legacy
workflows may only have prompt, so add a fallback in the migration and/or
validation: in migrate-workflow.ts ensure any SubAgent/SubAgentData entries set
agentDefinition = agentDefinition ?? prompt (or copy prompt into
agentDefinition) for legacy nodes, and in validate-workflow.ts (the
extension-side validator that checks SubAgent builtInType) add a presence/length
check for SubAgentData.agentDefinition (same 1-10000 char bounds) so missing
agentDefinition either gets backfilled or validation fails fast; update
validateWorkflowFile() to include SubAgentData validation or call the new
validator so old workflows don’t silently pass.

In `@src/webview/src/components/dialogs/SubAgentCreationDialog.tsx`:
- Around line 125-136: The hardcoded prompt string in the SubAgentCreationDialog
should be replaced with a translatable key: update the call that sets
formInitialData (within the block using parseAgentFrontmatter and
setFormInitialData) to use the translation function (e.g. t('...')) instead of
the literal 'Execute the following task:', add the new i18n key/value to each
locale file, and ensure selectedCommand.promptContent fallback behavior remains
unchanged; references to parseAgentFrontmatter, setFormInitialData,
setIsFormDialogOpen and selectedCommand.promptContent should help you locate and
update the correct spot.

In `@src/webview/src/utils/agent-frontmatter.ts`:
- Around line 9-20: The frontmatter regex and line-splitting assume LF-only
newlines, causing Windows CRLF files to fail; update the frontmatter match to
handle CRLF by using a CR-optional pattern (e.g. change the regex used in match
to /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/) and split the yamlBlock using
/\r?\n/ (or normalize CRs via .replace(/\r\n/g, '\n') beforehand), and ensure
body trimming removes any leftover '\r' so variables like match, yamlBlock, body
and the frontmatter parsing loop correctly handle CRLF files.

---

Outside diff comments:
In `@resources/workflow-schema.json`:
- Around line 967-971: The example subAgent nodes (e.g., the "analyzer" node in
"Simple Data Analysis", "scanner" in "Code Review with Priority",
"critical-fixer" and "all-fixer", and the various Document Processing and format
agents) are missing the required agentDefinition field; update each subAgent
entry to include an agentDefinition object that conforms to the schema (e.g.,
include fields such as name, description, type/model and any required config
keys) so examples validate against the declared schema; locate the subAgent
objects by their "id" or "data.name" values ("analyzer", "scanner",
"critical-fixer", "all-fixer", etc.) and add the appropriate agentDefinition
payload to each example node.

---

Nitpick comments:
In `@resources/ai-editing-skill-template.md`:
- Around line 9-11: Update Step 4 text so the generated workflow JSON explicitly
requires the sub-agent fields subAgent.data.agentDefinition and
subAgent.data.prompt (in addition to using builtInType:
explore/plan/general-purpose by default), and only invoke list_available_agents
when the user explicitly requests an existing custom sub-agent; wording should
state these fields are mandatory and should be included in the generated JSON to
avoid validation/retry churn, and reference the builtInType default and
list_available_agents behavior for clarity.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6dce3302-fab1-4814-8fad-2068f145a5e6

📥 Commits

Reviewing files that changed from the base of the PR and between 8188f84 and 2376e15.

📒 Files selected for processing (21)
  • resources/ai-editing-skill-template.md
  • resources/workflow-schema.json
  • resources/workflow-schema.toon
  • src/extension/commands/command-operations.ts
  • src/extension/services/export-service.ts
  • src/extension/services/mcp-server-tools.ts
  • src/shared/constants/built-in-sub-agents.ts
  • src/shared/types/messages.ts
  • src/shared/types/workflow-definition.ts
  • src/webview/src/components/NodePalette.tsx
  • src/webview/src/components/PropertyOverlay.tsx
  • src/webview/src/components/dialogs/SubAgentCreationDialog.tsx
  • src/webview/src/components/dialogs/SubAgentFormDialog.tsx
  • src/webview/src/components/nodes/SubAgentNode.tsx
  • src/webview/src/i18n/translation-keys.ts
  • src/webview/src/i18n/translations/en.ts
  • src/webview/src/i18n/translations/ja.ts
  • src/webview/src/i18n/translations/ko.ts
  • src/webview/src/i18n/translations/zh-CN.ts
  • src/webview/src/i18n/translations/zh-TW.ts
  • src/webview/src/utils/agent-frontmatter.ts

Comment thread src/extension/services/export-service.ts Outdated
Comment on lines +115 to 118
/** Agent definition: describes what this agent IS, its capabilities and role. Exported as .md file body. */
agentDefinition: string;
/** Task prompt: describes what to TELL this agent to do. Exported in execution instructions. */
prompt: string;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Find all Sub-Agent load/parse/migrate touch points
rg -n --type=ts --type=tsx -C2 '\b(agentDefinition|subAgent|migrate|schemaVersion|importWorkflow|openWorkflow)\b' src

# 2) Specifically verify fallback logic for legacy sub-agent payloads
rg -n --type=ts --type=tsx -C3 'agentDefinition\s*\?\?=|if\s*\(!.*agentDefinition|agentDefinition\s*:\s*.*prompt|prompt\s*:\s*.*agentDefinition' src

# 3) Inspect JSON/schema validators for required fields handling
rg -n --type=json --type=ts --type=tsx -C2 'agentDefinition|required' resources src

Repository: breaking-brake/cc-wf-studio

Length of output: 98


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Find all Sub-Agent load/parse/migrate touch points in TypeScript files
rg -n --type=ts -C2 '\b(agentDefinition|subAgent|migrate|schemaVersion|importWorkflow|openWorkflow|import.*Workflow|load.*Workflow)\b' src

# 2) Specifically verify fallback logic for legacy sub-agent payloads
rg -n --type=ts -C3 'agentDefinition\s*\?\?=|if\s*\(!.*agentDefinition|agentDefinition\s*:\s*.*prompt|prompt.*agentDefinition' src

# 3) Inspect schema validators for required fields handling
rg -n --type=ts -C2 'agentDefinition|required' resources src 2>/dev/null || true

Repository: breaking-brake/cc-wf-studio

Length of output: 50384


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Find the workflow-definition.ts file and read lines 624-625 and surrounding context
echo "=== Lines 620-630 from workflow-definition.ts ==="
wc -l src/shared/types/workflow-definition.ts
sed -n '620,630p' src/shared/types/workflow-definition.ts

# 2) Search for SubAgentData type definition
echo -e "\n=== SubAgentData type definition ==="
rg -n 'interface SubAgentData|type SubAgentData' src --type=ts -A 15

# 3) Search for workflow load/import/parse functions
echo -e "\n=== Load/import/parse functions ==="
rg -n '\b(loadWorkflow|importWorkflow|parseWorkflow|deserializeWorkflow|migrateWorkflow)' src --type=ts -B 2 -A 8 | head -100

# 4) Search for validation/schema enforcement
echo -e "\n=== Validation/schema functions ==="
rg -n '\b(validateWorkflow|validateSubAgent|validateSchema)' src --type=ts -B 2 -A 5

Repository: breaking-brake/cc-wf-studio

Length of output: 36741


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find and read the migrate-workflow.ts file
echo "=== Finding migrate-workflow.ts ==="
fd -n migrate-workflow src

# Read the migrate-workflow function
echo -e "\n=== Contents of migrate-workflow.ts ==="
if [ -f "src/extension/utils/migrate-workflow.ts" ]; then
  head -200 src/extension/utils/migrate-workflow.ts
fi

# Check if migration is applied before validation in open-editor
echo -e "\n=== Migration flow in open-editor.ts ==="
sed -n '930,960p' src/extension/commands/open-editor.ts

Repository: breaking-brake/cc-wf-studio

Length of output: 354


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find migrate-workflow.ts file
echo "=== Finding migrate-workflow.ts ==="
find src -name "*migrate*workflow*" -type f

# Read the migrate-workflow function
echo -e "\n=== Contents of migrate-workflow.ts ==="
find src -name "*migrate*workflow*" -type f -exec cat {} \;

Repository: breaking-brake/cc-wf-studio

Length of output: 859


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check the exact order in open-editor.ts where workflows are loaded
echo "=== Load path in open-editor.ts (lines 925-950) ==="
sed -n '925,950p' src/extension/commands/open-editor.ts

# Check workflow-preview-editor-provider.ts for the load order
echo -e "\n=== Load path in workflow-preview-editor-provider.ts (lines 170-195) ==="
sed -n '170,195p' src/extension/editors/workflow-preview-editor-provider.ts

# Check slack-import-workflow.ts load order
echo -e "\n=== Load path in slack-import-workflow.ts (lines 50-75) ==="
sed -n '50,75p' src/extension/commands/slack-import-workflow.ts

Repository: breaking-brake/cc-wf-studio

Length of output: 2918


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the validateWorkflowFile function to see what it validates
echo "=== validateWorkflowFile implementation ==="
sed -n '35,150p' src/extension/utils/workflow-validator.ts

# Also check validate-workflow.ts for node validation
echo -e "\n=== SubAgent node validation ==="
rg -n 'SubAgentData|agentDefinition.*required|subAgent.*validate' src/extension/utils/validate-workflow.ts -B 2 -A 5 | head -60

Repository: breaking-brake/cc-wf-studio

Length of output: 3088


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for SubAgent node validation specifically
echo "=== SubAgent node validation in validate-workflow.ts ==="
rg -n 'NodeType.SubAgent|case.*SubAgent' src/extension/utils/validate-workflow.ts -B 3 -A 15

# Also check what validateNodeData does
echo -e "\n=== validateNodeData function ==="
rg -n 'validateNodeData|validateNode' src/extension/utils/validate-workflow.ts -A 30 | head -80

Repository: breaking-brake/cc-wf-studio

Length of output: 5822


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check if SubAgentData fields are validated in PropertyOverlay or other UI components
echo "=== PropertyOverlay SubAgent validation ==="
rg -n 'agentDefinition.*valid|description.*valid|prompt.*valid' src/webview/src/components/PropertyOverlay.tsx -B 2 -A 5

# Check if validation uses VALIDATION_RULES for SubAgent
echo -e "\n=== PropertyOverlay VALIDATION_RULES usage for SubAgent ==="
rg -n 'VALIDATION_RULES.SUB_AGENT|SubAgentData' src/webview/src/components/PropertyOverlay.tsx -B 2 -A 8 | head -100

# Check the form validation for subagent
echo -e "\n=== SubAgent form validation ==="
fd -t f -n '*ubAgent*' src/webview/src/components/dialogs | xargs rg -l 'agentDefinition|validateSubAgent' | head -3

Repository: breaking-brake/cc-wf-studio

Length of output: 114


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find SubAgent form/dialog files
echo "=== SubAgent form/dialog files ==="
find src/webview/src/components -name "*SubAgent*" -type f

# Check the SubAgent dialog file
echo -e "\n=== SubAgentDialog validation logic ==="
rg -n 'agentDefinition|isValid|validate' src/webview/src/components/dialogs/SubAgentDialog.tsx -B 2 -A 5 | head -120

# Check for form field validation
echo -e "\n=== Form field validation in SubAgentDialog ==="
sed -n '1,100p' src/webview/src/components/dialogs/SubAgentDialog.tsx 2>/dev/null | tail -50 || echo "File read failed, checking with rg"
rg -n 'required.*agentDefinition|error.*agentDefinition' src --type=ts -B 2 -A 2

Repository: breaking-brake/cc-wf-studio

Length of output: 539


🏁 Script executed:

#!/bin/bash
set -euo pipefixpipe

# Check SubAgentFormDialog for validation
echo "=== SubAgentFormDialog validation logic ==="
rg -n 'agentDefinition|isValid|required|error' src/webview/src/components/dialogs/SubAgentFormDialog.tsx -B 2 -A 3 | head -150

Repository: breaking-brake/cc-wf-studio

Length of output: 127


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check SubAgentFormDialog for validation
echo "=== SubAgentFormDialog validation logic ==="
rg -n 'agentDefinition|isValid|required|error' src/webview/src/components/dialogs/SubAgentFormDialog.tsx -B 2 -A 3 | head -150

Repository: breaking-brake/cc-wf-studio

Length of output: 6055


Confirmed: No fallback logic for legacy workflows missing agentDefinition.

At lines 115-118, agentDefinition is a required, non-optional string field. Line 620-625 enforces validation bounds (1-10,000 chars). However, the migration function (src/extension/utils/migrate-workflow.ts) is empty—it contains only a comment stating "All legacy migrations have been removed after sufficient deprecation periods" with no backfill logic.

Additionally, validateWorkflowFile() only checks top-level workflow fields (id, name, version, nodes, connections) and does not validate SubAgentData field presence. The extension-side node validation in validate-workflow.ts (line 311+) only validates SubAgent's builtInType enum, not the required agentDefinition field. This means old workflows saved with only a prompt field will pass validation and load silently despite the type now requiring agentDefinition.

Action required: Add explicit fallback logic during migration (e.g., agentDefinition ??= prompt) or enforce field validation in validate-workflow.ts for SubAgent nodes to fail fast rather than allow silent mismatches.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/shared/types/workflow-definition.ts` around lines 115 - 118, The workflow
type now requires agentDefinition but legacy workflows may only have prompt, so
add a fallback in the migration and/or validation: in migrate-workflow.ts ensure
any SubAgent/SubAgentData entries set agentDefinition = agentDefinition ??
prompt (or copy prompt into agentDefinition) for legacy nodes, and in
validate-workflow.ts (the extension-side validator that checks SubAgent
builtInType) add a presence/length check for SubAgentData.agentDefinition (same
1-10000 char bounds) so missing agentDefinition either gets backfilled or
validation fails fast; update validateWorkflowFile() to include SubAgentData
validation or call the new validator so old workflows don’t silently pass.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Not needed — The export fallback (added in 8543483) handles legacy workflows that only have prompt. Full migration infrastructure is overkill for this change.

Comment on lines +125 to 136
const { frontmatter, body } = parseAgentFrontmatter(selectedCommand.promptContent || '');
setFormInitialData({
description: frontmatter.description || selectedCommand.description || selectedCommand.name,
agentDefinition: body,
prompt: 'Execute the following task:',
agentType: 'claudeCode',
model: (frontmatter.model as 'sonnet' | 'opus' | 'haiku' | 'inherit') || 'sonnet',
tools: frontmatter.tools || '',
memory: (frontmatter.memory as 'user' | 'project' | 'local' | '') || '',
});
setIsFormDialogOpen(true);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Hardcoded prompt string should be internationalized.

Line 129 uses a hardcoded English string 'Execute the following task:' instead of using the translation function. This is inconsistent with the rest of the i18n-aware codebase and will not display correctly for non-English users.

🌐 Proposed fix
       setFormInitialData({
         description: frontmatter.description || selectedCommand.description || selectedCommand.name,
         agentDefinition: body,
-        prompt: 'Execute the following task:',
+        prompt: t('subAgent.form.defaultPromptForCommand'),
         agentType: 'claudeCode',

Add the corresponding i18n key to each translation file.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { frontmatter, body } = parseAgentFrontmatter(selectedCommand.promptContent || '');
setFormInitialData({
description: frontmatter.description || selectedCommand.description || selectedCommand.name,
agentDefinition: body,
prompt: 'Execute the following task:',
agentType: 'claudeCode',
model: (frontmatter.model as 'sonnet' | 'opus' | 'haiku' | 'inherit') || 'sonnet',
tools: frontmatter.tools || '',
memory: (frontmatter.memory as 'user' | 'project' | 'local' | '') || '',
});
setIsFormDialogOpen(true);
}
const { frontmatter, body } = parseAgentFrontmatter(selectedCommand.promptContent || '');
setFormInitialData({
description: frontmatter.description || selectedCommand.description || selectedCommand.name,
agentDefinition: body,
prompt: t('subAgent.form.defaultPromptForCommand'),
agentType: 'claudeCode',
model: (frontmatter.model as 'sonnet' | 'opus' | 'haiku' | 'inherit') || 'sonnet',
tools: frontmatter.tools || '',
memory: (frontmatter.memory as 'user' | 'project' | 'local' | '') || '',
});
setIsFormDialogOpen(true);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/webview/src/components/dialogs/SubAgentCreationDialog.tsx` around lines
125 - 136, The hardcoded prompt string in the SubAgentCreationDialog should be
replaced with a translatable key: update the call that sets formInitialData
(within the block using parseAgentFrontmatter and setFormInitialData) to use the
translation function (e.g. t('...')) instead of the literal 'Execute the
following task:', add the new i18n key/value to each locale file, and ensure
selectedCommand.promptContent fallback behavior remains unchanged; references to
parseAgentFrontmatter, setFormInitialData, setIsFormDialogOpen and
selectedCommand.promptContent should help you locate and update the correct
spot.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Intentional — This was a deliberate decision to keep it English-only. The default prompt is a template for AI agent instructions, not user-facing UI text.

Comment thread src/webview/src/utils/agent-frontmatter.ts
- Fallback to data.prompt when agentDefinition is missing (legacy compat)
- Add agentDefinition to all sample subAgent nodes in workflow-schema.json

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@breaking-brake breaking-brake merged commit b336890 into main Mar 26, 2026
3 checks passed
@breaking-brake breaking-brake deleted the improvement/separate-agent-definition-and-prompt branch March 26, 2026 13:04
@breaking-brake breaking-brake mentioned this pull request Mar 26, 2026
braking-brake-semantic-release Bot pushed a commit that referenced this pull request Mar 26, 2026
## [3.31.0](v3.30.4...v3.31.0) (2026-03-26)

### Features

* add built-in sub-agent presets with cross-platform export support ([#686](#686)) ([8188f84](8188f84))

### Improvements

* add confirm dialog before disabling group highlight ([#685](#685)) ([ba74dff](ba74dff))
* separate Agent Definition and Prompt in Sub-Agent node ([#687](#687)) ([b336890](b336890))
@braking-brake-semantic-release
Copy link
Copy Markdown

🎉 This PR is included in version 3.31.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.