Files
aiagent/backend/app/models/goal.py
renjianbo beff3fac8d fix: delete agent 500 error + dynamic personality + deployment guide
- Fix delete agent 500: clean up FK records (agent_llm_logs, permissions,
  schedules, executions, team_members) and unbind goals/tasks before delete
- Remove hardcoded personality templates in Android, replace with dynamic
  system prompt generation from name + description
- Set promptSectionsEnabled=false to bypass PromptComposer for personality
- Add Tencent Cloud Linux deployment guide (Docker Compose)
- Accumulated backend service updates, frontend UI fixes, Android app changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-29 01:17:21 +08:00

47 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
目标模型 — Main Agent 管理的顶层目标
"""
from sqlalchemy import Column, String, Text, Integer, Float, DateTime, JSON, ForeignKey, Index, func
from sqlalchemy.dialects.mysql import CHAR
from sqlalchemy.orm import relationship
from app.core.database import Base
import uuid
class Goal(Base):
"""目标表 — Main Agent 数字员工的顶层工作目标"""
__tablename__ = "goals"
id = Column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()), comment="目标ID")
title = Column(String(500), nullable=False, comment="目标标题")
description = Column(Text, comment="目标描述(自然语言)")
status = Column(String(20), default="active", comment="状态: active/paused/completed/failed/cancelled")
priority = Column(Integer, default=5, comment="优先级 1-10")
progress = Column(Float, default=0.0, comment="完成进度 0.0 - 1.0")
# Main Agent 分解后的结构化计划
plan = Column(JSON, comment="执行计划: [{phase, tasks:[], assigned_agent_id, deadline}]")
# 自主循环配置
autonomy_config = Column(JSON, comment="自主循环配置: {check_interval_minutes, max_idle_hours, auto_replan, notify_on_progress}")
# 关联
creator_id = Column(CHAR(36), ForeignKey("users.id"), nullable=False, comment="创建者ID")
main_agent_id = Column(CHAR(36), ForeignKey("agents.id"), nullable=True, comment="管理此目标的 Main Agent ID")
parent_goal_id = Column(CHAR(36), ForeignKey("goals.id"), nullable=True, comment="父目标ID支持目标嵌套")
workspace_id = Column(CHAR(36), ForeignKey("workspaces.id"), nullable=True, comment="所属工作区ID")
# 时间
started_at = Column(DateTime, comment="开始时间")
completed_at = Column(DateTime, comment="完成时间")
deadline = Column(DateTime, comment="截止时间")
created_at = Column(DateTime, default=func.now(), comment="创建时间")
updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), comment="更新时间")
# 关系
creator = relationship("User", backref="goals")
main_agent = relationship("Agent", backref="managed_goals")
def __repr__(self):
return f"<Goal(id={self.id}, title={self.title}, status={self.status})>"