Skip to content

Bedrock Inline Agent

Overview

The Bedrock Inline Agent represents a powerful new approach to dynamic agent creation. At its core, it leverages Amazon Bedrock’s Converse API and its tool capabilities to interact with foundation models and orchestrate agent creation. Through a specialized tool, it intelligently analyzes user requests and selects the most relevant action groups and knowledge bases from your available resources.

Once the optimal Action Groups and/or Knowledge Bases are identified, the agent uses the InvokeInlineAgent API to dynamically create purpose-specific Agents for Amazon Bedrock. This eliminates the need to pre-configure static agent combinations - instead, agents are created on-demand with precisely the capabilities needed for each specific request.

This architecture removes practical limits on the number of action groups and knowledge bases you can maintain. Whether you have dozens or hundreds of different action groups and knowledge bases, the agent can efficiently select and combine just the ones needed for each query. This enables sophisticated use cases that would be impractical with traditional static agent configurations.

Key Features

  • Dynamic agent creation through InvokeInlineAgent API
  • Tool-based selection of action groups and knowledge bases
  • Support for multiple foundation models
  • Customizable inference configuration
  • Enhanced debug logging capabilities
  • Support for custom logging implementations

Creating a BedrockInlineAgent

Basic Example

import { BedrockInlineAgent } from 'multi-agent-orchestrator';
import { CustomLogger } from './logger';
const actionGroups = [
{
actionGroupName: "OrderManagement",
description: "Handles order-related operations like status checks and updates"
},
{
actionGroupName: "InventoryLookup",
description: "Checks product availability and stock levels"
}
];
const knowledgeBases = [
{
knowledgeBaseId: "KB001",
description: "Product catalog and specifications"
}
];
const agent = new BedrockInlineAgent({
name: 'Inline Agent Creator for Agents for Amazon Bedrock',
description: 'Specialized in creating Agent to solve customer request dynamically. You are provided with a list of Action groups and Knowledge bases which can help you in answering customer request',
actionGroupsList: actionGroups,
knowledgeBases: knowledgeBases,
region: "us-east-1",
LOG_AGENT_DEBUG_TRACE: true,
inferenceConfig: {
maxTokens: 500,
temperature: 0.5,
topP: 0.9
}
});

Debug Logging

LOG_AGENT_DEBUG_TRACE

When enabled, this flag activates detailed debug logging that helps you understand the agent’s operation. Example output:

> BedrockInlineAgent
> Inline Agent Creator for Agents for Amazon Bedrock
> System Prompt
> You are a Inline Agent Creator for Agents for Amazon Bedrock...
> BedrockInlineAgent
> Inline Agent Creator for Agents for Amazon Bedrock
> Tool Handler Parameters
> {
userRequest: 'Please execute...',
actionGroupNames: ['CodeInterpreterAction'],
knowledgeBases: [],
description: 'To solve this request...',
sessionId: 'session-456'
}
> BedrockInlineAgent
> Inline Agent Creator for Agents for Amazon Bedrock
> Action Group & Knowledge Base
> {
actionGroups: [
{
actionGroupName: 'CodeInterpreterAction',
parentActionGroupSignature: 'AMAZON.CodeInterpreter'
}
],
knowledgeBases: []
}

Custom Logger Implementation

You can provide your own logger implementation to customize log formatting and handling. Here’s an example:

export class CustomLogger {
private static instance: CustomLogger;
private constructor() {}
static getInstance(): CustomLogger {
if (!CustomLogger.instance) {
CustomLogger.instance = new CustomLogger();
}
return CustomLogger.instance;
}
info(message: string, ...args: any[]): void {
console.info(">>: " + message, ...args);
}
warn(message: string, ...args: any[]): void {
console.warn(">>: " + message, ...args);
}
error(message: string, ...args: any[]): void {
console.error(">>: " + message, ...args);
}
debug(message: string, ...args: any[]): void {
console.debug(">>: " + message, ...args);
}
log(message: string, ...args: any[]): void {
console.log(">>: " + message, ...args);
}
}

Sample Code

You can find sample code for using the BedrockInlineAgent in both TypeScript and Python:

The BedrockInlineAgent represents a significant advancement in agent flexibility and efficiency, enabling truly dynamic, context-aware responses while optimizing resource usage.