AWS Builder Center

Build a stock ticker research agent with AgentCore Web Search and Code Interpreter tools

How to build a managed agent that researches a stock ticker: recent news, analysis, live prices, and DynamoDB persistence

What I build

Given a stock ticker, the agent does ad-hoc research: it searches the web for recent news, synthesizes sentiment and key facts, fetches the current price and its variations (1 day, 30 days, 1 year), explains what moved the price that day, persists the result to  Amazon DynamoDB , and returns a structured JSON report to the caller.
I build it as an  Amazon Bedrock AgentCore  harness, a managed agent loop. You declare the model, system prompt, tools, and memory as configuration, and AgentCore runs the loop (planning, tool calls, reasoning, response). No orchestration code, no container to build.


The two AgentCore tools this uses

A harness tool is a managed capability the agent can call during its loop. This agent leans on two of them.
Web Search is a fully managed, MCP-compatible web search backed by an AWS-operated web index. Results carry titles, URLs, snippets, and publication dates, and the queries stay inside AWS (no third-party search API, no keys to manage). It is brand new: AWS made the  Web Search tool  generally available in June 2026, exposed as a Gateway connector. That recency is exactly why I create it through the  bedrock-agentcore-control  API instead of the  agentcorec CLI, which does not surface the connector yet (see Step 4). It is available only in  us-east-1  today.
Code Interpreter is a managed sandbox that runs code (Python here) in an isolated environment, so the model can compute over data and call external services. By design the  Code Interpreter tool  default sandbox has no outbound internet and no AWS credentials. This agent needs both —  yfinance  for prices and  boto3  for DynamoDB — so it uses a custom Code Interpreter that grants them (Step 5).
Everything else — the model (GLM 5) and the system prompt — is configuration, not code.

Two ways to build on AgentCore (same CLI)

  • Managed harness. You declare the agent in config and AgentCore runs the loop. Fastest path, no framework, no orchestration code. Changing the model or prompt is a config change, not a redeploy.
  • Code-based agent. You write the loop with a framework (Strands recommended, or LangChain/LangGraph, and others) and deploy it to AgentCore Runtime. Full control.
I chose the harness. The main reason: the thing I iterate on most is the system prompt, which in a harness is pure config (a versioned  .md  file). No rebuilds, which is ideal for a GitOps loop: prompt in git, PR review,  UpdateHarness  or a new version, an eval gate, promote the endpoint, and roll back by version.

Prerequisites (versions matter)

Tool
Minimum
Why
AWS CLI v2
2.28+ (use latest)
The  bedrock-agentcore-control  service (for  create-gateway  /  create-gateway-target , including the Web Search connector) was added in the v2 2.28 series. Older versions (for example 2.26.x) return  Invalid choice: bedrock-agentcore-control .
AgentCore CLI ( @aws/agentcore )
0.21.1+
Harness  create  /  add tool  /  deploy . npm package, needs Node.js 20+.
Node.js
20+
Runtime for the AgentCore CLI.
Python
3.10+
Agent and tool code.

Install the AgentCore CLI

npm install -g @aws/agentcore
agentcore --version
There are two AgentCore CLIs. The one used here is  @aws/agentcore  (npm, the recommended one for the harness). An older Python starter toolkit ( bedrock-agentcore-starter-toolkit , pip) also installs an  agentcore  binary. If both are present, the npm install can fail with  EEXIST  on  /usr/local/bin/agentcore . Uninstall the pip one ( pip uninstall bedrock-agentcore-starter-toolkit ) or install with  npm install -g @aws/agentcore --force .

Step 1: Create the harness project

agentcore create \
--project-name tickerharness \
--name tickernewsagent \
--defaults \
--model-provider Bedrock \
--model-id zai.glm-5 \
--skip-git
About the two model flags:
  •  --model-provider  accepts  Bedrock ,  Anthropic ,  OpenAI , or  Gemini . Non-Bedrock providers also need an API key ( --api-key , stored in  .env.local ). This walkthrough uses  Bedrock , so no key is required.
  •  --model-id zai.glm-5  is the Amazon Bedrock model ID for GLM 5, the frontier LLM from Z.ai (Zhipu AI) offered on Bedrock. The  zai.  prefix is the Bedrock provider namespace. Swap this for any model ID your chosen provider supports (for example an Anthropic Claude or an OpenAI model with the matching  --model-provider ).
This scaffolds  agentcore/  (project config plus CDK infra) and  app/tickernewsagent/  ( harness.json  and  system-prompt.md ), and installs the CDK toolchain so  deploy  works later without extra steps. Note that the system prompt lives in its own  .md  file. That is the GitOps-friendly seam.
 agentcore create  leaves you outside the new project directory (it prints a  cd tickerharness  hint at the end). Every command from here on ( add tool ,  deploy ,  status ,  invoke ) must run from inside the project, so change into it now:
cd tickerharness

Set the deployment target Region (important)

 agentcore create  writes the deployment target to  agentcore/aws-targets.json , and it picks the Region from your AWS CLI default. If your default is not  us-east-1  (or it resolves to empty), the harness would deploy to the wrong Region — while the Web Search connector (only in  us-east-1 ) and every  aws  command below stay in  us-east-1 . Note that  agentcore create --region  does not fix this: that flag only applies to  --type import .
So set the target explicitly to  us-east-1  (deterministic, no dependency on your CLI default). This overwrites  aws-targets.json  with a single  default  target:
# from tickerharness/
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
cat > agentcore/aws-targets.json <<EOF
[
{
"name": "default",
"account": "${ACCOUNT_ID}",
"region": "us-east-1"
}
]
EOF
Confirm it before continuing:
agentcore status # must report: target: default, us-east-1

Step 2: Write the system prompt

 agentcore create  scaffolds a placeholder  app/tickernewsagent/system-prompt.md . The harness reads this file by convention. Because the harness has no place to ship your own Python, I embed the exact yfinance and boto3 snippets in the prompt as "run exactly this" blocks that the model passes to the Code Interpreter. The prompt also defines the output contract, citation rules, the mandatory disclaimer, and a  priceMoveSummary  field (what moved the price on the day).
The file lives at  app/tickernewsagent/system-prompt.md , relative to the project root. Assuming you are in  tickerharness/  (from Step 1), open it in your editor of choice:
# from tickerharness/
nano app/tickernewsagent/system-prompt.md
# or: vim app/tickernewsagent/system-prompt.md
# or, in VS Code: code app/tickernewsagent/system-prompt.md
Replace the file contents with this:
# Role

You are an expert **financial research analyst**. Given a stock **ticker** (or a company
name, from which you infer the symbol), you perform **ad-hoc research**: gather recent
news from multiple sources, synthesize it, fetch the current price and its variations,
**persist** the result to DynamoDB, and **return** a structured report to the caller.

You do not give investment advice. You always include the mandatory disclaimer.

# Input

The user gives you a **ticker** (e.g. `AMZN`) or a company name. Normalize the symbol to
uppercase. If ambiguous, pick the most likely one and state which you chose.

# Workflow (run these in order)

## 1. News research

Use the **web search** tool to find recent news about the ticker (last 3-5 days) from
**multiple sources**. Prioritize recency. For each result keep `title`, `url`, and
`publishedDate`.

Then synthesize:
- **sentiment**: `Positive` | `Neutral` | `Negative`, with a one-sentence rationale.
- **keyPoints**: 2-4 bullets of key facts (avoid unsupported opinion).
- **catalysts**: catalysts if present (earnings, guidance, regulation, M&A, product).
- **priceMoveSummary**: 1-2 sentences explaining what most likely moved the price
**on the day**, tying the day's % change (`changePct1d`) to specific news or
catalysts you found. If no single clear driver, say so (e.g. "broad market move,
no stock-specific catalyst").
- **sources**: the list of sources you used.

Cite every claim with `[N]` linking to the source URL. If there is no recent news,
state it explicitly and continue with the price.

## 2. Price and variations (yfinance)

Use the **code_interpreter** tool to run **exactly** this Python (replace `TICKER` with
the real symbol):

```python
import subprocess, sys, json
subprocess.run([sys.executable, "-m", "pip", "install", "-q", "yfinance"], check=True)
import yfinance as yf

TICKER = "AMZN" # <-- replace with the requested ticker
t = yf.Ticker(TICKER)
fi = t.fast_info
price = float(fi["last_price"])
prev = float(fi["previous_close"])
h30 = t.history(period="1mo")["Close"]
h1y = t.history(period="1y")["Close"]

price_data = {
"value": round(price, 4),
"currency": fi.get("currency", "USD"),
"changePct1d": round((price - prev) / prev * 100, 2),
"changePct30d": round((h30.iloc[-1] - h30.iloc[0]) / h30.iloc[0] * 100, 2),
"changePct1y": round((h1y.iloc[-1] - h1y.iloc[0]) / h1y.iloc[0] * 100, 2),
}
print(json.dumps(price_data))
```

Use the printed `price_data` as the source of truth for the price. If yfinance fails for
a field, set it to `null` and state it.

## 3. Persist to DynamoDB

Use **code_interpreter** to run **exactly** this Python. Fill the analysis variables
(`SENTIMENT`, `SUMMARY`, `KEY_POINTS`, `CATALYSTS`, `PRICE_MOVE_SUMMARY`, `SOURCES`) with
what you produced in step 1, and reuse `TICKER` and `price_data` from step 2:

```python
import json, datetime, boto3
from decimal import Decimal

item = {
"ticker": TICKER,
"researchedAt": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
"price": price_data["value"],
"currency": price_data["currency"],
"changePct1d": price_data["changePct1d"],
"changePct30d": price_data["changePct30d"],
"changePct1y": price_data["changePct1y"],
"sentiment": SENTIMENT, # "Positive" | "Neutral" | "Negative"
"summary": SUMMARY, # str
"keyPoints": KEY_POINTS, # list[str]
"catalysts": CATALYSTS, # list[str]
"priceMoveSummary": PRICE_MOVE_SUMMARY, # str: what moved the price today
"sources": SOURCES, # list[{"title","url","publishedDate"}]
}

# DynamoDB does not accept float: parse_float=Decimal converts it.
boto3.resource("dynamodb", region_name="us-east-1").Table("TickerResearch").put_item(
Item=json.loads(json.dumps(item), parse_float=Decimal)
)
print("PutItem OK")
```

Confirm that `PutItem OK` was printed before continuing.

## 4. Respond to the caller

Return **only** this JSON (no extra text), consistent with what was persisted:

```json
{
"ticker": "AMZN",
"researchedAt": "2026-07-01T21:30:00Z",
"price": {
"value": 231.45,
"currency": "USD",
"changePct1d": 1.24,
"changePct30d": -3.10,
"changePct1y": 18.7
},
"news": {
"sentiment": "Positive",
"summary": "…",
"keyPoints": ["…"],
"catalysts": ["…"],
"priceMoveSummary": "One or two sentences on what moved the price today, tied to changePct1d.",
"sources": [{"title": "…", "url": "…", "publishedDate": "YYYY-MM-DD"}]
},
"persisted": { "table": "TickerResearch", "status": "OK" },
"disclaimer": "This analysis is for informational purposes only and does not constitute financial or investment advice, nor a recommendation to buy or sell securities. Consult a professional advisor before making investment decisions."
}
```

# Rules

- Do **not** give investment advice; the `disclaimer` is mandatory.
- Cite **every** news claim with its source.
- If a value is unavailable, use `null` and state it; do not fabricate.
- Handle ticker ambiguity using context from the news.
- yfinance prices can be delayed (~15 min) and are unofficial; do not present them as strict real-time.
This is the lowest-friction path. As the procedure grows, extract it into an Agent Skill (a  SKILL.md  plus a  scripts/  bundle) hosted on S3 or Git, which is more deterministic and reusable. See "From prompt to skill" below.
The prompt references two tools by name — web search and code_interpreter. You wire them up next: the web search Gateway in Step 4, and a custom Code Interpreter (with internet and AWS access) in Step 5.

Step 3: Create the DynamoDB table

aws dynamodb create-table \
--table-name TickerResearch \
--attribute-definitions \
AttributeName=ticker,AttributeType=S \
AttributeName=researchedAt,AttributeType=S \
--key-schema \
AttributeName=ticker,KeyType=HASH \
AttributeName=researchedAt,KeyType=RANGE \
--billing-mode PAY_PER_REQUEST \
--region us-east-1
The table is external to the harness by design: the agent writes to it, it does not create it.

Step 4: Web Search via a Gateway connector

 AgentCore Web Search  is a managed, MCP-compatible search over an AWS-owned web index (results with titles, URLs, snippets, and dates; queries stay inside AWS). It is exposed as a Gateway connector. The console shows it under Add target -> Connectors -> Web Search tool, but the  agentcore  CLI (0.21.1) does not expose the  web-search  connector, so I create it with the API and then attach the gateway.
Region note: the Web Search Tool connector is currently available only in US East (N. Virginia),  us-east-1 . That is why this whole walkthrough runs in  us-east-1 . If you deploy the gateway in another Region, the  web-search  connector target will not be available. ( AWS docs )
Placeholders vs. shell variables: angle-bracket tokens like  <ACCOUNT_ID>  are placeholders — never paste them literally. In  zsh / bash ,  <ACCOUNT_ID>  is read as input redirection from a file named  ACCOUNT_ID , which fails with  no such file or directory: ACCOUNT_ID . To avoid this, the commands below use the shell variables you capture as you go ( $ACCOUNT_ID ,  $GATEWAY_ID ,  $TARGET_ID ). These live only in the current terminal session — if you open a new terminal, re-run the  ACCOUNT_ID=...  capture from Step 4.1 first.

4.1 Gateway service role

The gateway needs an execution role it can assume, with permission to invoke the gateway and the web search tool. Create the two policy files in the project root ( tickerharness/ ) with the heredocs below — each one prints the file's contents and substitutes your account ID automatically. Run each block on its own.
First, capture your AWS account ID into a shell variable (reused across this step):
# from tickerharness/
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
echo "$ACCOUNT_ID"
Create  gateway-trust.json :
cat > gateway-trust.json <<EOF
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "AllowAgentCoreToAssumeRole",
"Effect": "Allow",
"Principal": { "Service": "bedrock-agentcore.amazonaws.com" },
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": { "aws:SourceAccount": "${ACCOUNT_ID}" },
"ArnLike": { "aws:SourceArn": "arn:aws:bedrock-agentcore:us-east-1:${ACCOUNT_ID}:gateway/*" }
}
}]
}
EOF
Create  gateway-websearch-policy.json :
cat > gateway-websearch-policy.json <<EOF
{
"Version": "2012-10-17",
"Statement": [
{ "Sid": "InvokeGateway", "Effect": "Allow",
"Action": "bedrock-agentcore:InvokeGateway",
"Resource": "arn:aws:bedrock-agentcore:us-east-1:${ACCOUNT_ID}:gateway/*" },
{ "Sid": "InvokeWebSearch", "Effect": "Allow",
"Action": "bedrock-agentcore:InvokeWebSearch",
"Resource": "arn:aws:bedrock-agentcore:us-east-1:aws:tool/web-search.v1" }
]
}
EOF
Create the role with the trust policy:
aws iam create-role --role-name TickerGatewayWebSearchRole \
--assume-role-policy-document file://gateway-trust.json
Attach the inline permissions policy:
aws iam put-role-policy --role-name TickerGatewayWebSearchRole \
--policy-name WebSearchInvoke --policy-document file://gateway-websearch-policy.json

4.2 Create the gateway (MCP, inbound AWS_IAM)

Create the gateway and capture its ID into  $GATEWAY_ID  for the next steps:
GATEWAY_ID=$(aws bedrock-agentcore-control create-gateway \
--name ticker-websearch-gw \
--role-arn "arn:aws:iam::${ACCOUNT_ID}:role/TickerGatewayWebSearchRole" \
--protocol-type MCP \
--authorizer-type AWS_IAM \
--region us-east-1 \
--query gatewayId --output text)
echo "$GATEWAY_ID"
 AWS_IAM  inbound auth lets the harness call the gateway with SigV4 (no OAuth setup).

4.3 Add the Web Search connector target

TARGET_ID=$(aws bedrock-agentcore-control create-gateway-target \
--gateway-identifier "$GATEWAY_ID" \
--name web-search-tool \
--target-configuration '{
"mcp": { "connector": {
"source": { "connectorId": "web-search" },
"configurations": [ { "name": "WebSearch", "parameterValues": {} } ]
}}
}' \
--credential-provider-configurations '[{"credentialProviderType":"GATEWAY_IAM_ROLE"}]' \
--region us-east-1 \
--query targetId --output text)
echo "$TARGET_ID"
Poll until the target is  READY :
aws bedrock-agentcore-control list-gateway-targets \
--gateway-identifier "$GATEWAY_ID" --region us-east-1 \
--query 'items[].{name:name,status:status}' --output table

4.4 Attach the gateway to the harness

agentcore add tool \
--harness tickernewsagent \
--type agentcore_gateway \
--name websearch \
--gateway-arn "arn:aws:bedrock-agentcore:us-east-1:${ACCOUNT_ID}:gateway/${GATEWAY_ID}" \
--outbound-auth awsIam

Step 5: Add a custom Code Interpreter (internet and AWS access)

The agent runs two pieces of Python through the Code Interpreter:  yfinance  (needs the public internet) and a  boto3   PutItem  into DynamoDB (needs AWS credentials). The default managed Code Interpreter can do neither — by design it is an isolated sandbox with no outbound internet and no AWS credentials. That isolation is a sensible default for computing over data the model already has, but here it would make  pip install yfinance  fail with  "The network is restricted"  and  boto3  fail with  "AWS credentials not available" .
The native fix is a custom Code Interpreter.  create-code-interpreter  lets you set exactly the two things this agent needs:
  •  networkMode: PUBLIC  — grants outbound internet, so  yfinance  can reach Yahoo Finance (and you could swap in any other market-data API).
  •  executionRoleArn  with  dynamodb:PutItem  — the sandbox runs with those credentials, so the  boto3   PutItem  succeeds.
One custom Code Interpreter solves both, natively, with no workaround. Note where the DynamoDB permission lives: on the Code Interpreter's execution role, not the harness's. The  boto3  call runs inside the sandbox, so it uses the sandbox's credentials — granting  PutItem  to the harness role would have no effect. This is the detail that trips people up, so we set it correctly from the start.
yfinance is just the price source in this example. Because the PUBLIC Code Interpreter can reach any endpoint, you can swap it for any market-data provider (Alpha Vantage, Polygon, Finnhub, or an internal service) with no change to the architecture.

5.1 Execution role for the Code Interpreter

The role trusts the AgentCore service and grants only  dynamodb:PutItem  on  TickerResearch . Scope the trust  aws:SourceArn  broadly to  arn:aws:bedrock-agentcore:us-east-1:${ACCOUNT_ID}:* : the custom Code Interpreter ARN uses the  code-interpreter-custom/...  segment, and a narrow  code-interpreter/*  condition fails the create-time role validation. yfinance needs no AWS permission; the PUBLIC network handles its egress.
Re-capture  ACCOUNT_ID  if you opened a new terminal:
# from tickerharness/
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
Create  ci-exec-trust.json :
cat > ci-exec-trust.json <<EOF
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "AllowAgentCoreToAssumeRole",
"Effect": "Allow",
"Principal": { "Service": "bedrock-agentcore.amazonaws.com" },
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": { "aws:SourceAccount": "${ACCOUNT_ID}" },
"ArnLike": { "aws:SourceArn": "arn:aws:bedrock-agentcore:us-east-1:${ACCOUNT_ID}:*" }
}
}]
}
EOF
Create  ci-exec-policy.json :
cat > ci-exec-policy.json <<EOF
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "PutTickerResearch",
"Effect": "Allow",
"Action": "dynamodb:PutItem",
"Resource": "arn:aws:dynamodb:us-east-1:${ACCOUNT_ID}:table/TickerResearch"
}]
}
EOF
Create the role with the trust policy:
aws iam create-role --role-name TickerCodeInterpreterRole \
--assume-role-policy-document file://ci-exec-trust.json
Attach the inline permissions policy:
aws iam put-role-policy --role-name TickerCodeInterpreterRole \
--policy-name PutTickerResearch --policy-document file://ci-exec-policy.json

5.2 Create the custom Code Interpreter

Create it with PUBLIC networking and the execution role, and capture its ID into  $CI_ID :
CI_ID=$(aws bedrock-agentcore-control create-code-interpreter \
--name ticker_ci \
--network-configuration '{"networkMode":"PUBLIC"}' \
--execution-role-arn "arn:aws:iam::${ACCOUNT_ID}:role/TickerCodeInterpreterRole" \
--region us-east-1 \
--query codeInterpreterId --output text)
echo "$CI_ID"

5.3 Attach it to the harness

agentcore add tool --harness tickernewsagent \
--type agentcore_code_interpreter --name code_interpreter \
--code-interpreter-arn "arn:aws:bedrock-agentcore:us-east-1:${ACCOUNT_ID}:code-interpreter-custom/${CI_ID}"
The harness now has both tools — the web search Gateway and the custom Code Interpreter — wired to the exact names the system prompt expects ( web search  and  code_interpreter ).

Step 6: Deploy

agentcore deploy --dry-run # preview: synthesize and validate, no AWS changes
agentcore deploy --yes # first run auto-bootstraps CDK, then deploys
agentcore status # shows the harness ARN and status
Deploy creates the harness, its execution role, and CloudWatch logging (and, the first time, the CDK bootstrap stack). Because you attached both tools before deploying, the CDK-created execution role already has everything the harness itself needs:  bedrock:InvokeModel  (GLM 5),  bedrock-agentcore:InvokeGateway  (web search), and permission to invoke the Code Interpreter. There is nothing extra to grant here — the only AWS write,  dynamodb:PutItem , lives on the Code Interpreter's execution role from Step 5, which is where the  boto3  call actually runs.

Step 7: Invoke and verify

Invoke the harness with a ticker:
agentcore invoke --harness tickernewsagent \
--session-id "$(uuidgen)" --stream \
"Research the ticker AMZN"
 --stream  prints the response in real time as the harness produces it (drop it for just the final response, or use  --verbose  to see the full JSON event trace with every tool call). Because the Code Interpreter has PUBLIC networking and an execution role, the traces show  pip install yfinance  succeeding, real price data, and  PutItem OK . The harness returns the structured report:
{
"ticker": "AMZN",
"price": { "value": 241.7, "currency": "USD",
"changePct1d": 1.0, "changePct30d": -5.78, "changePct1y": 9.9 },
"news": {
"sentiment": "Positive",
"priceMoveSummary": "AMZN rose about 1% on the day on continued AWS/AI momentum ...",
"keyPoints": ["..."], "catalysts": ["..."], "sources": [ ... ]
},
"persisted": { "table": "TickerResearch", "status": "OK" },
"disclaimer": "This analysis is for informational purposes only ..."
}
Verify the row landed in DynamoDB. Instead of dumping the full item (with DynamoDB's  {"S": ...}  /  {"N": ...}  type wrappers), project just the fields that matter into a table with  --query :
aws dynamodb query --table-name TickerResearch --region us-east-1 \
--key-condition-expression "ticker = :t" \
--expression-attribute-values '{":t":{"S":"AMZN"}}' \
--query 'Items[0].{ticker:ticker.S, researchedAt:researchedAt.S, price:price.N, changePct1d:changePct1d.N, changePct30d:changePct30d.N, changePct1y:changePct1y.N, sentiment:sentiment.S, priceMoveSummary:priceMoveSummary.S}' \
--output yaml
You get a clean  key: value  summary like this — the key research fields, no JSON noise:
ticker: AMZN
researchedAt: '2026-07-02T21:30:00Z'
price: '241.7'
changePct1d: '1.0'
changePct30d: '-5.78'
changePct1y: '9.9'
sentiment: Positive
priceMoveSummary: AMZN rose about 1% on the day on continued AWS/AI momentum.
Tip: you can add other text fields the same way (e.g.  summary:summary.S ). Keep the projection small so the table stays readable.

Key takeaways

  1. The harness fits prompt-heavy work. Model, prompt, and tools are config, so iterating on the prompt is a config change, not a rebuild. That gives you a GitOps loop for the part that changes most.
  1. Web Search is a managed Gateway connector. It is not exposed in the CLI (0.21.1) yet, so create it with  bedrock-agentcore-control  and attach the gateway ARN.
  1. The default Code Interpreter is isolated (no internet, no AWS credentials). For external APIs and AWS actions, use a custom Code Interpreter with  networkMode: PUBLIC  and an  executionRoleArn . Put the AWS permission ( dynamodb:PutItem ) on the Code Interpreter's execution role, not the harness role — the  boto3  call runs inside the sandbox, so that is where the credentials must be.
  1. Keep data-plane resources external. The DynamoDB table and IAM are yours to provision (IaC); the agent only writes to them.

From prompt to skill (production evolution)

I embedded the yfinance and boto3 code in the prompt because it is fast to iterate. For production, extract it into an Agent Skill: a  SKILL.md  plus a  scripts/  folder with your real code, hosted on S3 ( agentcore add skill --s3 ... ) or Git ( agentcore add skill --git ... ). The agent then runs your fixed script instead of a snippet it copies, which is more deterministic and easier to test and reuse. The CLI does not bundle a local project folder, so the skill must live in S3, Git, or a baked container image.

CI/CD

The harness is CI/CD friendly: declarative config, no container build, a full control-plane API, IaC support (CloudFormation, CDK, Terraform), and versioning plus endpoints for promotion and rollback. For production, use IaC for the stable infra (gateway, table, IAM, base harness) and GitOps for the fast-changing prompt, gated by evaluations before you promote an endpoint.

Cost and cleanup

Web Search is priced per query; the model, Code Interpreter sessions, and DynamoDB are usage-based. Tear everything down when you finish:
# 1. Harness, Runtime, and CDK stack for this project
agentcore destroy --yes

# 2. Gateway target and gateway (web search)
aws bedrock-agentcore-control delete-gateway-target \
--gateway-identifier <GATEWAY_ID> --target-id <TARGET_ID> --region us-east-1
aws bedrock-agentcore-control delete-gateway \
--gateway-identifier <GATEWAY_ID> --region us-east-1

# 3. Custom Code Interpreter
aws bedrock-agentcore-control delete-code-interpreter \
--code-interpreter-id <CI_ID> --region us-east-1

# 4. DynamoDB table
aws dynamodb delete-table --table-name TickerResearch --region us-east-1

# 5. IAM roles and inline policies
aws iam delete-role-policy --role-name TickerGatewayWebSearchRole --policy-name WebSearchInvoke
aws iam delete-role --role-name TickerGatewayWebSearchRole
aws iam delete-role-policy --role-name TickerCodeInterpreterRole --policy-name PutTickerResearch
aws iam delete-role --role-name TickerCodeInterpreterRole
 agentcore destroy  does not remove the resources you created out-of-band via the API (gateway, code interpreter, table, roles), so delete those explicitly as shown above.

Conclusion

With an AgentCore harness I built a real research agent (web search, LLM synthesis, live market data, and durable persistence) with configuration and a prompt, no orchestration code. The design detail that matters: when the agent must reach the internet or call AWS, give it a custom Code Interpreter with PUBLIC networking and an execution role.

Related on Builder Center

Keep going with related topics and tutorials from the builder community:

References and further reading

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article