diff --git a/k8s/orchestrator-local.yaml b/k8s/orchestrator-local.yaml new file mode 100644 index 0000000..3734816 --- /dev/null +++ b/k8s/orchestrator-local.yaml @@ -0,0 +1,104 @@ +# Local (Docker Desktop k8s) orchestrator deploy — adapted from orchestrator-deployment.yaml. +# Differences vs prod: local-built arm64 image (imagePullPolicy: Never), host Docker redis via the +# kind gateway, OpenAI base = api.heicode.cc, NO azkv (model key from an optional local Secret). +apiVersion: v1 +kind: Service +metadata: + name: orchestrator-service + namespace: swarm-system + labels: { app: orchestrator } +spec: + type: ClusterIP + ports: + - port: 8000 + targetPort: 8000 + name: http + selector: { app: orchestrator } +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: orchestrator + namespace: swarm-system + labels: { app: orchestrator } +spec: + replicas: 1 + selector: + matchLabels: { app: orchestrator } + template: + metadata: + labels: { app: orchestrator } + spec: + serviceAccountName: swarm-orchestrator + containers: + - name: orchestrator + image: swarm-orchestrator:local + imagePullPolicy: Never # use the node-loaded local image; never pull + ports: + - containerPort: 8000 + name: http + env: + # Reuse the existing in-cluster redis (Service redis-service in swarm-system). + - name: REDIS_HOST + value: "redis-service" + - name: REDIS_PORT + value: "6379" + - name: REDIS_DB + value: "0" + - name: LOG_LEVEL + value: "INFO" + # Swarm launches agent pods in-cluster using the local agent image. + - name: AGENT_LAUNCH_BACKEND + value: "kubernetes" + - name: AGENT_POD_IMAGE + value: "swarm-agent:local" + - name: AGENT_POD_NAMESPACE + value: "swarm-system" + - name: ORCHESTRATOR_PUBLIC_URL + value: "ws://orchestrator-service.swarm-system.svc.cluster.local:8000" + # User-supplied LLM gateway (OpenAI-compatible). + - name: AGENT_OPENAI_API_BASE + value: "https://api.heicode.cc/v1" + - name: OPENAI_API_BASE + value: "https://api.heicode.cc/v1" + # Default model id for launched agents (benchmark target; overridable per create request). + - name: OPENAI_MODEL + value: "qwen3.7-max" + # Agent pool window (local test): at least 16, up to 64 per run. + - name: AGENT_LAUNCH_MIN_POOL + value: "16" + - name: AGENT_LAUNCH_POOL_SIZE + value: "16" + - name: AGENT_LAUNCH_MAX_POOL + value: "64" + - name: MAX_AGENTS_PER_USER + value: "64" + # agent_swarm#7 bottom-up decomposition: how many subtasks one run may spawn. + - name: AGENT_PROPOSAL_BUDGET + value: "12" + # Local: no Azure workload identity. Model key comes from an OPTIONAL local Secret + # (swarm-model-key/OPENAI_API_KEY). resolve_model_key() falls back to this OPENAI_API_KEY. + # Create it to enable real LLM calls: + # kubectl -n swarm-system create secret generic swarm-model-key \ + # --from-literal=OPENAI_API_KEY=sk-xxxx + - name: OPENAI_API_KEY + valueFrom: + secretKeyRef: + name: swarm-model-key + key: OPENAI_API_KEY + optional: true + resources: + requests: { memory: "256Mi", cpu: "200m" } + limits: { memory: "512Mi", cpu: "500m" } + livenessProbe: + httpGet: { path: /health, port: 8000 } + initialDelaySeconds: 20 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 + readinessProbe: + httpGet: { path: /health, port: 8000 } + initialDelaySeconds: 8 + periodSeconds: 5 + timeoutSeconds: 3 + failureThreshold: 3 diff --git a/orchestrator/agent_launcher.py b/orchestrator/agent_launcher.py index 491eed4..a7add37 100644 --- a/orchestrator/agent_launcher.py +++ b/orchestrator/agent_launcher.py @@ -492,6 +492,10 @@ def plan_launch_specs( env["HEICODE_USER_ID"] = user_id if git_env: env.update(git_env) + # LOCAL TEST ONLY (not for upstream): propagate the agent-side subtask-handoff switch so + # launched agents decompose + hand off subtasks to peers (else each agent does its task alone). + if os.getenv("ENABLE_SUBTASK_HANDOFF", "false").lower() in {"1", "true", "yes"}: + env["ENABLE_SUBTASK_HANDOFF"] = "true" specs.append(AgentLaunchSpec(agent_id=env["AGENT_ID"], capabilities=cap_csv, env=env)) return specs