Build a multi-agent music production pipeline on Amazon Bedrock AgentCore Runtime Instances
https://aws.amazon.com/blogs/machine-learning/build-a-multi-agent-music-production-pipeline-on-amazon-bedrock-agentcore-runtime-instances/📌 AWS讓多個Agent共用GPU跑好幾天的協作
TL;DR:AWS Bedrock AgentCore 新推出 Runtime Instances,讓多個 agent 共享 GPU 與檔案系統,支援長達 14 天的持續協作工作流。
單一 agent 回答客服問題,短短幾小時的 serverless session 綽綽有餘;但如果是三個 agent 要花好幾天合作完成一段音樂創作,彼此需要共享上下文、接續對方的產出,傳統 serverless 的 session 時限根本撐不住。AWS 這篇教學就示範了怎麼用新的運算選項解決這個問題。
🤔 多代理系統改變了基礎設施需求
Amazon Bedrock AgentCore 原本提供 MicroVMs 這種無伺服器選項:冷啟動快、session 彼此隔離、按用量計價。這次新增的 Runtime Instances,則是 AWS 代管的 EC2 基礎設施,專為長時間執行的 agent 工作流設計。兩者共用同一套 runtime API,差別在於底層運算模型:MicroVMs 是一個 runtime 對應一個 agent,Runtime Instances 則能讓多個 agent 共用同一個 session,只要用相同的 runtimeSessionId 呼叫,多個 runtime 就會被安排到同一臺 EC2 執行個體上,共享檔案系統並協同作業。
🧩 三個 agent:作曲、後製、合規把關
這次示範的音樂製作系統包含三個專責 agent。composition agent 用 Claude Sonnet 4.6 把製作人的需求轉成音樂簡報,再呼叫 ACE-Step 這個生成式音訊基礎模型,在該 instance 的 GPU 上實際算出一段音訊。delivery agent 從共享檔案系統讀取這段 .wav,測量後用 Claude Sonnet 4.6 決定 EQ 頻段與壓縮器設定,套用訊號處理後再重新測量一次,確認結果真的達標,而不是單憑推論。compliance agent 接著獨立重新測量,核對 delivery agent 宣稱的交付目標,並比對工作室既有作品庫檢查和聲相似度;一旦發現雷同,就會回頭呼叫 composition agent 產生替代版本。
架構細節:capacity provider 負責指定 instance 類型與 VPC 配置,由 AgentCore 代管佈建與生命週期;需要兩個信任 bedrock-agentcore.amazonaws.com 的 IAM 角色;命名時要用底線而非連字號。每個 agent 都部署成獨立的 runtime,並在呼叫時各自掛上 capacity provider,指定要掛載哪些 volume,最後用同一個 runtimeSessionId 逐一呼叫,就能讓它們落在同一臺機器上互相交棒。
🎯 實作眉角與運維要點
文中提到兩個容易搞錯、而且出錯訊息很模糊的地方:SDK 是靠參數名稱 params[1] == “context” 來判斷、讀取 session ID(agent 要靠這個找到彼此的檔案並互相呼叫);另外 Agent 物件要建在 handler 內部而非模組層級,否則多個並行請求共用同一個模組層級 Agent,會被 Strands 拒絕並丟出「Agent is already processing a request」錯誤。對話歷史則透過掛在 volume 上的 FileSessionManager 保存,讓幾天後恢復的 session 依然記得先前的決策。
第一次呼叫會比較慢,因為要佈建 instance;之後的呼叫都會直接路由到已經在跑的機器上。呼叫 StopRuntimeSession 後,instance 會自動閒置下來,閒置期間不計費;之後再次呼叫會恢復 session,前提是落在同一個可用區(Availability Zone)。由於 Amazon EBS volume 是綁定可用區的,若原本的 AZ 容量不足,volume 就無法重新掛載、持久狀態也會跟著遺失,需要用 AZ 綁定的 ODCR 或指定 MODELS_SNAPSHOT_ID 來因應。Session 最長可持續 14 天。
這個架構也讓獨立部署變得簡單:某個團隊要更新 composition agent,只需要更新自己的 runtime,delivery 與 compliance agent 完全不受影響,不需要協調、不共用部署流程,也不會有互相打架的風險。要結束整個 pipeline,先刪除 session 就會一併解除佈建 EC2 instance、網路介面與 EBS volume,是停止計費最直接的方式。
🔗 來源
- 標題:Build a multi-agent music production pipeline on Amazon Bedrock AgentCore Runtime Instances
- 作者/機構:Evandro Franco, AWS Machine Learning Blog
- 連結:https://aws.amazon.com/blogs/machine-learning/build-a-multi-agent-music-production-pipeline-on-amazon-bedrock-agentcore-runtime-instances/
#AWS #BedrockAgentCore #MultiAgent #AgenticAI #GPU #StrandsAgents #CloudInfrastructure #AudioAI #AgentOrchestration #MLOps
原始資料 AWS ML · 收集於 2026-09-30
摘要原文
As organizations move from single-purpose agents to multi-agent systems, the infrastructure requirements change. A lone agent handling customer queries can run in a serverless environment with short-lived sessions. But when you need three agents collaborating on a creative workflow that spans several days, sharing context and building on each other’s output, serverless sessions that cap at a few hours don’t cut it. In this post, we walk through deploying a music production pipeline: One agent runs a generative audio model on the instance’s own GPU. The other two open the .wav file it wrote, off a shared volume. By the end, you will have a track you can play. You will also have learned how to create capacity providers, deploy agents from different artifact types, orchestrate agent-to-agent collaboration using shared sessions, and persist workflows across multiple days. Amazon Bedrock AgentCore offers two compute options for hosting agents. MicroVMs are the serverless option: fast cold starts, session isolation, and consumption-based pricing. Runtime Instances are the new option: AWS managed EC2 infrastructure for persistent, long-running agent workflows. Both use the same runtime APIs, but Instances add multi-day sessions, GPUs, persistent volumes, and the ability to colocate multiple agents on a single instance. Both options support custom frameworks (CrewAI, LangGraph, LlamaIndex, Strands Agents), work with your choice of foundation model, integrate with MCP and A2A, and share the same AgentCore runtime APIs. The difference is in the underlying compute model. An agent is a workload running within a session. Unlike the MicroVM model, where one runtime hosts one agent, a single Instances session can host multiple agents. When two agent runtimes share the same capacity provider, you can invoke them with the same runtimeSessionId to land both agents on the same EC2 instance. There, they share a filesystem and can collaborate on the same task. Figure 1: The three-agent pipeline (Compose, Deliver, Screen) sharing one GPU instance and session We will build a music production system that uses three specialized agents: The workflow: a producer starts a track. The composition agent writes a brief and renders real audio on the instance’s GPU. The delivery agent opens that file, measures it, applies a chain it derived from those measurements, and measures again to prove the result landed on target. The compliance agent then re-measures independently, checks the delivery targets, and screens the audio against the studio’s back catalog. If the screen flags a match, it calls back to the composition agent to generate an alternative. The producer ends up with a playable .wav and three reports explaining every decision. What makes this possible on Runtime Instances: From here on, this post is hands-on. You will prepare your AWS account, then run a three-agent pipeline that renders, generates, and clears a finished track, producing a .wav file you can play. Work through the steps in order. You will start by confirming the prerequisites, then define the three agents (Step 1), create a capacity provider that provisions the GPU instance and its persistent volumes (Step 2), deploy each agent as its own runtime (Step 3), and invoke them with a shared session ID so they can colocate on one instance and hand work to each other (Step 4). Finally, Step 5 shows how any one team can ship a new version of its agent without disturbing the others. The complete sample is in the AgentCore samples GitHub repository . Before you begin, make sure you have: For the complete working code, see the AgentCore samples repository on GitHub. AgentCore Runtime Instances supports any agent framework. In this sample, each agent is a Python application built with Strands Agents . Two details are commonly misconfigured, and both fail confusingly: The SDK dispatches on the parameter name (it checks params[1] == "context" ). That is the only way to read the session ID, which the agents need in order to find each other’s files and to call one another. Second, build the Agent inside the handler, not at module scope: A module-level Agent is shared across concurrent requests, and Strands rejects re-entrant invocation with Agent is already processing a request . History lives on the volume through FileSessionManager , which is how a session resumed days later remembers earlier decisions. The composition agent turns the producer request (prompt) into a musical brief, using Claude Sonnet 4.6, then renders the actual audio with the ACE-Step foundation model: The mode=prepare call builds the stack onto the volume, a virtualenv with CUDA PyTorch and ACE-Step. The render runs as a subprocess under that volume’s interpreter: The delivery agent reads the rendered track off the shared filesystem and measures it. It uses Claude Sonnet 4.6 to choose EQ bands, compressor settings, and what to leave alone. The digital signal processing (DSP) is then applied. Then the output is measured again, so the plan is checked rather than trusted. The compliance agent independently re-measures the finished delivery, checks it against the delivery targets the delivery agent claimed, and screens it for harmonic similarity against the studio’s own back catalog. When it finds a similarity, it raises a flag and calls back to the composition agent for remediation. A capacity provider tells AgentCore what compute infrastructure to provision for your agents. You specify instance types and VPC placement. AgentCore handles provisioning and lifecycle management. You need two IAM roles, and the distinction matters: Both trust bedrock-agentcore.amazonaws.com . Now create the capacity provider. Note that names must use underscores (hyphens are not allowed): GPU capacity. If you hit InsufficientInstanceCapacity across multiple Availability Zones (AZs) trying to allocate a GPU instance, you can switch to another GPU instance type, like g5.xlarge . Update allowedInstanceTypes accordingly. Each agent here gets its own runtime. The runtimes are brought together at invoke time. When two runtimes share a capacity provider and you invoke them with the same runtimeSessionId , AgentCore places both agents on the same EC2 instance, where they share a filesystem and can collaborate on the same task. That’s how the delivery agent reads the .wav the composition agent wrote. Next, point each runtime at the capacity provider and declare which volumes it mounts: The compliance agent is the same call with a different artifact, a zip rather than an image, and only the workspace volume: Now invoke the agents. This is where the three agents become a pipeline: you pass the same runtimeSessionId to each invocation. The first invocation is the slow one because it provisions the instance. Every call after that routes to the instance already running. Here’s what that produces on a live g6.xlarge in us-east-2: When you call StopRuntimeSession , the instance idles down automatically. No compute charges accrue while idle. When you invoke the session again, AgentCore resumes it, provided it lands in the same Availability Zone . Amazon Elastic Block Store (Amazon EBS) volumes are AZ-locked. If the original AZ is capacity-dry, volumes can’t reattach and persistence is lost. Use an AZ-pinned ODCR or MODELS_SNAPSHOT_ID so a re-placed resume can recover. Sessions can persist for up to 14 days. One of the strengths of this architecture is independent deployment. When the Audio AI team ships a new version of the composition agent, they update only their runtime: The delivery and compliance agents continue running unchanged. No coordination needed, no shared deploy pipeline, no risk of breaking another team’s agent with your update. Delete the session first. It’s the most direct way to stop EC2 and Amazon EBS charges. Deleting a session deprovisions the EC2 resources: instance, network interface, and Amazon EBS volume.
由 claude-code/sonnet 自動生成