feat: Agent 运行时、对话 API、作业助手与引擎修复及前端执行超时

- agent_runtime 模块与 agent_chat API,前端 AgentChat 视图与路由对接
- workflow_engine: code 节点命名空间与 json 引用修复
- llm_service: 工具调用 extra_body(如 DeepSeek)
- create_homework_manager_agent / _3 脚本与测试脚本扩展
- frontend: WORKFLOW_EXECUTION_HTTP_TIMEOUT_MS、AgentChatPreview/MainLayout 等
- 文档:架构说明与自主 Agent 改造完成情况

Made-with: Cursor
This commit is contained in:
renjianbo
2026-05-01 11:31:48 +08:00
parent 4366312946
commit 09467568ec
23 changed files with 2798 additions and 77 deletions

View File

@@ -244,7 +244,7 @@ import {
Promotion,
Document
} from '@element-plus/icons-vue'
import api from '@/api'
import api, { WORKFLOW_EXECUTION_HTTP_TIMEOUT_MS } from '@/api'
import { useUserStore } from '@/stores/user'
interface Message {
@@ -404,6 +404,14 @@ function getPreviewContextUserId(agentId: string): string {
return getPreviewSessionUserId(agentId)
}
/** 本轮发送前已有对话(不含即将追加的当前用户句),供后端注入 LLM 上下文 */
function conversationHistoryPayloadBeforeNewUserTurn(): Array<{ role: string; content: string }> {
return messages.value.map((m) => ({
role: m.role === 'user' ? 'user' : 'assistant',
content: typeof m.content === 'string' ? m.content : String(m.content ?? '')
}))
}
/** 未登录时的浏览器会话 id见 agent记忆实现方案.md */
function getPreviewSessionUserId(agentId: string): string {
const key = `agent_preview_uid_${agentId}`
@@ -846,6 +854,8 @@ const handleSendMessage = async () => {
userBubble = head
}
const conversation_history = conversationHistoryPayloadBeforeNewUserTurn()
// 添加用户消息
const userAttachments: MessageAttachment[] = attachSnap.map((a) => ({
relative_path: a.relative_path,
@@ -870,15 +880,21 @@ const handleSendMessage = async () => {
// 发送到Agent
loading.value = true
try {
const response = await api.post('/api/v1/executions', {
agent_id: props.agentId,
input_data: {
USER_INPUT: mergedForModel,
query: mergedForModel,
user_id: getPreviewContextUserId(props.agentId),
attachments: attachSnap
}
})
const response = await api.post(
'/api/v1/executions',
{
agent_id: props.agentId,
input_data: {
USER_INPUT: mergedForModel,
query: mergedForModel,
user_id: getPreviewContextUserId(props.agentId),
attachments: attachSnap,
conversation_history,
memory: { conversation_history }
}
},
{ timeout: WORKFLOW_EXECUTION_HTTP_TIMEOUT_MS }
)
const execution = response.data
blobsPendingRevokeAfterRun.value = attachSnap.length ? attachSnap : null
@@ -904,14 +920,18 @@ const handleSendMessage = async () => {
}
// 获取详细执行状态(包含节点执行信息)
const statusResponse = await api.get(`/api/v1/executions/${execution.id}/status`)
const statusResponse = await api.get(`/api/v1/executions/${execution.id}/status`, {
timeout: WORKFLOW_EXECUTION_HTTP_TIMEOUT_MS
})
const status = statusResponse.data
// 将执行状态传递给父组件,用于显示工作流动画
emit('execution-status', status)
// 获取执行详情(用于提取输出结果)
const execResponse = await api.get(`/api/v1/executions/${execution.id}`)
const execResponse = await api.get(`/api/v1/executions/${execution.id}`, {
timeout: WORKFLOW_EXECUTION_HTTP_TIMEOUT_MS
})
const exec = execResponse.data
if (exec.status === 'completed') {

View File

@@ -31,6 +31,10 @@
<el-icon><User /></el-icon>
<span>Agent管理</span>
</el-menu-item>
<el-menu-item index="agent-chat" @click="router.push('/agent-chat')">
<el-icon><ChatLineSquare /></el-icon>
<span>Agent对话</span>
</el-menu-item>
<el-menu-item index="executions">
<el-icon><List /></el-icon>
<span>执行历史</span>