

🏗️ OpenAI Symphony deep-dive: Bóc tách spec poll-dispatch-reconcile đứng sau +500% PR
OpenAI vừa open-source Symphony, không phải SaaS mà là một specification (Apache 2.0) để team tự build orchestrator biến Linear thành control plane cho Codex agents. Triết lý "software as a spec" (Zach Brock, OpenAI): spec đứng trước implementation, Codex tự build reference trong 5+ ngôn ngữ song song để phát hiện ambiguity.
🎼 Symphony và "software as a spec"
Repo github.com/openai/symphony chỉ có SPEC.md và reference Elixir. OpenAI chọn Elixir vì primitives supervising concurrent processes vượt trội, nhưng nói thẳng: "Symphony Elixir is prototype software intended for evaluation only". Khuyến nghị production: đọc SPEC, tự build hardened version. Nội bộ OpenAI ghi nhận +500% landed PRs trên một số team trong vài tuần.
🔄 Vòng lặp Poll-Dispatch-Reconcile
Trái tim Symphony là loop 4 giai đoạn:
- Poll Tick: validate config, fetch issues từ Linear qua GraphQL (filter
project.slugId) - Dispatch: sort priority, claim issue, launch agent worker trong workspace cô lập
- Reconciliation: monitor session, dừng stalled/terminal, refresh tracker
- Retry Queue:
delay = min(10000 × 2^(attempt-1), max_retry_backoff_ms), cap 5 phút
Bất biến: "The orchestrator is the only component that mutates scheduling state", chống race condition. Polling 30s, max_concurrent_agents mặc định 10.
📝 WORKFLOW.md, hợp đồng team-Symphony
File commit thẳng vào repo, gồm YAML front matter (config) và Markdown body (prompt template). Section chính:
tracker: Linear endpoint, project slug, statespolling.interval_ms,workspaceroothooks:after_create,before_run,after_run,before_removeagent:max_concurrent_agents,max_turns,max_retry_backoff_mscodex: command, approval_policy, sandbox
Bắt buộc: "Software MUST detect WORKFLOW.md changes and re-apply config without restart". Hot reload là requirement.
🧪 Workspace, hooks và retry
Mỗi issue có workspace tại <workspace_root>/<sanitized_issue_identifier>. Ký tự ngoài [A-Za-z0-9._-] thay bằng _. Workspace tồn tại sau run thành công để reuse cho retry. Bất biến: "Workspace path MUST stay inside workspace root", chống path traversal.
Hooks cwd = workspace: after_create (fail abort), before_run (fail abort), after_run/before_remove (chỉ log).
Codex launch qua bash -lc <codex.command>, emit session_id = <thread_id>-<turn_id>. Continuation retry 1000ms fixed. Stall: không event trong 5 phút thì kill worker.
📊 Observability: logs và HTTP API
Spec yêu cầu structured logging với issue_id, issue_identifier, session_id. Token accounting track absolute thread totals, không double-count.
HTTP server (qua --port hoặc server.port):
GET /api/v1/state: runtime snapshot (running, retrying, tokens, rate limits)GET /api/v1/<issue_identifier>: debug detailPOST /api/v1/refresh: trigger poll+reconciliationGET /: dashboard
API vừa đủ tích hợp Prometheus/Grafana.
💡 Cảnh báo và áp dụng cho team Việt
Spec KHÔNG quy định: sandbox/hardening, web UI, multi-tenant, workflow engine, tracker write API. SPEC: "Implementations SHOULD state clearly whether they are intended for trusted environments".
Khuyến nghị CTO Việt:
- Đừng deploy Symphony Elixir vào production. Tự build hardened: secret qua Vault, sandbox Firecracker/gVisor, audit log
- Bắt đầu nhỏ: 1-2 service, đo throughput PR trước/sau 4 tuần
- Port sang stack quen: Node/TS hoặc Go theo SPEC.md
- Tích hợp với team đã dùng Linear và GitHub
Team bạn đã thử fork Symphony chưa? Comment để cùng bàn architecture decisions.
#OpenAISymphony #Codex #SoftwareAsASpec #DevOps #VibeAICoder


