Files
aiagent/backend/app/models/agent_schedule.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

34 lines
2.3 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.
"""Agent 定时任务表:按 cron 表达式周期执行 Agent"""
import uuid
from datetime import datetime
from sqlalchemy import Column, String, Text, Integer, DateTime, ForeignKey, Boolean, JSON, Index
from sqlalchemy.dialects.mysql import CHAR
from app.core.database import Base
class AgentSchedule(Base):
"""Agent 定时任务 — 按 cron 表达式周期执行指定 Agent"""
__tablename__ = "agent_schedules"
id = Column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()))
agent_id = Column(CHAR(36), ForeignKey("agents.id"), nullable=True, index=True, comment="关联 Agent IDschedule_type=agent 时必填)")
schedule_type = Column(String(20), default="agent", comment="调度类型: agent / goal")
goal_id = Column(CHAR(36), ForeignKey("goals.id"), nullable=True, index=True, comment="关联 Goal IDschedule_type=goal 时必填)")
goal_config = Column(JSON, nullable=True, comment="Goal 调度配置: {title, description, priority}")
name = Column(String(100), nullable=False, comment="任务名称")
cron_expression = Column(String(100), nullable=False, comment="cron 表达式,如 0 9 * * *")
input_message = Column(Text, nullable=False, comment="定时执行时发送的消息内容")
timezone = Column(String(64), default="Asia/Shanghai", comment="时区")
webhook_url = Column(String(512), nullable=True, comment="飞书机器人 Webhook URL可选执行完成后推送通知")
enabled = Column(Boolean, default=True, comment="是否启用")
last_run_at = Column(DateTime, nullable=True, comment="上次执行时间")
last_run_status = Column(String(32), nullable=True, comment="上次执行状态: success/failed")
next_run_at = Column(DateTime, nullable=False, comment="下次执行时间")
user_id = Column(CHAR(36), ForeignKey("users.id"), nullable=False, index=True, comment="创建者 ID")
workspace_id = Column(CHAR(36), ForeignKey("workspaces.id"), nullable=True, comment="所属工作区ID")
created_at = Column(DateTime, default=datetime.utcnow, comment="创建时间")
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, comment="更新时间")
def __repr__(self):
return f"<AgentSchedule(id={self.id}, name={self.name}, cron={self.cron_expression})>"