Skip to content

feat(AgentsManager): AI Chat tab for natural language task orchestration#498

Draft
Copilot wants to merge 5 commits intomasterfrom
copilot/implement-agents-manager-task
Draft

feat(AgentsManager): AI Chat tab for natural language task orchestration#498
Copilot wants to merge 5 commits intomasterfrom
copilot/implement-agents-manager-task

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

Users need a conversational interface to launch AgentsManager tasks via natural language — if no suitable ChatGroup exists, the AI proposes creating one (with agent selection and naming), waits for confirmation, then auto-creates and runs the task.

Backend — AiChatAppService

Three [ApiBind(Post)] endpoints:

  • SendMessage — Builds a dynamic system prompt injecting all available AgentTemplate and ChatGroup records, calls AI, parses structured JSON response into one of: Message | SuggestRunTask | SuggestCreateGroup | TaskStarted | Error
  • ConfirmCreateAndRunGroup — Calls ChatGroupAppService.SetChatGroup() (existing FunctionRender method, not duplicated), then fires ChatGroupService.RunChatGroupInThread() in a background Task.Run with exception logging
  • RunExistingGroup — Same fire-and-forget pattern for an already-existing group
// AI system prompt is fully data-driven — no hardcoded agent/group logic
var systemPrompt = BuildSystemPrompt(agentTemplateList, chatGroupList);
// AI returns JSON: {"action":"create_group","suggestion":{...}} or {"action":"run_existing","groupId":N,...}
var responseDto = ParseAiResponse(aiResult.OutputString, agentTemplates, request.AiModelId);

New DTOs: AiChat_SendMessageRequest, AiChat_SuggestedGroupDto, AiChat_RunExistingGroupRequest, AiChat_SendMessageResponse (with AiChatResponseType enum).

AiChatAppService registered in Register.cs.

Frontend — new "AI 对话" tab (fourth)

  • Model selector (Chat-type models only), clear button
  • Message list: user/AI bubbles rendered via existing task-html-renderer, loading animation
  • Inline confirm/cancel buttons on SuggestCreateGroup and SuggestRunTask messages — hidden after action
  • Textarea input with Ctrl+Enter shortcut

Key JS methods added to index.js:

  • sendAiChatMessage() — posts message + pruned history, handles all response types
  • confirmCreateAndRunGroup() / confirmRunExistingGroup() — POST to backend, show success via $message, mark suggestion confirmed
  • loadAiChatModelList() — lazy-loads on tab click via handleTabsClick

CSS chat bubble styles appended to index.css.

Original prompt

AI Chat 需要实现效果:让用户用语言对话启动一个AgentsManager的任务。如果没有合适的组做这个任务,则提示用户是否创建一个新的组(并且说明将会参与的Agent以及组的命名等),用户在对话过程中确认后自动创建,并且自动运行任务(类似Prompt优化一样自动触发运行,尽量复用,以及使用EventBus),这个过程需要使用Prompt+functionrender对应的方法来调用实现,不要硬编码。

Created from VS Code.

Copilot AI and others added 4 commits April 4, 2026 10:55
…orchestration

- Add AiChatAppService.cs with AI-powered chat endpoint that:
  - Analyzes user intent using AI with structured Prompt-based responses
  - Finds suitable existing ChatGroups or suggests creating new ones
  - Programmatically invokes ChatGroupAppService.SetChatGroup and ChatGroupService.RunChatGroupInThread (FunctionRender pattern)
  - Runs tasks in background thread (EventBus pattern)
- Add AiChatRequest.cs with request models (AiChat_SendMessageRequest, AiChat_SuggestedGroupDto, AiChat_RunExistingGroupRequest)
- Add AiChatResponse.cs with response models (AiChat_SendMessageResponse, AiChatResponseType)
- Register AiChatAppService in Register.cs
- Add AI Chat tab (fourth) to Index.cshtml with chat UI featuring:
  - Message list with user/AI messages
  - Confirmation buttons for group creation/task execution
  - AI model selector
- Add AI Chat JavaScript methods in index.js:
  - sendAiChatMessage() - sends message and handles AI response
  - confirmCreateAndRunGroup() - confirms group creation and task start
  - confirmRunExistingGroup() - runs existing group
  - cancelSuggestion() / clearAiChat() - utility functions
  - loadAiChatModelList() - loads available AI models
- Add AI Chat CSS styles to index.css

Agent-Logs-Url: https://github.com/NeuCharFramework/NcfPackageSources/sessions/2b0ded12-8dc2-4c02-8ed9-a726706e8edb

Co-authored-by: JeffreySu <2281927+JeffreySu@users.noreply.github.com>
…e, fix chat history filter

Agent-Logs-Url: https://github.com/NeuCharFramework/NcfPackageSources/sessions/2b0ded12-8dc2-4c02-8ed9-a726706e8edb

Co-authored-by: JeffreySu <2281927+JeffreySu@users.noreply.github.com>
Co-authored-by: JeffreySu <2281927+JeffreySu@users.noreply.github.com>
Copilot AI changed the title [WIP] Add language-driven task initiation for AgentsManager feat(AgentsManager): AI Chat tab for natural language task orchestration Apr 4, 2026
Copilot AI requested a review from JeffreySu April 4, 2026 11:06
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.

2 participants