効かないと思います。
無理やり効かせます。AgentCoreラインタイムになりますが。
手順
まずは無心でAgentCoreハーネスを作ります。クイック作成でOKです。
作成したAgentCoreハーネスの画面で「コードへのエクスポート手順を表示」をクリックします。
親切にエクスポート手順を教えてくれます。
しかしながら、このまま実行できません。(オイ!)
以下の手順で実行ください。
AgentCore CLIをインストール(検証時点でバージョンは0.24.1でした)
npm install -g @aws/agentcore
AgentCoreプロジェクトを作成(この手順が書いてないヨ!)
agentcore create
プロジェクト名(myharnessとしました)を入力します。
「What would you like to build?」は「Skip」を選択しました。
ディレクトリを移動します。
cd myharness
ここから先は先程の手順のとおりです。AgentCoreハーネスをエクスポートします。
agentcore export harness --arn arn:aws:bedrock-agentcore:us-east-1:123456789012:harness/harness_adhn1-V8gQRoqV92
エクスポートできました。
[done] Fetching harness from service
[done] Reading harness configuration
[done] Mapping to Strands template config
[done] Rendering agent code
[done] Updating agentcore.json
[done] Writing EXPORT_NOTES.md
Exported harness arn:aws:bedrock-agentcore:us-east-1:123456789012:harness/harness_adhn1-V8gQRoqV92 → runtime agent harness_adhn1Agent
Generated:
app/harness_adhn1Agent/ Python agent (Strands)
agentcore/agentcore.json updated
No manual follow-up required. (Details: app/harness_adhn1Agent/EXPORT_NOTES.md)
Next steps:
agentcore deploy Deploy the new runtime agent
agentcore dev Run the agent locally
appディレクトリ内にAgentCoreハーネスのコードが作成されています。Python版のStrands Agentsでできています。
Strands Agentsのプロンプトキャッシュ対応のドキュメントはこちらです。(Claudeの場合は簡単にプロンプトキャッシュを有効化できます)
エクスポートされたコードの該当の箇所は、model/load.pyです。改造します。
- from strands.models.bedrock import BedrockModel
+ from strands.models.bedrock import BedrockModel, CacheConfig
def load_model() -> BedrockModel:
"""Get Bedrock model client using IAM credentials."""
- return BedrockModel(model_id="global.anthropic.claude-sonnet-4-6")
+ return BedrockModel(
+ model_id="global.anthropic.claude-sonnet-4-6",
+ cache_tools="default",
+ cache_config=CacheConfig(strategy="auto"),
+ )
できましたので、デプロイします。
残念ながらAgentCoreハーネスにデプロイすることはできないようで、AgentCoreランタイムにデプロイされます。
agentcore deploy
何度か会話をすると無事、キャッシュが効きました~!
AgentCoreハーネスならStep Functionsから呼べる。
AgentCoreランタイムならAgentCoreゲートウェイの後ろに置ける。ということはガードレールがつけられる。
統一してほしすぎる。



