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

feat: structured JSON response format for AI refinement#287

Merged
breaking-brake merged 2 commits intomainbreaking-brake/cc-wf-studio:mainfrom
feat/ai-refinement-structured-responsebreaking-brake/cc-wf-studio:feat/ai-refinement-structured-responseCopy head branch name to clipboard
Dec 17, 2025
Merged

feat: structured JSON response format for AI refinement#287
breaking-brake merged 2 commits intomainbreaking-brake/cc-wf-studio:mainfrom
feat/ai-refinement-structured-responsebreaking-brake/cc-wf-studio:feat/ai-refinement-structured-responseCopy head branch name to clipboard

Conversation

@breaking-brake
Copy link
Copy Markdown
Owner

Summary

Implement structured JSON response format for AI workflow refinement to prevent PARSE_ERROR when AI returns non-JSON responses.

Problem

When AI determines no changes are needed, it sometimes returns Japanese explanation text instead of JSON, causing PARSE_ERROR:

"outputPreview": "現在のワークフローを確認しました。ユーザーのリクエストは..."

Current Behavior

  1. User requests refinement in Japanese
  2. AI determines no changes needed
  3. ❌ AI returns explanation text instead of JSON
  4. ❌ Parser fails with PARSE_ERROR

Expected Behavior

  1. User requests refinement in Japanese
  2. AI determines no changes needed
  3. ✅ AI returns structured JSON with status and message
  4. ✅ Message displayed in chat UI

Solution

Force AI to always return structured JSON responses:

{
  "status": "success",
  "message": "変更を適用しました",
  "values": {
    "workflow": { /* workflow JSON */ }
  }
}

Changes

File: src/extension/services/refinement-service.ts

  • Added AIRefinementResponse and AISubAgentFlowResponse type definitions
  • Added parseRefinementResponse() and parseSubAgentFlowResponse() functions
  • Updated prompts to require structured JSON format with status, message, and values fields
  • Added aiMessage field to result interfaces for chat UI display
  • Added raw CLI output to INFO logs for debugging

File: src/extension/commands/workflow-refinement.ts

  • Modified to use AI message in chat UI instead of hardcoded translation key

File: src/extension/services/claude-code-service.ts

  • Fixed timeout detection to also check exitCode === 143 (128 + SIGTERM)
  • nano-spawn may only set exitCode without isTerminated flag

Impact

  • AI responses now consistently use structured JSON format
  • AI's response message displayed in chat UI for better UX
  • Timeout errors correctly reported as TIMEOUT instead of UNKNOWN_ERROR
  • No breaking changes to existing workflows

Testing

  • Manual E2E testing: Japanese refinement requests
  • Manual E2E testing: No-change scenarios return valid JSON
  • Manual E2E testing: AI message displayed in chat UI
  • Manual E2E testing: Timeout errors reported correctly
  • Code quality checks passed (format, lint, check)
  • Build successful

🤖 Generated with Claude Code

breaking-brake and others added 2 commits December 17, 2025 17:05
- Add AIRefinementResponse and AISubAgentFlowResponse types
- Update prompts to require structured JSON with status field
- Add parseRefinementResponse and parseSubAgentFlowResponse functions
- Include aiMessage in refinement results for chat UI display
- Fix NodeType enum usage in createMinimalSubAgentFlow
- Add raw CLI output to INFO logs for debugging

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- nano-spawn may only set exitCode=143 (128 + SIGTERM) without isTerminated flag
- Added exitCode check to timeout detection logic
- Fixes TIMEOUT errors being incorrectly reported as UNKNOWN_ERROR

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@breaking-brake breaking-brake merged commit d16f74e into main Dec 17, 2025
3 checks passed
@breaking-brake breaking-brake deleted the feat/ai-refinement-structured-response branch December 17, 2025 08:24
@breaking-brake breaking-brake mentioned this pull request Dec 17, 2025
github-actions Bot added a commit that referenced this pull request Dec 17, 2025
## [3.8.0](v3.7.4...v3.8.0) (2025-12-17)

### Features

* structured JSON response format for AI refinement ([#287](#287)) ([d16f74e](d16f74e))
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.8.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.