TypeScript版Strands AgentsをAmazon Bedrock AgentCoreにデプロイしてみた
はじめに
前回TypeScript版StrandsAgentsを使用したブログを書きました。
アップデートのアナウンス内で以下の記載がありましたので、早速CDKを使用してAgentCoreにデプロイしてみました。
TypeScript support in Strands has been designed to provide an idiomatic TypeScript experience with full type safety, async/await support, and modern JavaScript/TypeScript patterns. Strands can be easily run in client applications, in browsers, and server-side applications in runtimes like AWS Lambda and Bedrock AgentCore. Developers can also build their entire stack in Typescript using the AWS CDK.
https://aws.amazon.com/jp/about-aws/whats-new/2025/12/typescript-strands-agents-preview/
やってみる
前提条件
- Node.js: v24.11.1
- Bun: 1.3.3
- Docker: 28.3.3
今回作成したコードはこちらにありますので、適宜詳細をご確認ください。
CDK & Agentの作成
以下のブログを参考にCDKのL2コンストラクトを使用してAgentCore Runtimeの設定を行います。
実際に作成した内容は以下の通りです。
import * as cdk from 'aws-cdk-lib/core';
import * as iam from 'aws-cdk-lib/aws-iam';
import { Construct } from 'constructs';
import * as path from "path";
import * as agentcore from "@aws-cdk/aws-bedrock-agentcore-alpha";
export class AgentcoreStrandsTsStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromAsset(
path.join(__dirname, "../agent"),
);
const runtime = new agentcore.Runtime(this, "StrandsAgentsRuntime", {
runtimeName: "StrandsAgentsTS",
agentRuntimeArtifact: agentRuntimeArtifact,
description: "Strands Agents for TypeScript",
});
runtime.addToRolePolicy(
new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream",
],
resources: [
"arn:aws:bedrock:*::foundation-model/*",
`arn:aws:bedrock:${this.region}:${this.account}:inference-profile/*`,
],
}),
);
new cdk.CfnOutput(this, "RuntimeArn", {
value: runtime.agentRuntimeArn,
description: "ARN of the AgentCore Runtime",
exportName: "AgentRuntimeArn",
});
new cdk.CfnOutput(this, "RuntimeId", {
value: runtime.agentRuntimeId,
description: "ID of the AgentCore Runtime",
exportName: "AgentRuntimeId",
});
}
}
#!/usr/bin/env node
import * as cdk from 'aws-cdk-lib/core';
import { AgentcoreStrandsTsStack } from '../lib/agentcore-strands-ts-stack';
const app = new cdk.App();
new AgentcoreStrandsTsStack(app, 'AgentcoreStrandsTsStack', {
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: 'us-east-1',
},
});
続けて、Agentを作成します。
今回はこちらのサンプルを参考に微修正しています。
import { Agent, BedrockModel, tool } from '@strands-agents/sdk'
import type { Request, Response } from 'express'
import express from 'express'
import { z } from 'zod'
const PORT = process.env.PORT || 8080
const weatherTool = tool({
name: 'get_weather',
description: 'Get the current weather for a specific location.',
inputSchema: z.object({
location: z.string().describe('The city and state, e.g., San Francisco, CA'),
}),
callback: (input) => {
const fakeWeatherData = {
temperature: '72°F',
conditions: 'sunny',
}
return `The weather in ${input.location} is ${fakeWeatherData.temperature} and ${fakeWeatherData.conditions}.`
},
})
async function runInvoke(title: string, agent: Agent, prompt: string) {
console.log(`--- ${title} ---`)
console.log(`User: ${prompt}`)
const result = await agent.invoke(prompt)
console.log(`\nInvocation complete; stop reason was ${result.stopReason}\n`)
return result
}
async function runStreaming(title: string, agent: Agent, prompt: string) {
console.log(`--- ${title} ---`)
console.log(`User: ${prompt}`)
console.log('Agent response stream:')
for await (const event of agent.stream(prompt)) {
console.log('[Event]', event.type)
}
console.log('\nStreaming complete.\n')
}
const model = new BedrockModel({ region: 'us-east-1' })
const defaultAgent = new Agent()
const agentWithoutTools = new Agent({ model })
const agentWithTools = new Agent({
systemPrompt:
'You are a helpful assistant that provides weather information using the get_weather tool. Always Inform the user if you run tools.',
model,
tools: [weatherTool],
})
const app = express()
app.get('/ping', (_req: Request, res: Response) =>
res.json({
status: 'Healthy',
time_of_last_update: Math.floor(Date.now() / 1000),
})
)
app.post('/invocations', express.raw({ type: '*/*' }), async (req: Request, res: Response) => {
try {
const prompt = new TextDecoder().decode(req.body)
console.log(`Received prompt: ${prompt}`)
const result = await agentWithTools.invoke(prompt)
console.log(`Response stopReason: ${result.stopReason}`)
return res.json({ response: result })
} catch (err) {
console.error('Error processing request:', err)
return res.status(500).json({ error: 'Internal server error' })
}
})
app.listen(PORT, () => {
console.log(`AgentCore Runtime server listening on port ${PORT}`)
})
export { runInvoke, runStreaming, defaultAgent, agentWithoutTools, agentWithTools }
今回は諸事情によりnpmが使えないので、代わりにBunを使用します。
以下の内容でDockerfileを作成します。
FROM oven/bun:latest
WORKDIR /app
# Copy source code
COPY . ./
# Install dependencies
RUN bun install
# Build TypeScript
RUN bun run build
# Expose port
EXPOSE 8080
# Start the application
CMD ["bun", "run", "start"]
事前準備はここまでです。(package.json等の内容はGitHubをご確認ください。)
デプロイ
各種パッケージをインストールし、CDKをデプロイします。
bun install
cd agent && bun install
bunx cdk deploy
無事デプロイが完了したようです!
✅ AgentcoreStrandsTsStack
✨ Deployment time: 66.16s
Outputs:
AgentcoreStrandsTsStack.RuntimeArn = arn:aws:bedrock-agentcore:us-east-1:123456789012:runtime/StrandsAgentsTS-XXXXXXX
AgentcoreStrandsTsStack.RuntimeId = StrandsAgentsTS-XXXXXXX
Stack ARN:
arn:aws:cloudformation:us-east-1:123456789012:stack/AgentcoreStrandsTsStack/5fdc3490-d0aa-11f0-a748-12ab6b40db63
✨ Total time: 69.73s
動作確認
マネジメントコンソールのエージェントサンドボックスから動作確認をしてみます。

なんとか動いたようです!!!
まとめ
今回はStrands AgentsのTypeScript版がプレビューされた記念にAmazon Bedrock AgentCoreにデプロイしてみました。
これからAmazon Bedrock AgentCoreも含め色々検証していきたいと思います。
どなたかの参考になれば幸いです。








