Skip to content

Conversation

@Micro66
Copy link
Collaborator

@Micro66 Micro66 commented Dec 2, 2025

Summary

  • Add new Chat Shell type that directly calls LLM APIs (Claude, OpenAI) from Backend without Docker containers
  • Optimize Dify Shell type to support direct API calls from Backend
  • Add async streaming support with SSE for real-time responses
  • Store chat history and Dify conversation IDs in Redis for multi-worker support
  • Add concurrency control with configurable MAX_CONCURRENT_DIRECT_CHATS setting

Key Changes

New Files

  • backend/app/services/direct_chat/ - Direct chat service module
    • base.py - Base class, shared HTTP client with connection pooling
    • session_manager.py - Redis session state management
    • chat_service.py - Chat service for Claude/OpenAI APIs
    • dify_service.py - Dify service adapted from executor for async
  • backend/app/api/endpoints/adapter/direct_chat.py - SSE streaming endpoints

Modified Files

  • backend/app/core/config.py - Add MAX_CONCURRENT_DIRECT_CHATS config
  • backend/app/main.py - HTTP client lifecycle management
  • backend/app/services/adapters/task_kinds.py - Add direct chat check helper
  • backend/init_data/02-public-shells.yaml - Add Chat public shell definition
  • backend/app/api/api.py - Register direct chat routes

Technical Constraints Met

  • Full async/await implementation using httpx.AsyncClient
  • Session state stored in Redis for multi-worker support
  • Shared HTTP client with connection pooling
  • Proper error handling and resource cleanup
  • Concurrency limiting with asyncio.Semaphore

Test Plan

  • Verify Chat Shell type appears in public shells list
  • Test direct chat streaming with Claude API
  • Test direct chat streaming with OpenAI API
  • Test Dify chat streaming (chat, chatflow, workflow modes)
  • Verify conversation history persistence in Redis
  • Test concurrent chat requests within limit
  • Test cancellation functionality
  • Verify proper status updates for task/subtask

qdaxb and others added 13 commits November 30, 2025 00:57
- Add baseImage and baseShellRef fields to ShellSpec schema
- Update public shells init data with default baseImage
- Create Shell unified API endpoints (/shells/unified, CRUD operations)
- Add image validation API to check compatibility with shell types
- Modify task dispatch to pass baseImage to Executor Manager
- Add executor binary extraction on Executor Manager startup
- Support Base Image + Executor mount mode in Docker executor
- Create frontend Shell API client and management UI components
- Add Shells tab to Settings page with i18n support

The feature enables users to create custom shells with their own base
images while using the latest executor binary via Named Volume mount.
- Fix ShellList Tag variant error (use 'default' instead of 'outline')
- Move image validation logic to Executor Manager API
  (/executor-manager/images/validate)
- Backend shells API now proxies validation requests to Executor Manager
- Support various deployment modes (Docker, K8s) where backend may not
  have direct Docker access
- Create ImageValidatorAgent for running validation inside container
- Modify executor_manager to dispatch validation tasks via task processor
- Update backend shells API for async validation response
- Update frontend to handle async validation status
- Add i18n translations for validation status messages

This approach uses the actual executor run flow instead of direct docker
subprocess calls, making it extensible for both Docker and K8s modes.
Validation runs inside the target container and reports results via callback.
…ling

- Add UUID-based validation tracking with Redis storage (5min TTL)
- Add validation status query endpoint GET /api/shells/validation-status/{id}
- Add validation status update endpoint for internal callback forwarding
- Enhance Executor Manager to pass validation_id and forward callbacks to Backend
- Enhance Docker executor to report container start/pull failures
- Add stage progress reporting in ImageValidatorAgent (submitted/pulling/starting/running_checks/completed)
- Implement frontend polling mechanism with 2s interval, 120s timeout
- Disable save button until validation passes (forced validation for new/changed baseImage)
- Add progress bar UI showing real-time validation stages
- Add i18n messages for validation stages in both en/zh-CN
…orting

Add httpx>=0.24.0 to requirements.txt to fix CI test failure.
The httpx library is required by docker executor to report
validation stage progress to the backend API.
Fix ESLint errors for unused variables:
- Rename validationId to _validationId (stored for future use)
- Remove pollingCount state (internal count only needed in closure)
# Conflicts:
#	docs/en/reference/yaml-specification.md
#	docs/zh/reference/yaml-specification.md
#	frontend/src/i18n/locales/en/common.json
#	frontend/src/i18n/locales/zh-CN/common.json
Add new Chat Shell type and optimize Dify Shell to support direct API calls
from Backend without requiring Docker Executor containers. This improves
response speed for lightweight chat scenarios.

Key changes:
- Add new direct_chat service module with async streaming support
- Add Chat public shell type supporting Claude and OpenAI compatible APIs
- Add direct chat API endpoints for SSE streaming
- Add MAX_CONCURRENT_DIRECT_CHATS config for concurrency control
- Add helper function to check if team supports direct chat mode
- Store chat history and Dify conversation IDs in Redis
- Use shared HTTP client with connection pooling
@coderabbitai
Copy link

coderabbitai bot commented Dec 2, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch weagent/feature-direct-chat-shell

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.

Base automatically changed from wegent/feature-custom-shell-base-image to main December 2, 2025 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants