Agent
Source:
src/AWS/Bedrock/Agent.ts
An Amazon Bedrock agent — a foundation model driven by natural-language instructions that can orchestrate multi-step tasks.
Agent owns the lifecycle of the agent’s DRAFT version. An IAM execution
role is created automatically (trusted by bedrock.amazonaws.com, granted
bedrock:InvokeModel on the foundation model) unless an explicit
agentResourceRoleArn is supplied. After every create/update the agent is
prepared (unless prepare: false) so it is immediately invocable and can
back an AgentAlias.
Creating Agents
Section titled “Creating Agents”Minimal Agent
import * as Bedrock from "alchemy/AWS/Bedrock";
const agent = yield* Bedrock.Agent("assistant", { foundationModel: "us.anthropic.claude-3-5-sonnet-20240620-v1:0", instruction: "You are a helpful assistant that answers questions concisely.",});Agent with a Guardrail and Custom Session TTL
const agent = yield* Bedrock.Agent("assistant", { foundationModel: "us.anthropic.claude-3-5-sonnet-20240620-v1:0", instruction: "You are a careful, policy-compliant support agent.", idleSessionTTL: "30 minutes", guardrailConfiguration: { guardrailIdentifier: guardrail.guardrailId, guardrailVersion: "DRAFT", },});Agent with Long-Term Memory
// Session summaries are retained for 30 days and readable at runtime// through the GetAgentMemory binding.const agent = yield* Bedrock.Agent("assistant", { foundationModel: "us.anthropic.claude-3-5-sonnet-20240620-v1:0", instruction: "You are a helpful assistant that remembers past sessions.", memoryConfiguration: { enabledMemoryTypes: ["SESSION_SUMMARY"], storage: "30 days", },});