Blog · Amazon Bedrock Agents · Multi-Agent, Memory, Return Control & Prompt Override · 2026-11-20
Amazon Bedrock Agents for MCP Servers: Multi-Agent Orchestration, Cross-Session Memory, Return Control, and Prompt Override
A single Bedrock Agent with Lambda action groups can call tools and answer questions — but that only gets you to the first demo. Production MCP server platforms hit four walls quickly: too many tools to load into one agent's context, users who return to a blank slate each session, Lambda cold starts that break interactive workflows, and orchestration behavior that cannot be tuned without forking the entire prompt template. Amazon Bedrock Agents has production answers for all four problems — multi-agent collaboration for tool scale, SESSION_SUMMARY memory for user continuity, RETURN_CONTROL execution for in-process MCP routing, and PromptOverrideConfiguration for behavioral control. This post synthesizes all four patterns into a complete picture of what it takes to run a Bedrock-backed MCP platform in production.
TL;DR
- Multi-agent: use alias ARNs, not agent ARNs.
AssociateAgentCollaboratorCommandtakes an alias ARN inagentDescriptor.aliasArn. Using an agent ARN makes routing silently fail — the supervisor handles all requests itself with no error. - Multi-agent: re-prepare the supervisor after every collaborator change. PrepareAgentCommand updates the orchestration manifest. Without it, newly associated collaborators are invisible to the runtime.
- Memory: memoryId ≠ sessionId.
memoryIdis the stable user identity (hash a user ID);sessionIdis the per-conversation identifier. OmittingmemoryIdcauses each session to get its own isolated memory bucket — cross-session retention silently does not work. - Memory: 25-summary cap per memoryId. Older summaries are dropped as new ones arrive. Supplement with external storage for high-frequency users.
- Return Control: submit all tool results together. When
invocationInputscontains multiple tool calls, all results must be bundled into one re-invocation. Submitting a partial set returns an error. - Return Control: the RETURN_CONTROL pattern is the natural MCP bridge. The agent declares tool schemas; your application routes tool calls to the right MCP server at execution time — no Lambda deployment changes when MCP servers change.
- Prompt Override: include all five placeholders. An orchestration override that omits
$tools$means the model cannot call any tools. Omitting$memory_content$when memory is enabled means stored summaries are never injected. All five are required:$instructions$,$tools$,$conversation_history$,$question$,$memory_content$. - Guardrails are independent of prompt overrides. Guardrails apply at the Bedrock service layer before any prompt logic runs — a blocked input never reaches your pre-processing override.
The four-wall problem in production Bedrock Agents deployments
When you first deploy a Bedrock Agent for an MCP server platform, the architecture is clean: one agent, one set of action groups, tools backed by Lambda functions or direct MCP server calls. This handles the first few use cases well. Then scale arrives.
The tool count wall is usually the first. Claude 3 and 3.5 models work reliably with ten to twenty tools in context. Load fifty action group functions and the model starts selecting tools incorrectly — not because of a bug in your implementation, but because the model's attention distributes across too large a tool surface. Each tool name, description, and parameter schema consumes tokens in the system prompt, leaving less space for reasoning and conversation history.
The memory wall arrives when users return. The default Bedrock Agent is stateless across sessions. A user who spent a session configuring their data sources, setting their display preferences, and completing half a workflow starts the next session with a blank slate. Building a useful assistant requires persistence across conversations, not just within them.
The execution wall hits teams that chose Lambda action groups for all tools. Lambda cold starts add 100–1,000ms to the first tool call in a session. For MCP server platforms whose tool lists change as servers connect and disconnect, every tool change means updating Lambda handlers and re-deploying. For tools that need access to in-process state — authenticated sessions, database connections, in-memory registries of available MCP tools — Lambda's stateless isolation is the wrong execution model.
The behavior wall appears when you need the agent to do something the managed orchestration loop does not do well: inject dynamic per-request context, enforce domain-specific input policies before the orchestration model sees the request, transform outputs into a consistent format, or swap out the orchestration logic entirely when you need to integrate with an external routing system.
Bedrock Agents has production-grade answers for all four walls. They each require learning a new API surface and avoiding a set of non-obvious gotchas, but they compose cleanly. The rest of this post covers each one.
Multi-agent orchestration: scaling tool surface with SUPERVISOR and SUPERVISOR_ROUTER
Multi-agent collaboration in Bedrock Agents solves the tool count wall by decomposing a large tool surface into specialized sub-agents. A supervisor agent routes sub-tasks to collaborator agents; each collaborator maintains its own focused tool surface and context window. The supervisor sees each collaborator as an opaque capability — it does not need to know which tools the collaborator has, just what domain it covers.
The supervisor mode is configured in the agentCollaboration field on the agent resource. There are two meaningful values:
| Mode | Supervisor has own action groups? | Use case |
|---|---|---|
SUPERVISOR |
Yes | Supervisor can both handle requests directly and delegate to collaborators. Good when the supervisor needs fallback capabilities or cross-domain synthesis. |
SUPERVISOR_ROUTER |
No | Pure routing: every request is delegated to a collaborator. Maximum decoupling — the supervisor's sole job is intent classification and routing. |
For MCP server platforms, SUPERVISOR_ROUTER is the cleaner architecture when you have a clear domain decomposition. Each connected MCP server becomes a collaborator agent. The supervisor agent routes incoming user requests to the right collaborator based on intent. Adding a new MCP server means adding a new collaborator and updating the supervisor's collaborator associations — not touching the supervisor's instruction or action groups.
The aliasArn requirement: the most common first failure
The most common failure when setting up multi-agent collaboration is passing an agent ARN where Bedrock expects an alias ARN. The AssociateAgentCollaboratorCommand agentDescriptor.aliasArn field requires an alias ARN in this format:
arn:aws:bedrock:{region}:{account}:agent-alias/{agentId}/{aliasId}
The agent ARN — arn:aws:bedrock:{region}:{account}:agent/{agentId} — is a different resource. If you accidentally pass the agent ARN, the association command succeeds with no error. The supervisor prepares successfully. At runtime, the supervisor simply never routes to the collaborator; it handles all requests itself. There is no runtime exception to tell you something went wrong. Enable enableTrace: true in your invocation calls during development to see the supervisor's routing decisions in the orchestration trace output.
import { AssociateAgentCollaboratorCommand } from "@aws-sdk/client-bedrock-agent";
// dbAgent.agentId and dbAlias.agentAliasId come from prior CreateAgent + CreateAgentAlias calls
await client.send(new AssociateAgentCollaboratorCommand({
agentId: supervisorAgent.agentId,
agentVersion: "DRAFT",
agentDescriptor: {
// Alias ARN — not agent ARN
aliasArn: `arn:aws:bedrock:us-east-1:123456789012:agent-alias/${dbAgent.agentId}/${dbAlias.agentAliasId}`
},
collaborationInstruction: `Delegate to this agent for all database operations: running SQL queries,
retrieving schema information, checking connection health, and managing database users.`,
collaboratorName: "DatabaseSpecialist",
relayConversationHistory: "TO_COLLABORATOR"
}));
PrepareAgentCommand after every collaborator change
After associating all collaborators, re-prepare the supervisor with PrepareAgentCommand. Preparation compiles the orchestration manifest — the supervisor's view of which collaborators exist, their descriptions, and their alias ARNs. Without re-preparation, newly associated collaborators do not appear in the manifest and the runtime routes as if they do not exist.
This requirement applies every time the collaborator set changes: new associations, disassociations, and updates to collaborationInstruction or relayConversationHistory all require a re-prepare. The same is true for the collaborator agents themselves — if you update a collaborator's action groups or instruction, re-prepare the collaborator, create a new alias version if needed, and then re-prepare the supervisor to pick up the new alias routing configuration.
The supervisor's execution role also needs bedrock:InvokeAgent on each collaborator alias. Without this, preparation succeeds but delegation fails at runtime with an AccessDeniedException in the trace. Use a wildcard on the alias ID suffix so the permission covers all current and future alias versions without requiring IAM policy updates on every alias rotation:
{
"Effect": "Allow",
"Action": "bedrock:InvokeAgent",
"Resource": [
"arn:aws:bedrock:us-east-1:123456789012:agent-alias/DBAGENTID/*",
"arn:aws:bedrock:us-east-1:123456789012:agent-alias/FSAGENTID/*"
]
}
relayConversationHistory and session propagation
The relayConversationHistory field on each collaborator association controls whether the supervisor passes the full conversation history to the collaborator when delegating. TO_COLLABORATOR gives the collaborator full context — necessary when the sub-task requires prior conversation ("update the record we just looked up"). DISABLED gives the collaborator only the specific sub-task text — lower token cost, appropriate when each delegation is self-contained.
Important session behaviors in multi-agent systems: memory is per-agent (a supervisor's memory does not propagate to collaborators unless you configure memory on each collaborator separately), and each agent's idle session TTL is independent. Set collaborator idleSessionTTLInSeconds equal to or longer than the supervisor's TTL — a collaborator whose session expires while the supervisor session is still active loses its session context, causing the next delegation to that collaborator to start a new session.
Bedrock Agents can invoke multiple collaborators in parallel when the supervisor model determines sub-tasks are independent. Each parallel invocation uses the same session ID but different internal trace IDs. The final response assembles results from all parallel invocations. This is a quota consideration: parallel collaborator invocations multiply TPS against your Bedrock Agents invocation quota.
See the full multi-agent orchestration guide for the complete setup sequence, ListAgentCollaboratorsCommand / DisassociateAgentCollaboratorCommand for lifecycle management, and the MCP-server-per-collaborator Lambda pattern.
Cross-session memory: the memoryId / sessionId distinction
Bedrock Agents memory breaks the stateless-across-sessions default. When memory is enabled, Bedrock automatically summarizes each completed session and stores the summary under a stable memoryId. On subsequent sessions with the same memoryId, the agent loads those summaries into its context — the user's past preferences, completed tasks, and established facts are available from the first turn of a new conversation.
The single most important thing to understand about memory is the two-identifier model:
| Field | Scope | Lifecycle | Typical value |
|---|---|---|---|
sessionId |
Single conversation | Expires after idleSessionTTLInSeconds of inactivity |
Random UUID or {memoryId}-{timestamp} |
memoryId |
User identity across all conversations | Persists for storageDays (1–365) |
SHA-256 hash of internal user ID, truncated to 32 chars |
If you omit memoryId from an invocation, Bedrock uses the sessionId as the memory identifier. This means every new conversation — which always starts with a new sessionId — gets its own isolated memory bucket. The agent generates summaries, stores them, and never retrieves them, because no future session shares the same identifier. This is the most common reason memory "doesn't work" in early integration testing.
Always pass an explicit memoryId that maps to a stable user identity. Do not use raw user IDs or email addresses — these may appear in CloudWatch logs. Use a one-way hash:
const userId = "user_8f3a9d2c";
const memoryId = crypto.createHash("sha256").update(userId).digest("hex").slice(0, 32);
const sessionId = `${memoryId}-${Date.now()}`;
const response = await runtime.send(new InvokeAgentCommand({
agentId: process.env.BEDROCK_AGENT_ID,
agentAliasId: process.env.BEDROCK_AGENT_ALIAS_ID,
sessionId,
memoryId,
inputText: message
}));
The 25-summary cap and the external storage supplement
Bedrock imposes a cap of 25 stored session summaries per memoryId. When a 26th session ends and is summarized, the oldest summary is dropped. For users who interact daily within a 365-day retention window, this means roughly the most recent 25 days of session history are available — older context is gone.
For platforms where long-term retention across more sessions is a core feature, supplement Bedrock's built-in memory with external storage. Use GetAgentMemoryCommand to retrieve summaries after each session ends, persist them in your own database, and inject the most relevant historical context into future sessions via sessionState.sessionAttributes at invocation time. This supplements the 25-summary ring buffer without competing with it.
import { GetAgentMemoryCommand, DeleteAgentMemoryCommand } from "@aws-sdk/client-bedrock-agent-runtime";
// Inspect what is stored for a user (useful for debugging and compliance audits)
const { memoryContents } = await runtime.send(new GetAgentMemoryCommand({
agentId: "YOURAGENTID",
agentAliasId: "YOURAGENTALIASID",
memoryId,
memoryType: "SESSION_SUMMARY"
}));
for (const memory of memoryContents) {
if (memory.sessionSummary) {
console.log("Session:", memory.sessionSummary.sessionId);
console.log("Summary:", memory.sessionSummary.summaryText);
console.log("Expires:", memory.sessionSummary.expiresAt);
}
}
GDPR right-to-erasure: DeleteAgentMemoryCommand
Use DeleteAgentMemoryCommand to remove all stored memories for a user. This is the right tool for right-to-erasure (GDPR Article 17) requests. The deletion is immediate and permanent — no soft-delete or recovery window. Because memoryId is a one-way hash in the recommended pattern, you must store a mapping from raw user ID to memoryId in your own database. Bedrock does not provide a lookup from user identity to memoryId.
await runtime.send(new DeleteAgentMemoryCommand({
agentId: "YOURAGENTID",
agentAliasId: "YOURAGENTALIASID",
memoryId
}));
Memory deletion does not affect active sessions. If a user is in an active conversation when their memories are deleted, that session continues using whatever memories were loaded at its start. Future sessions start with an empty memory slate.
Triggering summarization immediately
Sessions are summarized either when the session TTL expires (the agent received no invocations for idleSessionTTLInSeconds of inactivity) or when you explicitly end the session by calling InvokeAgentCommand with endSession: true. Use the explicit approach when your application knows the conversation is complete — this triggers immediate summarization instead of waiting for the TTL and ensures the summary is available for the user's next session without an idle wait.
await runtime.send(new InvokeAgentCommand({
agentId: "YOURAGENTID",
agentAliasId: "YOURAGENTALIASID",
sessionId,
memoryId,
inputText: "",
endSession: true
}));
See the full memory guide for the multi-instance MCP server session management pattern, the agent instruction techniques for influencing summary quality, and memory pricing details.
Return Control: Bedrock Agents as a thin router to in-process MCP tools
RETURN_CONTROL is the execution model that makes Bedrock Agents a natural fit for MCP server platforms. With standard Lambda action groups, Bedrock invokes a Lambda function every time the agent calls a tool. RETURN_CONTROL inverts this: the agent decides what tool to call, Bedrock packages the tool call and sends it back to the calling application via the response stream, and the application executes the tool and re-submits the result. No Lambda required. The tool execution runs in your existing application process.
The pattern fits MCP servers precisely because MCP tool registration is dynamic. MCP servers advertise their tools via the tools/list method — the tool surface changes as servers connect and disconnect. With Lambda action groups, every tool change requires updating a Lambda handler and re-deploying. With RETURN_CONTROL, the tool execution routing lives entirely in your application; only the action group schema declaration requires updating in Bedrock (which still requires re-preparing the agent, but no Lambda deployment).
Configuring a RETURN_CONTROL action group
Create the action group with customControl: 'RETURN_CONTROL' in the executor. Define tool schemas in functionSchema.functions — these become the tools the agent can invoke via return control. The function schemas work the same way as Lambda action group schemas; only the executor is different.
import { CreateAgentActionGroupCommand } from "@aws-sdk/client-bedrock-agent";
await client.send(new CreateAgentActionGroupCommand({
agentId: "YOURAGENTID",
agentVersion: "DRAFT",
actionGroupName: "MCPTools",
description: "Tools provided by connected MCP servers",
actionGroupExecutor: {
customControl: "RETURN_CONTROL"
},
functionSchema: {
functions: [
{
name: "readFile",
description: "Read the contents of a file at the given path",
parameters: {
path: { type: "string", description: "Path to the file", required: true }
}
},
{
name: "runQuery",
description: "Execute a read-only SQL query and return results as JSON",
parameters: {
sql: { type: "string", description: "SQL SELECT statement", required: true },
database: { type: "string", description: "Database name", required: true }
}
}
]
}
}));
The ReturnControlPayload: invocationId and invocationInputs
When the agent decides to call a tool, the InvokeAgentCommand response stream emits a returnControl event instead of a text chunk. The event carries an invocationId (a stable identifier for this tool-call batch) and an invocationInputs array (one entry per tool call).
async function invokeAgent(sessionId, inputText) {
const response = await runtime.send(new InvokeAgentCommand({
agentId: process.env.BEDROCK_AGENT_ID,
agentAliasId: process.env.BEDROCK_AGENT_ALIAS_ID,
sessionId,
inputText
}));
let finalAnswer = "";
let returnControlEvent = null;
for await (const event of response.completion) {
if (event.chunk?.bytes) {
finalAnswer += new TextDecoder().decode(event.chunk.bytes);
} else if (event.returnControl) {
returnControlEvent = event.returnControl;
break;
}
}
if (returnControlEvent) {
return await handleReturnControl(sessionId, returnControlEvent);
}
return finalAnswer;
}
The critical rule: submit all results together
When the foundation model calls multiple tools in parallel (Claude 3.5 Sonnet and Opus do this frequently), invocationInputs contains multiple entries. All results must be submitted in a single re-invocation — submitting a partial set returns an error. Execute all tools, collect all results, then re-invoke once with everything bundled:
async function handleReturnControl(sessionId, returnControl) {
const { invocationId, invocationInputs } = returnControl;
// Execute all tool calls, possibly in parallel
const results = await Promise.all(
invocationInputs.map(async (input) => {
const { actionGroup, function: fnName, parameters } = input.functionInvocationInput;
const args = Object.fromEntries((parameters || []).map(p => [p.name, p.value]));
const toolResult = await executeMCPTool(fnName, args);
return {
functionResult: {
actionGroup,
function: fnName,
responseBody: {
TEXT: { body: typeof toolResult === "string" ? toolResult : JSON.stringify(toolResult) }
}
}
};
})
);
// Re-invoke with ALL results at once
const response = await runtime.send(new InvokeAgentCommand({
agentId: process.env.BEDROCK_AGENT_ID,
agentAliasId: process.env.BEDROCK_AGENT_ALIAS_ID,
sessionId,
inputText: "",
sessionState: {
invocationId,
returnControlInvocationResults: results
}
}));
let answer = "";
let nextReturnControl = null;
for await (const event of response.completion) {
if (event.chunk?.bytes) answer += new TextDecoder().decode(event.chunk.bytes);
else if (event.returnControl) { nextReturnControl = event.returnControl; break; }
}
// Handle chained tool calls recursively
if (nextReturnControl) return await handleReturnControl(sessionId, nextReturnControl);
return answer;
}
Chained tool calls are common — the agent may call a tool, receive results, decide it needs another tool based on those results, and emit a second returnControl event. The recursive pattern above handles this naturally. Set a maximum recursion depth (ten rounds is a reasonable default) to guard against runaway loops from a misconfigured agent instruction.
If a tool call in a batch fails — the MCP server returns an error, a timeout fires — still submit a result for it. Use the error message as the body. The agent incorporates the error into its reasoning and decides whether to retry, ask for clarification, or continue. Never silently omit a failed result from the batch; a missing result causes Bedrock to return an error, not graceful degradation.
The MCP tool registry pattern
The executeMCPTool function above is where MCP routing lives. For a Bedrock Agent fronting multiple MCP servers, maintain a registry that maps Bedrock tool names to their source MCP server:
const toolRegistry = {};
async function buildToolRegistry(mcpServers) {
for (const server of mcpServers) {
const { tools } = await server.listTools();
for (const tool of tools) {
const bedrockToolName = `${server.name}_${tool.name}`;
toolRegistry[bedrockToolName] = { server, mcpToolName: tool.name };
}
}
}
async function executeMCPTool(functionName, args) {
const registration = toolRegistry[functionName];
if (!registration) return JSON.stringify({ error: `Unknown tool: ${functionName}` });
const { server, mcpToolName } = registration;
const result = await server.callTool(mcpToolName, args);
return result.content.filter(c => c.type === "text").map(c => c.text).join("\n");
}
When the MCP server's tool list changes, rebuild the registry and update the Bedrock action group schema via UpdateAgentActionGroupCommand, then re-prepare the agent. The return control execution routing is in-application and invisible to Bedrock — only the schema declaration changes in AWS.
See the full Return Control guide for the RETURN_CONTROL vs Lambda comparison table, timeout handling, and the session management considerations when tool execution takes a long time.
Prompt Override Configuration: behavioral control across all pipeline stages
PromptOverrideConfiguration is the mechanism for taking control of the Bedrock Agents orchestration pipeline. By default, Bedrock manages every stage — pre-processing, orchestration, post-processing, and knowledge base response generation — using its own prompt templates. Overrides let you replace any stage's prompt text, attach a custom response-parsing Lambda, or replace the entire orchestration loop with your own Lambda.
The four stages and their override use cases:
| Stage | Prompt type | Override use cases for MCP platforms |
|---|---|---|
| Pre-processing | PRE_PROCESSING |
Topic restrictions, user metadata injection, intent classification before orchestration begins |
| Orchestration | ORCHESTRATION |
Dynamic runtime context injection (current date, user permissions), tool selection guidance, custom orchestration Lambda for external MCP tool registry integration |
| Post-processing | POST_PROCESSING |
Consistent response format enforcement, disclaimer injection, internal reasoning stripping |
| Knowledge base response | KNOWLEDGE_BASE_RESPONSE_GENERATION |
Citation format customization, recency emphasis, synthesis style changes |
The five required placeholders in orchestration overrides
Overriding the orchestration prompt is the most powerful option, but it requires including all five Bedrock-managed variable placeholders. Missing any one of them produces a silently degraded agent:
| Placeholder | What Bedrock injects | Effect of omitting |
|---|---|---|
$instructions$ |
The agent's instruction field text |
Agent loses its core persona and behavioral guidelines |
$tools$ |
Tool schemas for all action groups | Model cannot call any tools; will respond as if no tools exist |
$conversation_history$ |
Prior turns in the current session | Agent is amnesiac within a session; treats every turn as the first |
$question$ |
The current user input | Model does not see the user's request; produces generic output |
$memory_content$ |
Retrieved memory summaries (if memory is enabled) | Stored memories are never injected; memory is effectively disabled at runtime even if configured |
The $memory_content$ placeholder is the interaction point between memory configuration and prompt override. If you have enabled memory on the agent and you override the orchestration prompt without including $memory_content$, summaries are stored and retrieved but never reach the model — the two features cancel each other out silently.
const orchestrationTemplate = `You are an AI assistant for a data platform.
$instructions$
PLATFORM CONTEXT: Today is ${new Date().toISOString().split('T')[0]}. The requesting user has
read access to the reporting database and write access to their own dashboards.
$memory_content$
Available tools:
$tools$
Conversation history:
$conversation_history$
Current request: $question$`;
The PRE_PROCESSING XML format
Pre-processing overrides must return a strict XML format that Bedrock parses to determine whether to proceed. The namespace prefix amazon: is required; Bedrock does not accept variations. amazon:valid_input must be exactly true or false. A false value returns amazon:invalid_input_reason to the caller without touching the orchestration stage — the blocked request never reaches the model's core reasoning loop.
const preProcessingTemplate = `You are a pre-processor for a data analytics assistant.
Conversation history: $conversation_history$
User request: $question$
Is this request related to data analytics, SQL, or business intelligence?
Is this a request to access system credentials or infrastructure? Deny those.
Respond ONLY with this XML:
<amazon:pre_processing_response xmlns:amazon="http://www.amazon.com/bedrock/agents">
<amazon:valid_input>true|false</amazon:valid_input>
<amazon:invalid_input_reason>reason if false</amazon:invalid_input_reason>
<amazon:category>VALID|INVALID</amazon:category>
</amazon:pre_processing_response>`;
Guardrails are independent of prompt overrides
Bedrock Guardrails apply at the service layer, before any prompt logic runs. A guardrail that blocks an input prevents the pre-processing override from ever seeing the content. A guardrail that blocks an output prevents post-processing from receiving blocked content. This layering has a clear implication for architecture decisions:
- Use guardrails for universal, compliance-driven filtering (PII detection, profanity, topic denial) that must apply regardless of agent configuration and cannot be bypassed by any prompt modification.
- Use pre-processing overrides for domain-specific, context-aware validation that requires the model to reason about the input — policy rules that depend on conversation context or user state.
- Use post-processing overrides for output format normalization. Be aware they add a second model call to every response, increasing latency and cost proportionally.
Custom orchestration Lambda: replacing the built-in loop entirely
When prompt-level adjustments are insufficient — you need to integrate with a live MCP server manifest at each orchestration step, implement a fully custom tool-selection strategy, or route between different foundation models based on request type — use a custom orchestration Lambda. Set overrideLambda in the prompt configuration for the ORCHESTRATION stage. Bedrock calls this Lambda at each orchestration step instead of its built-in loop.
await client.send(new UpdateAgentCommand({
agentId: "YOURAGENTID",
// ... other fields
promptOverrideConfiguration: {
overrideLambda: "arn:aws:lambda:us-east-1:123456789012:function:custom-orchestrator",
promptConfigurations: [
{
promptType: "ORCHESTRATION",
promptCreationMode: "OVERRIDDEN",
promptState: "ENABLED",
basePromptTemplate: "$instructions$ $tools$"
}
]
}
}));
Custom orchestration Lambdas have full control over the tool-decision loop. They can invoke external tools directly, make their own model calls, consult a live MCP server registry for available tools, or implement deterministic routing without using a foundation model for decisions. For MCP server platforms with complex routing requirements that change frequently, a custom orchestration Lambda can be the right architectural choice — the routing logic lives in Lambda code rather than a prompt template.
Change management and alias traffic splitting
Changing a prompt override requires updating the DRAFT version, re-preparing, and publishing a new agent version. For production systems, use alias routing to control the rollout. A Bedrock Agents alias can route traffic across two versions with configurable weights — route 10% to the new prompt configuration, monitor invocation errors and human feedback signals in CloudWatch, then increase the percentage as confidence grows:
await client.send(new UpdateAgentAliasCommand({
agentId: "YOURAGENTID",
agentAliasId: "YOURAGENTALIASID",
agentAliasName: "prod",
routingConfiguration: [
{ agentVersion: "5", provisionedThroughput: undefined },
// A/B: 90% traffic to v4, 10% to v5 (weights sum to 1.0)
// This is set via the console or routingConfiguration weight field
]
}));
// Full cutover when confidence is high
await client.send(new UpdateAgentAliasCommand({
agentId: "YOURAGENTID",
agentAliasId: "YOURAGENTALIASID",
agentAliasName: "prod",
routingConfiguration: [{ agentVersion: "5" }]
}));
// Instant rollback if needed
await client.send(new UpdateAgentAliasCommand({
agentId: "YOURAGENTID",
agentAliasId: "YOURAGENTALIASID",
agentAliasName: "prod",
routingConfiguration: [{ agentVersion: "4" }]
}));
Alias routing updates are instant with no downtime. The alias switch is the deployment primitive — keep at least the two most recent versions available so rollback is always one API call away.
See the full Prompt Override guide for the complete stage-by-stage reference, the parser Lambda pattern for custom response parsing, and the interaction between KNOWLEDGE_BASE_RESPONSE_GENERATION overrides and standard knowledge base nodes.
How the four capabilities compose into a production platform
Multi-agent orchestration, memory, return control, and prompt override are independent features — each can be used without the others. But they also compose cleanly into a layered architecture that addresses the full set of production requirements for an MCP server platform.
A production Bedrock-backed MCP platform might look like this:
- SUPERVISOR_ROUTER agent as the entry point — routes intent to specialized collaborator agents. Each collaborator corresponds to a cluster of related MCP servers (database tools, file system tools, communication tools). The supervisor never executes tools itself; its sole job is intent classification and routing.
- RETURN_CONTROL action groups in each collaborator — no Lambda cold starts, in-process MCP server routing, dynamic tool registration as MCP servers connect and disconnect. The tool registry is rebuilt when the MCP server set changes; Bedrock action group schemas are updated to match.
- SESSION_SUMMARY memory on the supervisor — user preferences, completed tasks, and context flow forward across sessions. The supervisor's memory is queried at the start of each new conversation. Collaborators handle stateless execution; the supervisor maintains the user model.
- PRE_PROCESSING override on the supervisor — platform policy enforcement before the orchestration model sees any request. Topic restrictions, permission checks, and user-context injection all happen in the pre-processing stage without touching the orchestration prompt.
- Guardrails on all agents — PII detection, profanity filtering, and topic denial at the service layer, independent of any prompt configuration. These apply uniformly across all agents in the fleet regardless of individual prompt override configurations.
The $memory_content$ placeholder wires memory into the orchestration prompt. The IAM bedrock:InvokeAgent permission on alias ARNs wires multi-agent routing into the supervisor's execution role. The endSession: true pattern wires the conversation lifecycle into the memory summarization trigger. Each feature has its own setup requirement, but the runtime behaviors compose without conflict.
Common failures across all four features
| Feature | Symptom | Root cause | Fix |
|---|---|---|---|
| Multi-agent | Supervisor never routes to collaborators; handles all requests itself | aliasArn in agentDescriptor is an agent ARN, not alias ARN |
Use format arn:aws:bedrock:{region}:{account}:agent-alias/{agentId}/{aliasId} |
| Multi-agent | AccessDeniedException in trace on collaborator delegation |
Supervisor execution role lacks bedrock:InvokeAgent on collaborator aliases |
Add bedrock:InvokeAgent on arn:aws:bedrock:{region}:{account}:agent-alias/{agentId}/* |
| Memory | Cross-session memory never carries forward; each session starts blank | memoryId omitted from invocations; Bedrock uses sessionId as memory key |
Always pass explicit memoryId derived from stable user identity |
| Memory | Memory configured; summaries stored; agent never uses them | Orchestration prompt override missing $memory_content$ |
Add $memory_content$ placeholder to orchestration template |
| Return Control | Error on re-invocation with tool results | Partial tool results submitted — not all invocationInputs entries covered |
Promise.all() all tool executions before submitting results; always include an error result for failed tools |
| Prompt Override | Agent cannot call tools after orchestration override is applied | $tools$ placeholder missing from orchestration template |
Include all five required placeholders in every orchestration template |
| Prompt Override | PRE_PROCESSING override allows all requests regardless of logic | Response XML malformed — wrong namespace or tag names | Use exact format: <amazon:pre_processing_response xmlns:amazon="http://www.amazon.com/bedrock/agents"> with matching close tags |
Monitoring multi-agent and memory deployments with AliveMCP
Multi-agent systems multiply the number of Bedrock Agents endpoints in play. Each collaborator agent has its own alias ARN, its own quota consumption profile, and its own failure surface. A collaborator that is temporarily unavailable or quota-throttled degrades the supervisor's routing silently — from the caller's perspective, the supervisor simply returns a low-quality response or an error without indicating which sub-system failed.
Instrument each collaborator alias as a separate monitored endpoint. Watch for ServiceQuotaExceededException from parallel invocations — multi-agent collaboration multiplies TPS against your Bedrock Agents quota when the supervisor routes to multiple collaborators simultaneously. Enable enableTrace: true in development and log agentCollaboratorInvocationOutput trace events to understand which collaborator was selected for each request; this is the fastest way to diagnose routing misconfigurations.
Memory adds another failure surface: if the memory configuration is correct but the agent is not using stored summaries, the most likely cause is the missing $memory_content$ placeholder. Use GetAgentMemoryCommand to verify that summaries are being stored after sessions end — if summaries exist but are not surfacing in agent behavior, the placeholder is missing from the orchestration template.
AliveMCP provides uptime monitoring and health checks for MCP server infrastructure. As your MCP platform grows from a single Bedrock Agent to a multi-agent fleet with per-user memory and in-process tool routing, the ability to know which components are live and which are degraded becomes more valuable — not less.