Infrastructure: - Add Redis and Celery workers to all docker-compose files - Fix celery migration race condition in entrypoint.sh - Add healthchecks and resource limits to dev compose - Update .env.template with Redis/Celery variables Backend Models & Schemas: - Rename Sprint.completed_points to velocity (per requirements) - Add AgentInstance.name as required field - Rename Issue external tracker fields for consistency - Add IssueSource and TrackerType enums - Add Project.default_tracker_type field Backend Fixes: - Add Celery retry configuration with exponential backoff - Remove unused sequence counter from EventBus - Add mypy overrides for test dependencies - Fix test file using wrong schema (UserUpdate -> dict) Frontend Fixes: - Fix memory leak in useProjectEvents (proper cleanup) - Fix race condition with stale closure in reconnection - Sync TokenWithUser type with regenerated API client - Fix expires_in null handling in useAuth - Clean up unused imports in prototype pages - Add ESLint relaxed rules for prototype files CI/CD: - Add E2E testing stage with Testcontainers - Add security scanning with Trivy and pip-audit - Add dependency caching for faster builds Tests: - Update all tests to use renamed fields (velocity, name, etc.) - Fix 14 schema test failures - All 1500 tests pass with 91% coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
125 lines
3.5 KiB
Python
125 lines
3.5 KiB
Python
# app/schemas/syndarix/agent_instance.py
|
|
"""
|
|
Pydantic schemas for AgentInstance entity.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
from decimal import Decimal
|
|
from typing import Any
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
from .enums import AgentStatus
|
|
|
|
|
|
class AgentInstanceBase(BaseModel):
|
|
"""Base agent instance schema with common fields."""
|
|
|
|
agent_type_id: UUID
|
|
project_id: UUID
|
|
status: AgentStatus = AgentStatus.IDLE
|
|
current_task: str | None = None
|
|
short_term_memory: dict[str, Any] = Field(default_factory=dict)
|
|
long_term_memory_ref: str | None = Field(None, max_length=500)
|
|
session_id: str | None = Field(None, max_length=255)
|
|
|
|
|
|
class AgentInstanceCreate(BaseModel):
|
|
"""Schema for creating a new agent instance."""
|
|
|
|
agent_type_id: UUID
|
|
project_id: UUID
|
|
name: str = Field(..., min_length=1, max_length=100)
|
|
status: AgentStatus = AgentStatus.IDLE
|
|
current_task: str | None = None
|
|
short_term_memory: dict[str, Any] = Field(default_factory=dict)
|
|
long_term_memory_ref: str | None = Field(None, max_length=500)
|
|
session_id: str | None = Field(None, max_length=255)
|
|
|
|
|
|
class AgentInstanceUpdate(BaseModel):
|
|
"""Schema for updating an agent instance."""
|
|
|
|
status: AgentStatus | None = None
|
|
current_task: str | None = None
|
|
short_term_memory: dict[str, Any] | None = None
|
|
long_term_memory_ref: str | None = None
|
|
session_id: str | None = None
|
|
last_activity_at: datetime | None = None
|
|
tasks_completed: int | None = Field(None, ge=0)
|
|
tokens_used: int | None = Field(None, ge=0)
|
|
cost_incurred: Decimal | None = Field(None, ge=0)
|
|
|
|
|
|
class AgentInstanceTerminate(BaseModel):
|
|
"""Schema for terminating an agent instance."""
|
|
|
|
reason: str | None = None
|
|
|
|
|
|
class AgentInstanceInDB(AgentInstanceBase):
|
|
"""Schema for agent instance in database."""
|
|
|
|
id: UUID
|
|
last_activity_at: datetime | None = None
|
|
terminated_at: datetime | None = None
|
|
tasks_completed: int = 0
|
|
tokens_used: int = 0
|
|
cost_incurred: Decimal = Decimal("0.0000")
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class AgentInstanceResponse(BaseModel):
|
|
"""Schema for agent instance API responses."""
|
|
|
|
id: UUID
|
|
agent_type_id: UUID
|
|
project_id: UUID
|
|
name: str
|
|
status: AgentStatus
|
|
current_task: str | None = None
|
|
short_term_memory: dict[str, Any] = Field(default_factory=dict)
|
|
long_term_memory_ref: str | None = None
|
|
session_id: str | None = None
|
|
last_activity_at: datetime | None = None
|
|
terminated_at: datetime | None = None
|
|
tasks_completed: int = 0
|
|
tokens_used: int = 0
|
|
cost_incurred: Decimal = Decimal("0.0000")
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
# Expanded fields from relationships
|
|
agent_type_name: str | None = None
|
|
agent_type_slug: str | None = None
|
|
project_name: str | None = None
|
|
project_slug: str | None = None
|
|
assigned_issues_count: int | None = 0
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class AgentInstanceListResponse(BaseModel):
|
|
"""Schema for paginated agent instance list responses."""
|
|
|
|
agent_instances: list[AgentInstanceResponse]
|
|
total: int
|
|
page: int
|
|
page_size: int
|
|
pages: int
|
|
|
|
|
|
class AgentInstanceMetrics(BaseModel):
|
|
"""Schema for agent instance metrics summary."""
|
|
|
|
total_instances: int
|
|
active_instances: int
|
|
idle_instances: int
|
|
total_tasks_completed: int
|
|
total_tokens_used: int
|
|
total_cost_incurred: Decimal
|