[New Service] Trying Out How Answers Change with a Data Dictionary and Search Instructions in AWS Context #AWSreInvent

[New Service] Trying Out How Answers Change with a Data Dictionary and Search Instructions in AWS Context #AWSreInvent

I tried AWS Context on order data in the Glue Data Catalog. With only abbreviated columns, the agent's assumptions changed between runs; defining business terms in a data dictionary and search instructions produced SQL matching the correct conditions.
2026.12.02

This page has been translated by machine translation. View original

I'm Ishikawa from the Cloud Business Division. AWS Context became generally available on December 1, 2026, so I prepared a small set of order data and tested how an agent's answers change before and after giving it business term definitions.

https://dev.classmethod.jp/articles/20261201-aws-context-is-now-generally-available/

https://aws.amazon.com/about-aws/whats-new/2026/12/aws-context-is-now-generally-available/

AWS Context is a new service that gives agents a shared understanding of the business. It connects to data sources such as AWS Glue Data Catalog, Amazon S3, Amazon Redshift, Amazon Aurora, Amazon RDS, Amazon DynamoDB, SharePoint, Google Drive, Confluence, and Salesforce, and builds a context graph that represents the meaning of terms, how numbers are calculated, and the rules that apply. Agents search this graph through MCP tools, retrieve information from multiple sources, and query data directly.

According to What's New, teams can add data dictionaries, query examples, and retrieval instructions, and curation policies that include human review let you decide which changes agents are allowed to use. Ontologies, learning from agent feedback, and connections to Amazon SageMaker AI / AWS Streaming services / Databricks / Snowflake and others are in preview.

GA is available in three Regions: US East (N. Virginia), US West (Oregon), and Europe (Ireland).

https://docs.aws.amazon.com/context/latest/userguide/what-is-service.html
https://aws.amazon.com/data/context/

What is AWS Context?

AWS Context does not move data out of the source. It indexes the metadata and documents of connected sources to build an Agent Context, and queries the source directly when an answer needs the data itself. Agents use it through MCP tools and APIs.

Main resources

Resource Description
Agent Context The target agents query. Up to 20 can be created per account
Connection A connection to a data source. One Connection can be used by multiple Agent Contexts
Ontology Definitions of entity types, attributes, and relationships. The console showed built-in Data / Enterprise / Business Process
Curation policy Decides whether changes to an Agent Context are applied immediately or held for review

https://docs.aws.amazon.com/context/latest/userguide/what-is-key-resources.html

How agents use it

Usage Description
Agentic retrieval (AgenticRetrieve) Takes a natural language question, repeats graph search/traversal and source queries as needed, and returns an answer with citations
Search and traversal (SearchAgentContext / TraverseAgentContext) Searches for related entities and follows relationships from them
Data query (ExecuteSql, etc.) Queries data sources directly

https://docs.aws.amazon.com/context/latest/userguide/what-is-capabilities.html

Customization

Business knowledge that source metadata alone cannot express is added through Agent Context customization. This time I tried the data dictionary and retrieval instructions.

Customization Description
Ontology association Defines business concepts as classes and relationships
Query examples Pairs of SQL used by analysts and the question each SQL answers. SQL / CSV / JSON / TXT
Data dictionary Business meanings of tables and columns. CSV / JSON / YAML / Markdown, 1 to 10 files, up to 10 MiB total
Retrieval instructions Rules the answering agent reads every time. One per Agent Context, 1 to 2,048 characters

Retrieval instructions apply only to Agentic retrieval answers and do not affect the results of SearchAgentContext and TraverseAgentContext. The default curation policy attached to a new Agent Context holds only changes from trace analysis and ontology grounding for review, so changes to the data dictionary and retrieval instructions are applied immediately.

https://docs.aws.amazon.com/context/latest/userguide/context-customization.html
https://docs.aws.amazon.com/context/latest/userguide/retrieval-instructions.html

Pricing

The pricing page states the following.

Item Price
Graph creation from supported AWS structured data services (Aurora, RDS, DynamoDB, Redshift, Athena, S3, etc.) Free
Storage for graphs created from the above Free
Storage for graphs created from other sources $5 / GB-month
Agentic operations such as search and answers $0.04 / agent-unit
Free tier 3,750 agent-units in the first 30 days (one time)

https://aws.amazon.com/data/context/pricing/

Trying it out

Prerequisites

  • Region: us-east-1 (N. Virginia)
  • Test date: December 2, 2026
  • AWS CLI: 2.43.0
  • The Glue Data Catalog in this account is managed with AWS Lake Formation (the default permissions for new databases do not include IAMAllowedPrincipals). The IAM role used was a data lake administrator

What I tested

To see how AWS Context reflects "the meaning of terms" and "how numbers are calculated" in its answers, I prepared a customer table and an order table with abbreviated column names and status code values. I added no descriptions to the tables or columns.

  • Customer master cst_mst: sts is 1 = in use, 2 = suspended, 3 = withdrawn. tst_flg is 1 = test customer
  • Orders ord_trn: sts is 1 = tentative, 2 = confirmed, 3 = canceled (same column name as the customer sts but a different meaning). amt is the amount before discount, dsc is the discount, rfd is the refund

I fixed the question as "How many active customers were there in November 2026, and what was their net sales in November?" For this test, the correct definitions are as follows.

  • Net sales = amt - dsc - rfd. Only confirmed (sts = 2) orders are counted
  • Active customer = a customer who is in use and not a test customer, and whose total net sales of confirmed November orders is greater than 0 yen

The correct answer under these definitions is 2 active customers and net sales of 19,000 yen. Counting "customers with orders in November" and the sum of amt without thinking about definitions gives 7 customers and 61,999 yen. I also deliberately included a customer whose net sales are 0 yen because of a full refund (K006).

I asked the same question in the following three states and compared.

The setup is as follows. I prepared the data with the CLI and operated AWS Context in the console.

Preparing the data

The two CSVs I prepared are below.

cst_id,cst_nm,sts,tst_flg
K001,佐藤 一郎,1,0
K002,鈴木 花子,1,0
K003,高橋 健太,2,0
K004,田中 美咲,3,0
K005,テスト 太郎,1,1
K006,伊藤 翔,1,0
K007,渡辺 陽菜,1,0
ord_id,cst_id,ord_dt,sts,amt,dsc,rfd
O001,K001,2026-11-01,2,10000,1000,0
O002,K001,2026-11-30,2,5000,0,0
O003,K002,2026-11-15,2,8000,1000,2000
O004,K003,2026-11-10,2,6000,0,0
O005,K004,2026-11-05,2,7000,0,0
O006,K005,2026-11-12,2,9999,0,0
O007,K006,2026-11-20,2,4000,0,4000
O008,K006,2026-11-22,3,3000,0,0
O009,K007,2026-10-31,2,5000,0,0
O010,K007,2026-12-01,2,5000,0,0
O011,K007,2026-11-25,1,6000,0,0
O012,K001,2026-11-18,3,3000,0,0

Create an S3 bucket and upload the CSVs.

% aws s3api create-bucket --bucket ctxdemo-123456789012-use1 --region us-east-1
{
    "Location": "/ctxdemo-123456789012-use1",
    "BucketArn": "arn:aws:s3:::ctxdemo-123456789012-use1"
}

% aws s3 cp data/csv/ s3://ctxdemo-123456789012-use1/ctxdemo_shop/ --recursive
upload: data/csv/cst_mst/cst_mst.csv to s3://ctxdemo-123456789012-use1/ctxdemo_shop/cst_mst/cst_mst.csv
upload: data/csv/ord_trn/ord_trn.csv to s3://ctxdemo-123456789012-use1/ctxdemo_shop/ord_trn/ord_trn.csv

Create the Glue database and tables. The table definition is the following JSON (the ord_trn example). I did not add table or column descriptions (Description / Comment).

{
  "Name": "ord_trn",
  "TableType": "EXTERNAL_TABLE",
  "Parameters": { "classification": "csv", "skip.header.line.count": "1" },
  "StorageDescriptor": {
    "Columns": [
      { "Name": "ord_id", "Type": "string" },
      { "Name": "cst_id", "Type": "string" },
      { "Name": "ord_dt", "Type": "date" },
      { "Name": "sts", "Type": "int" },
      { "Name": "amt", "Type": "int" },
      { "Name": "dsc", "Type": "int" },
      { "Name": "rfd", "Type": "int" }
    ],
    "Location": "s3://ctxdemo-123456789012-use1/ctxdemo_shop/ord_trn/",
    "InputFormat": "org.apache.hadoop.mapred.TextInputFormat",
    "OutputFormat": "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat",
    "SerdeInfo": {
      "SerializationLibrary": "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe",
      "Parameters": { "field.delim": "," }
    }
  }
}
% aws glue create-database --region us-east-1 --database-input Name=ctxdemo_shop

% aws glue create-table --region us-east-1 --database-name ctxdemo_shop --table-input file://data/glue/cst_mst.json

% aws glue create-table --region us-east-1 --database-name ctxdemo_shop --table-input file://data/glue/ord_trn.json

% aws glue get-tables --region us-east-1 --database-name ctxdemo_shop --query 'TableList[].{Table:Name,Columns:join(`, `, StorageDescriptor.Columns[].join(`:`, [Name, Type]))}' --output table
----------------------------------------------------------------------------------------------
|                                          GetTables                                         |
+---------------------------------------------------------------------------------+----------+
|                                     Columns                                     |  Table   |
+---------------------------------------------------------------------------------+----------+
|  cst_id:string, cst_nm:string, sts:int, tst_flg:int                             |  cst_mst |
|  ord_id:string, cst_id:string, ord_dt:date, sts:int, amt:int, dsc:int, rfd:int  |  ord_trn |
+---------------------------------------------------------------------------------+----------+

To confirm the correct answer, I ran the following SQL in Athena.

WITH net AS (
  SELECT o.cst_id, SUM(o.amt - o.dsc - o.rfd) AS net_sales
  FROM ord_trn o JOIN cst_mst c ON o.cst_id = c.cst_id
  WHERE o.ord_dt >= DATE '2026-11-01' AND o.ord_dt < DATE '2026-12-01'
    AND o.sts = 2 AND c.sts = 1 AND c.tst_flg = 0
  GROUP BY o.cst_id
  HAVING SUM(o.amt - o.dsc - o.rfd) > 0
)
SELECT COUNT(*) AS active_customers, SUM(net_sales) AS net_sales FROM net
active_customers net_sales
2 19000

Finally, I checked the Glue auto-discovery status. To connect the Glue Data Catalog to AWS Context, auto-discovery must be enabled. At this point it was disabled (OPTED_OUT).

% aws glue get-catalog-discovery --region us-east-1
{
    "Mode": "OPTED_OUT",
    "Errors": []
}

https://docs.aws.amazon.com/context/latest/userguide/glue-data-catalog-source.html

Creating a Connection

Opening "Connections" → "Create connection" in the AWS Context console shows the data source selection screen. Under Featured there were two sources, AWS Glue and Amazon Bedrock Managed Knowledge Base, and under More data sources there were 22 types. Of these, five — Amazon Athena, Amazon Data Firehose, Amazon Kinesis, Amazon MSK, and Amazon SageMaker AI — are "Discovery only" (metadata only), and the rest are "Discovery and retrieval". I chose AWS Glue this time.

In Configure connection, I set the connection name to ctxdemo. Connections are created with the name <name>-<service> per service, so this became ctxdemo-glue.

Data scope showed the message "Enable auto-discovery to ingest assets across services" and an "Enable auto-discovery" button. After pressing the button it changed to "Auto-discovery enabled", and AWS Glue / Amazon S3 Tables / Amazon S3 appeared in Available data.

The CLI also confirmed that auto-discovery was enabled (OPTED_IN).

% aws glue get-catalog-discovery --region us-east-1
{
    "Mode": "OPTED_IN",
    "Errors": []
}

In Available data, I expanded AWS Glue → Catalogs → AWSDataCatalog → Databases and selected only ctxdemo_shop.

In Set permissions, you choose to create a new ingestion role (the role AWS Glue assumes to send metadata to AWS Context) and how data is read. I left data reading at the default "Use caller credentials (recommended)". With this setting, AWS Context reads data with the caller's IAM credentials.

I checked the contents in Review and create and pressed "Create connection".

In about 30 seconds, the Connection ctxdemo-glue became Active.

I checked the ingestion role created by the console with the CLI. The role was created under the /service-role/ path, and the trust policy and permissions policy matched the examples in the documentation.

% aws iam get-role --role-name AWSContextIngestion-ctxdemo-usoax --query Role.AssumeRolePolicyDocument
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowGlueToAssumeRole",
            "Effect": "Allow",
            "Principal": {
                "Service": "glue.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "123456789012"
                },
                "ArnLike": {
                    "aws:SourceArn": [
                        "arn:aws:glue:us-east-1:123456789012:catalog",
                        "arn:aws:glue:us-east-1:123456789012:catalog/*"
                    ]
                }
            }
        }
    ]
}
% aws iam get-policy-version --policy-arn arn:aws:iam::123456789012:policy/service-role/AWSContextDataCatalogIngestionPolicy-AWSContextIngestion-ctxdemo-usoax-01pir --version-id v1 --query PolicyVersion.Document
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "IngestFromGlueDataCatalog",
            "Effect": "Allow",
            "Action": "context:IngestAgentContext",
            "Resource": "*",
            "Condition": {
                "ArnLike": {
                    "context:SourceArn": [
                        "arn:aws:glue:us-east-1:123456789012:catalog",
                        "arn:aws:glue:us-east-1:123456789012:catalog/*",
                        "arn:aws:glue:us-east-1:123456789012:connection/*"
                    ]
                },
                "StringEquals": {
                    "aws:ResourceAccount": "${aws:PrincipalAccount}"
                }
            }
        },
        {
            "Sid": "SendGlueMetadata",
            "Effect": "Allow",
            "Action": "glue:SendMetadata",
            "Resource": "arn:aws:glue:us-east-1:123456789012:catalog"
        }
    ]
}

Creating an Agent Context

I opened "Agent context" → "Create agent context" and set the name to ctxdemo-shop and the description to "Customer and order data for a small e-commerce shop for testing". The description does not include definitions such as active customers. After adding ctxdemo-glue with "Add connection", Configuration showed "Reads data with its catalog schema (schema), without additional filters."

The Curation policies field showed "The default review policy is created and attached with your first agent context." Checking after creation, the default policy Review-trace-and-grounding-changes (which holds changes from trace analysis and ontology grounding for review) was attached.

After pressing "Create agent context", it became Active in about 1 minute. However, at this point Entities and Relationships were 0.

Because it was still 0 after waiting about 6 minutes, I watched for AssumeRole of the ingestion role in CloudTrail. About 8 minutes after the Agent Context was created (01:26:14), at 01:34:21, there was a record of glue.amazonaws.com assuming the ingestion role. Right after that, Summary showed 18 Entities and 16 Relationships.

Time (JST) Event
01:22:48 Enabled auto-discovery
01:24:29 Created Connection
01:26:14 Created Agent Context
around 01:27 Agent Context became Active (Entities 0)
01:34:21 Glue assumed the ingestion role (CloudTrail)
around 01:35 Entities 18 / Relationships 16

Even after ingestion finished, the Entities tab still showed "No entities in the agent context yet" just by switching tabs. After reloading the page in the browser, 18 entries appeared.

The 18 entries broke down into 1 Schema (ctxdemo_shop), 2 Tables, 11 Columns, 2 Jobs, and 2 LineageDatasets (S3 paths). In addition to tables and columns, nodes derived from Glue data lineage (Jobs and LineageDatasets) were also ingested.

Opening ctxdemo_shop.ord_trn showed Type Table, Ontology built-in Data, Source GLUE, and the Relationships were HAS_COLUMN (7) and PRODUCES (1) from a Job.

With "Focus on canvas", I displayed the graph centered on cst_mst. It shows HAS_COLUMN to the columns, HAS_TABLE from the Schema, and PRODUCES from the Job. At this point there was no relationship joining the two tables on cst_id and no glossary entity.

Checking behavior with Chat with context

Opening "Chat with context" for the Agent Context showed "Responses come from the AgenticRetrieveStream API, the same API your agents call." The console chat answers using the same API that agents call. To see the answering process, I turned on "Details" at the top right.

First, to confirm the data could be read, I asked "How many orders are there in total?"

The answer was "There are 12 orders in total", and it also showed a breakdown by sts (1: 1, 2: 9, 3: 2) in a table. It also noted that because the definition of "order" and the meaning of sts values were not in the retrieved information, it counted all rows without filtering by status. The SQL executed is below; the table was specified by its Glue table ARN.

SELECT COUNT(*) AS total_rows, COUNT(DISTINCT "ord_id") AS distinct_orders, "sts", COUNT(*) OVER () AS x
FROM "arn:aws:glue:us-east-1:123456789012:table/ctxdemo_shop/ord_trn"
GROUP BY "sts"

The response time was 11.5 seconds (7 steps, 25 items retrieved, 3 cited).

1. Asking without definitions

I asked the main question, "How many active customers were there in November 2026, and what was their net sales in November?", twice in new conversations.

The first time, it fetched sample rows (SELECT * ... LIMIT 10), guessed the code values, and aggregated with the following SQL.

SELECT COUNT(DISTINCT o."cst_id") AS active_customers, SUM(o."amt" - o."dsc" - o."rfd") AS net_sales
FROM "arn:aws:glue:us-east-1:123456789012:table/ctxdemo_shop/ord_trn" o
JOIN "arn:aws:glue:us-east-1:123456789012:table/ctxdemo_shop/cst_mst" c ON o."cst_id" = c."cst_id"
WHERE o."ord_dt" >= DATE '2026-11-01' AND o."ord_dt" < DATE '2026-12-01'
  AND o."sts" = 2 AND c."sts" = 1 AND c."tst_flg" = 0

The answer opened with "I can't give a definitive answer. I couldn't find the code values or metric definitions in the context," and gave reference values of 3 active customers and net sales of 19,000. It then wrote its assumptions, "treating sts = 1 as a valid customer and sts = 2 as a valid order is a guess," and asked questions to confirm the definition of an active customer, the meanings of ord_trn.sts and cst_mst.sts, and the net sales formula.

The filter conditions were the same as the correct SQL, but because there was no condition excluding customers with 0 yen net sales (K006), the number of active customers came out as 3. Since K006's portion of net sales is 0 yen, the net sales happened to be 19,000, the same as the correct answer.

The second time, it did not guess the code values. It answered that it could not give a definitive value because the definitions of "active customer" and "net sales" were not found, and as a reference value with no exclusion by status and so on, it showed 7 customers with orders in November and a total amount of 61,999 (53,999 after subtracting discounts and refunds). It also noted "please don't use this as an official figure" and mentioned that test customers are included (K005's name is "Test Taro").

Without definitions, the way assumptions were made changed from trial to trial even for the same question. Both answers clearly stated that they were assumptions and what they wanted confirmed.

Trial Answer Response time / steps
1st Reference: 3 customers / 19,000 26.5 s / 16
2nd No definitive value. Reference: 7 customers / 61,999 (net 53,999) 29.6 s / 17

2. Adding a data dictionary and asking

Opening "Actions" → "Customize context" for the Agent Context shows four options: "Associate ontologies", "Upload query examples", "Upload data dictionaries", and "Customize retrieval instructions".

Following the example shown in "View examples" under "Upload data dictionaries", I created the following JSON. It contains only column meanings and code values, and does not define "active customer" or "net sales".

{
  "description": "ctxdemo_shop データベースのテーブルとカラムの意味",
  "tables": [
    {
      "table": "ctxdemo_shop.cst_mst",
      "definition": "顧客マスタ。1 行が 1 顧客。",
      "fields": [
        { "field": "cst_id", "definition": "顧客ID。K と 3 桁の数字(例: K001)。" },
        { "field": "cst_nm", "definition": "顧客名。" },
        { "field": "sts", "definition": "顧客ステータス。1 = 利用中、2 = 休止、3 = 退会。" },
        { "field": "tst_flg", "definition": "テスト用顧客フラグ。0 = 通常の顧客、1 = 動作確認用のテスト顧客。" }
      ]
    },
    {
      "table": "ctxdemo_shop.ord_trn",
      "definition": "受注トランザクション。1 行が 1 受注。",
      "fields": [
        { "field": "ord_id", "definition": "受注ID。O と 3 桁の数字(例: O001)。" },
        { "field": "cst_id", "definition": "受注した顧客の顧客ID。ctxdemo_shop.cst_mst.cst_id を参照する。" },
        { "field": "ord_dt", "definition": "受注日。" },
        { "field": "sts", "definition": "受注ステータス。1 = 仮受付、2 = 確定、3 = 取消。cst_mst.sts とは値の意味が異なる。" },
        { "field": "amt", "definition": "値引前の受注金額。税抜、単位は円。" },
        { "field": "dsc", "definition": "値引額。税抜、単位は円。" },
        { "field": "rfd", "definition": "返金額。税抜、単位は円。" }
      ]
    }
  ]
}

Uploading the file created a "Data dictionary upload" customization task. It became Complete within 1 minute, and Changes created was "2 (2 auto-approved)". The default curation policy does not hold data dictionary changes, so they were applied without review.

Opening the created change set showed edits adding a Description property to each column and table entity (19 for cst_mst alone).

In this state, I asked the same question in a new conversation. The answer was "There were 3 active customers in November, and their total net sales were 19,000 yen."

Sources displayed the data dictionary descriptions as they were (for example, "Customer status. 1 = in use, 2 = suspended, 3 = withdrawn."). It also correctly explained the reasons for the excluded customers and orders (K003 is suspended, K004 is withdrawn, K005 is a test customer, K007 has only a tentative order, and O008 and O012 are canceled).

The number of active customers remained 3, with a note at the end: "K006 was fully refunded and has 0 yen net sales, so if you define active as 'customers with net sales over 0 yen', it would be 2." It also said it could not find official definitions of "active customer" and "net sales" and calculated with assumptions. The result is that even if column meanings are known, business term definitions cannot be determined from column descriptions.

The response time was 18.8 seconds (9 steps, 41 items retrieved, 7 cited), shorter than without definitions (26 to 30 seconds, 16 to 17 steps).

3. Adding retrieval instructions and asking

I opened "Customize context" → "Customize retrieval instructions" → "Edit instructions", loaded the following Markdown with "Upload file", and saved it (321 characters).

# 集計ルール
- 「純売上」は ord_trn の amt - dsc - rfd で計算する。金額は税抜・円。
- 売上の集計対象は、受注ステータスが確定(ord_trn.sts = 2)の受注だけとする。
- 月の集計期間は、受注日(ord_dt)がその月の 1 日以上、翌月 1 日未満とする。
- 「アクティブ顧客」は、利用中(cst_mst.sts = 1)かつテスト用でない(cst_mst.tst_flg = 0)顧客のうち、集計期間の確定受注の純売上の合計が 0 円より大きい顧客とする。
- 「アクティブ顧客の純売上」は、アクティブ顧客の集計期間の確定受注の純売上の合計とする。
- 回答には、使った条件と計算式を書く。

After saving, "Instructions saved." appeared and the change took effect without being held for review.

I asked the same question in a new conversation. The answer was "There were 2 active customers in November 2026, and their total net sales for November were 19,000 yen (excluding tax)", which matched the correct answer.

The executed SQL included a HAVING clause restricting to customers with net sales over 0 yen. The conditions are the same as the correct SQL.

SELECT COUNT(*) AS active_cnt, SUM(t.net) AS total_net
FROM (
  SELECT o."cst_id", SUM(o."amt" - o."dsc" - o."rfd") AS net
  FROM "arn:aws:glue:us-east-1:123456789012:table/ctxdemo_shop/ord_trn" o
  JOIN "arn:aws:glue:us-east-1:123456789012:table/ctxdemo_shop/cst_mst" c ON o."cst_id" = c."cst_id"
  WHERE o."sts" = 2 AND o."ord_dt" >= DATE '2026-11-01' AND o."ord_dt" < DATE '2026-12-01'
    AND c."sts" = 1 AND c."tst_flg" = 0
  GROUP BY o."cst_id"
  HAVING SUM(o."amt" - o."dsc" - o."rfd") > 0
) t

As requested in the retrieval instructions, the answer included "the conditions and formula used" as bullet points. The first search terms also changed from "active customer" and "net sales" in ① and ② to "ord_trn orders" and "cst_mst customer master", and the step of searching for definitions disappeared. The response time was 11.5 seconds (6 steps).

When I asked the same question once more in a new conversation, the result was again 2 customers / 19,000 yen with the same SQL structure (13.6 seconds, 6 steps).

Summary of results

State Active customers Net sales Response time / steps
① No definitions (1st) 3 (reference) 19,000 (reference) 26.5 s / 16
① No definitions (2nd) No definitive value (reference 7) No definitive value (reference 61,999) 29.6 s / 17
② Data dictionary added 3 (noted 2 if over 0 yen) 19,000 18.8 s / 9
③ Retrieval instructions added (1st) 2 19,000 11.5 s / 6
③ Retrieval instructions added (2nd) 2 19,000 13.6 s / 6

The correct answer is 2 active customers and net sales of 19,000.

Checking the information for using it from agents

The Integration tab of the Agent Context had the information for connecting agents via MCP. I did not try connecting from an MCP client such as Claude Code this time, but I'll record what was shown on the screen.

  • Authentication methods: two types, AWS credentials (local mcp-proxy-for-aws signs with AWS credentials) and Identity provider sign-in
  • Endpoint: https://context-mcp.us-east-1.api.aws/mcp, signing service name context-mcp
  • MCP client configuration example (as shown in the console)
{
  "mcpServers": {
    "agent-context": {
      "command": "uvx",
      "args": [
        "mcp-proxy-for-aws",
        "https://context-mcp.us-east-1.api.aws/mcp",
        "--service", "context-mcp",
        "--region", "us-east-1"
      ],
      "env": {
        "AWS_PROFILE": "default",
        "AWS_REGION": "us-east-1"
      }
    }
  }
}
  • Available tools: 18 in total — SearchAgentContext, TraverseAgentContext, AgenticRetrieve, AgenticRetrieveStream, ExecuteSql, GetAgentContext, ListAgentContexts, change set and curation proposal operations (9 including CreateChangeSet), PutTrace, and RetrieveKnowledgeBase
  • SDK sample code (TypeScript / Python / Java) and the IAM policy required to use the tools

https://docs.aws.amazon.com/context/latest/userguide/gs-tutorial-mcp.html

Cleanup

Opening "Actions" → "Delete agent context" for the Agent Context showed the impact of deletion.

  • 19 entities and 18 relationships are permanently deleted
  • 1 Connection is detached (the data source remains)
  • Agents using this Agent Context lose access immediately
  • The attached curation policy is detached (the policy itself remains)

After entering the name and deleting, I deleted ctxdemo-glue from Connections. Note that "Last sync with source" in the Connection list stayed "—" to the end, even after ingestion finished.

For the default curation policy Review-trace-and-grounding-changes, Edit and Delete under Actions were disabled. The description on the detail screen is "This is the agent context's built-in default policy. It applies automatically and can't be edited.", and the ARN is curation-policy/system-default-curation-policy. It remains as a built-in policy.

I deleted the automatically created IAM role and policy in the IAM console. Before deleting, opening the policy summary showed the warning "This policy does not grant any permissions" and "Unrecognized service: context". The policy was actually what made ingestion work, so the IAM console's policy summary apparently doesn't support AWS Context yet.

I deleted the Glue database and S3 bucket with the CLI and returned auto-discovery to the original OPTED_OUT.

% aws glue delete-database --region us-east-1 --name ctxdemo_shop

% aws s3 rm s3://ctxdemo-123456789012-use1 --recursive
delete: s3://ctxdemo-123456789012-use1/athena-results/82ce71db-6fed-4f09-8e5a-ebadf0a96f08.csv
delete: s3://ctxdemo-123456789012-use1/athena-results/3b4c2a19-1a49-4f5e-8663-dc95a9146469.csv
delete: s3://ctxdemo-123456789012-use1/ctxdemo_shop/cst_mst/cst_mst.csv
delete: s3://ctxdemo-123456789012-use1/athena-results/3b4c2a19-1a49-4f5e-8663-dc95a9146469.csv.metadata
delete: s3://ctxdemo-123456789012-use1/ctxdemo_shop/ord_trn/ord_trn.csv
delete: s3://ctxdemo-123456789012-use1/athena-results/82ce71db-6fed-4f09-8e5a-ebadf0a96f08.csv.metadata

% aws s3api delete-bucket --bucket ctxdemo-123456789012-use1 --region us-east-1

% aws glue put-catalog-discovery --region us-east-1 --mode OPTED_OUT
{
    "Mode": "OPTED_OUT",
    "Errors": []
}

What remained in athena-results/ was only the results of the two Athena runs I made myself to confirm the correct answer. The results of the SQL AWS Context ran during chat were not written to this bucket.

Discussion

Without definitions, the way assumptions are made changes from trial to trial

Even without definitions, AWS Context guessed the code values from column names and sample rows and built an SQL close to the correct one. On the other hand, on the second ask of the same question it did not guess and returned a reference value with no exclusions, so the way assumptions were made changed from trial to trial. Both answers clearly stated that they were assumptions and what they wanted confirmed. After definitions were added, both trials produced the same numbers and SQL with the same conditions.

The data dictionary and retrieval instructions play different roles

Adding the data dictionary removed the need to guess code values, reducing steps from 16–17 to 9 and response time from 26–30 seconds to 18.8 seconds. Sources also displayed the dictionary descriptions, so you can check the basis of the answer. However, the definition of a business term that spans multiple columns, such as "active customer", could not be determined from column descriptions.

When the business term definitions were written in the retrieval instructions, those conditions were reflected in the SQL, and both trials were correct. Within this test's scope, writing column meanings in the data dictionary and business term definitions and aggregation rules in the retrieval instructions got us to the correct answer. Note that retrieval instructions are limited to one per Agent Context and 2,048 characters. I did not try query examples or ontologies this time.

Points to watch in operation

  • Ingestion takes time to show up: It took about 8 minutes after the Agent Context became Active for entities to appear. In CloudTrail, the point where Glue assumed the ingestion role was just before entities appeared. According to the documentation, the Glue Data Catalog connection syncs in response to source changes, and there is no operation to start ingestion manually
  • Console display refresh: The Entities tab did not update without reloading the page. Also, "Last sync with source" for the Connection stayed "—" even after ingestion
  • auto-discovery is an account/Region-level setting: It can be enabled from the Connection creation screen, but according to the Glue documentation, enabling it makes metadata from participating AWS services appear as assets in the account's Data Catalog. In this test too, Amazon S3 Tables and Amazon S3 appeared in Available data after enabling, besides Glue
  • Behavior in a Lake Formation environment: This account manages Data Catalog permissions with Lake Formation, but metadata was ingested without granting Lake Formation permissions to the ingestion role. According to the documentation, Glue Data Catalog table and column metadata is not filtered by Lake Formation, and anyone with access to the Agent Context can see table names and descriptions. Lake Formation permissions apply when reading data. The exposure scope of the metadata itself needs to be managed through access to the Agent Context
  • IAM console display: In the automatically created permissions policy, context was shown as an "unrecognized service". It is a display warning, and ingestion worked
  • The default curation policy cannot be deleted: It remains as a built-in policy

Pricing

According to the pricing page, graph creation and storage from the Glue Data Catalog as in this test is free, and agentic operations such as chat questions and data dictionary ingestion are billed in agent-units. There is a free tier of 3,750 agent-units for the first 30 days. I could not check in the console how many agent-units this test consumed. I also have not confirmed its reflection in billing as of writing.

What I hope for next

  • A context command in the AWS CLI
  • Being able to check agent-unit consumption per Agent Context in the console (the pricing page says a feature to set an agent-unit budget is Coming soon)
  • Being able to check ingestion progress on the Connection or Agent Context screen
  • Support for the context service in the IAM console policy summary
  • Service availability in the Tokyo Region

Conclusion

I created an AWS Context Connection and Agent Context using only the management console, apart from data preparation, and verified behavior with small order data that has abbreviated columns and code values. Even without definitions, answers show the SQL and their basis, but the way assumptions are made changed from trial to trial. When I wrote column meanings in the data dictionary and business term definitions like "active customer" in the retrieval instructions, both trials returned the correct numbers and SQL with the same conditions as the correct one.

When you want an agent to use internal data, I felt a practical approach is to first build an Agent Context from the Glue Data Catalog metadata, ask questions with Chat with context, and then write into the data dictionary and retrieval instructions, starting with the terms that appear in the answers' assumptions and confirmation requests. Usage through MCP, query examples, ontologies, and Evaluation, which I did not try this time, are things I'd like to check in another article.


Claudeならクラスメソッドにお任せください

クラスメソッドは、Anthropic社とリセラー契約を締結しています。各種製品ガイドから、業種別の活用法、フェーズごとのお悩み解決などサービス支援ページにまとめております。まずはご覧いただき、お気軽にご相談ください。

サービス詳細を見る

Share this article

AWSのお困り事はクラスメソッドへ