TL;DR

Anthropic phát hành dynamic workflows trong Claude Code, cho phép Claude tự viết harness orchestration cho từng tác vụ cụ thể. Thay vì một context window duy nhất, workflows sinh ra 10-1.000 subagent song song, mỗi cái có context window riêng, tránh được những bệnh: agentic laziness (dừng giữa đường), self-preferential bias (ưu thích kết quả của chính mình), goal drift (mất mục tiêu ban đầu).

Lợi ích: Bun đã dùng workflows để port 750.000 dòng code từ Zig sang Rust trong 11 ngày (99,8% test pass), công việc dự kiến mất 6-12 tháng. Tradeoff: dùng ~15× more tokens, nhưng kết quả tốt 90% hơn so với Opus 4 solo.

Dynamic Workflows Là Gì?

Dynamic Workflows là JavaScript orchestration scripts mà Claude viết ngay trên harness, custom-built cho từng tác vụ. Thay vì Claude Code harness mặc định (tối ưu cho coding tasks), workflows cho phép Claude tự chọn:

  • Số tác nhân: Từ vài cái cho task nhỏ đến 1.000+ cho audit cảnh báo đỏ

  • Model tier: Orchestrator (Opus 4.8) điều phối, subagent dùng Sonnet, Haiku tuỳ cần

  • Isolation: Worktree per-agent nếu cần tránh collision parallel

  • Phân công: Classify-and-route, fan-out-and-synthesize, adversarial verify, generate-and-filter, tournament, loop-until-done

Script runtime chạy nền trong Claude Code, manage state, verify kết quả trước khi trả về. Nếu interrupt, resume sau này sẽ tiếp tục từ checkpoint - không mất tiến độ.

Tại Sao Tạo Ra ?

Harness mặc định của Claude Code tối ưu cho coding tasks: planning + execution cùng lúc trong 1 context window. Nhưng nó có vấn đề với tác vụ phức tạp, lâu dài, song song:

Agentic laziness: Claude dừng giữa đường khi task quá phức tạp, tuyên bố "xong" dù mới hoàn 20 trên 50 item. Ví dụ: security review 50 files, Claude chỉ review 15 rồi nói "done".

Self-preferential bias: Khi yêu cầu verify hay judge kết quả của chính mình, Claude có xu hướng ưu thích kết quả đó, dù sai. Tạo agent X để tìm bug, agent Y (của chính X) để verify → Y có xu hướng nói "looks good" về findings của X.

Goal drift: Qua nhiều turns, details constraints bị mất dần. Ví dụ: "không dùng dark color", mà qua 10 turn summarization, constraint ấy biến mất.

Workflows động cấu trúc chống những bệnh này: spins up agent độc lập → mỗi cái có goal riêng + context + không bị self-bias vì chúng không phải agent tạo ra findings.

Các Mô Hình Pattern Phổ Biến

Khi Claude xây dựng workflow, nó có thể kết hợp những pattern sau:

  • Classify-and-act: 1 agent classifier quyết định type tác vụ → route sang agent khác tùy type

  • Fan-out-and-synthesize: Split task thành N step → spawn N agent → synthesize kết quả. Barriers: synthesize chờ hết fan-out xong mới chạy

  • Adversarial verify: Mỗi agent tạo output → spawn skeptic agent để REFUTE nó. Kill nếu majority refute

  • Generate-and-filter: Spawn N agent tạo ideas → filter theo rubric, dedup, return top quality

  • Tournament: N agent cùng attempt task với N cách khác nhau → judge pairwise champion bracket

  • Loop-until-done: Tác vụ unknown-size (bug hunt, issue mining), keep spawning agents đến khi K rounds không tìm được gì mới

So Sánh vs Cũ

Static workflows (Agent SDK, claude -p): Generic, dùng được cho mọi edge case, nhưng kém optimal cho từng use-case cụ thể.

Dynamic workflows: Claude viết harness tailor-made per task → adaptive, tối ưu hơn.

Single Opus 4.8: Nhanh, mua tokens rẻ, nhưng dễ bị 3 bệnh (laziness, bias, drift). Multi-agent dùng 15× more tokens, nhưng kết quả tốt 90% hơn trên complex tasks.

Khi Nào Dùng Workflows?

Workflows KHÔNG phải cho regular coding tasks (rewrite function, fix bug nhỏ). Dùng khi:

  • Task phức tạp, multi-step, hoặc unknown-size

  • Cần parallel execution → savings wall-clock time

  • Quality > speed (security audit > prototype)

  • Giá trị của task justify ~15× token cost

  • Cần independent verification (reduce bias)

Ví dụ workflows hợp lý: large migration (750k+ lines), security audit (codebase-wide), root cause investigation (multiple hypotheses), deep research (fan-out searches), triage at scale (1000+ tickets).

Workflows chưa hợp lý: thêm feature nhỏ, fix typo, refactor 1 function.

Kết

Dynamic Workflows trong Claude Code là bước tiến lớn cho phép Claude xử lý tác vụ phức tạp mà trước đây phải tay người hoặc hệ thống bên ngoài. Paradigm từ single-agent-plan-exec sang multi-agent-orchestration mở ra khả năng mới trong automation, security audit, research. Bun đã chứng minh (750k lines, 11 days, 99.8% pass), workflows sẽ trở thành công cụ chuẩn cho large-scale software tasks.

Tuy nhiên, best practices vẫn đang evolve. Workflows dùng nhiều token, nên nghĩ kỹ khi + sao dùng. Nếu task tạo được giá trị lớn (security, migration, research), workflows là step up. Nếu task routine, solo Claude Sonnet/Opus vẫn nhanh và rẻ hơn.