From 6de433d92b8df6f6318b2e8d3dddc47b6a69e869 Mon Sep 17 00:00:00 2001 From: elipitc Date: Wed, 3 Jun 2026 11:12:36 +0800 Subject: [PATCH] Add runtime revision and workflow detail fields --- api/swarm/models.py | 1 + api/swarm/router.py | 13 +++++++++++-- k8s/agent-manager-deployment.yaml | 2 +- k8s/deployment-with-kubeconfig.yaml | 2 +- k8s/deployment.yaml | 2 +- tests/test_sub_mode_runtime_contract.py | 1 + 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/api/swarm/models.py b/api/swarm/models.py index e9b28c4..8661581 100644 --- a/api/swarm/models.py +++ b/api/swarm/models.py @@ -111,6 +111,7 @@ class SwarmCreateResponse(BaseModel): """Compatibility response model for sub-mode runtime creation.""" deployment_id: Optional[str] = None swarm_id: str + mode: Optional[str] = None status: str agents: List[SwarmAgentInfo] created_at: datetime diff --git a/api/swarm/router.py b/api/swarm/router.py index 0411f9b..10c88ec 100644 --- a/api/swarm/router.py +++ b/api/swarm/router.py @@ -3,11 +3,13 @@ import json import mimetypes import uuid +from copy import deepcopy from datetime import datetime, timedelta from typing import Dict, Any from fastapi import APIRouter, Depends, HTTPException, BackgroundTasks, Request from fastapi.responses import FileResponse, Response from sqlalchemy.orm import Session +from sqlalchemy.orm.attributes import flag_modified from database import ( get_db, Swarm, SwarmAgent, SwarmMessage, @@ -391,6 +393,7 @@ async def create_swarm( return SwarmCreateResponse( deployment_id=swarm_id, swarm_id=swarm_id, + mode="sub_agile", status=project_runtime_run_status(swarm.status), agents=agent_infos, created_at=swarm.created_at, @@ -808,7 +811,7 @@ def apply_runtime_artifact_edit(db: Session, swarm_id: str, request: ArtifactEdi if not swarm: raise HTTPException(status_code=404, detail="Runtime deployment not found") - artifacts = list(swarm.artifacts or []) + artifacts = deepcopy(list(swarm.artifacts or [])) artifact = next((artifact for artifact in artifacts if artifact.get("artifact_id") == request.artifact_id), None) if not artifact: raise HTTPException(status_code=404, detail="ARTIFACT_REVISION_NOT_FOUND") @@ -839,6 +842,7 @@ def apply_runtime_artifact_edit(db: Session, swarm_id: str, request: ArtifactEdi ) artifact["metadata"] = metadata swarm.artifacts = artifacts + flag_modified(swarm, "artifacts") swarm.updated_at = datetime.utcnow() db.commit() @@ -869,8 +873,13 @@ async def receive_swarm_artifact_edit( db: Session = Depends(get_db), ): """Accept an accepted project revision forwarded by Manager.""" - response = apply_runtime_artifact_edit(db, swarm_id, request) swarm = db.query(Swarm).filter(Swarm.swarm_id == swarm_id).first() + try: + response = apply_runtime_artifact_edit(db, swarm_id, request) + except HTTPException as exc: + if swarm and exc.status_code == 409: + await _emit_artifact_edit_event(swarm, request, "artifact.local_edit_conflict") + raise if swarm: await _emit_artifact_edit_event(swarm, request, "artifact.local_edit_applied") return response diff --git a/k8s/agent-manager-deployment.yaml b/k8s/agent-manager-deployment.yaml index d3f8684..49f1ec2 100644 --- a/k8s/agent-manager-deployment.yaml +++ b/k8s/agent-manager-deployment.yaml @@ -31,7 +31,7 @@ spec: containers: - name: agent-manager - image: agnettaiji.azurecr.io/ai-agents/agent-manager:heicode-v2-runtime-20260603104215-arm64 + image: agnettaiji.azurecr.io/ai-agents/agent-manager:heicode-v2-runtime-20260603110450-arm64 imagePullPolicy: Always ports: diff --git a/k8s/deployment-with-kubeconfig.yaml b/k8s/deployment-with-kubeconfig.yaml index e875a67..a13b655 100755 --- a/k8s/deployment-with-kubeconfig.yaml +++ b/k8s/deployment-with-kubeconfig.yaml @@ -22,7 +22,7 @@ spec: - name: acr-secret containers: - name: agent-manager - image: agnettaiji.azurecr.io/ai-agents/agent-manager:heicode-v2-runtime-20260603104215-arm64 + image: agnettaiji.azurecr.io/ai-agents/agent-manager:heicode-v2-runtime-20260603110450-arm64 imagePullPolicy: Always ports: - containerPort: 8000 diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index f971111..2e78e7a 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -20,7 +20,7 @@ spec: - name: acr-secret containers: - name: agent-manager - image: agnettaiji.azurecr.io/ai-agents/agent-manager:heicode-v2-runtime-20260603104215-arm64 + image: agnettaiji.azurecr.io/ai-agents/agent-manager:heicode-v2-runtime-20260603110450-arm64 imagePullPolicy: Always ports: - containerPort: 8000 diff --git a/tests/test_sub_mode_runtime_contract.py b/tests/test_sub_mode_runtime_contract.py index 4eedc8b..c2b72b1 100644 --- a/tests/test_sub_mode_runtime_contract.py +++ b/tests/test_sub_mode_runtime_contract.py @@ -104,3 +104,4 @@ def test_runtime_rich_workflow_contract_is_present(): callbacks_source = _read("api/agnet/callbacks.py") assert "artifact.local_edit_applied" in callbacks_source assert '"project_folder"' in callbacks_source + assert "mode: Optional[str] = None" in swarm_models_source