# Maintainer notes

For whoever maintains this kit. Commands run from `kits/amazon-ergo`. Shown on the Files page only.

## Run the POC

A playground page streams Ergo's answer to a coding prompt and shows output tokens per second, time to first token, total time, tokens and the dollar cost of that request. The shared platform (repo root `make deploy`) must exist first: the API uses its Cognito pool.

```
make preflight       # credentials (profile supernova) and tools
make web             # local mode at http://127.0.0.1:8787, your credentials, no sign-in, nothing deployed
make deploy          # API Gateway + Lambda + WAF; writes poc/web/config.json
make verify          # 401 without a token, direct Bedrock call, Lambda invoke; prints tokens per second
make screenshots     # docs/screenshots/*.png from local mode
make destroy         # removes everything and lists leftovers (must be none)
```

- Hosted page: after `make deploy`, run `make deploy` at the repo root to publish `poc/web/` (with its `config.json`) to the dashboard site. Sign-in is Midway through the shared pool.
- Path: browser, API Gateway REST API (Cognito authorizer, response streaming), Lambda (`poc/lambda/index.mjs`, Node.js 26), Bedrock `ConverseStream` on `global.amazon.ergo-1.0`. Local mode runs the same handler code.
- Cost guards: output limit fixed at 16,384 tokens, prompts over 20,000 characters rejected, Lambda concurrency 5, stage throttle 2 requests per second (burst 5), WAF rate limit 100 requests per 5 minutes per IP.
- Timings are measured in the backend around the Bedrock call. Cost is computed from the token usage Bedrock returns and the prices in `poc/prices.json`.
- Tags: `Project`, `Environment`, `Owner`, `CostCenter`, `ManagedBy`, `Repository` from provider `default_tags`. Activate them once with `make cost-tags` at the repo root, then `make cost`.
- Demo backup: `make web` (local mode) if the hosted page or the network fails. Stop it with Ctrl+C.
- The hosted demo stays up between sessions. Tear down only at the end of the event with `make destroy`.

## Security Hub

Built to FSBP, CIS v3.0 and AI Security Best Practices. Status below is by design; no Security Hub findings have been read for a deployed copy yet.

| Control | How the POC meets it |
|---|---|
| APIGateway.1 execution logging | INFO level on every method, bodies not logged, log group with 14 day retention |
| APIGateway.2 backend certificate | Client certificate attached to the stage |
| APIGateway.3 X-Ray tracing | Enabled on the stage |
| APIGateway.4 WAF on the stage | Regional WAFv2 web ACL: per-IP rate limit plus `AWSManagedRulesCommonRuleSet` |
| Stage access logging | JSON access log to CloudWatch Logs |
| WAF.10, WAF.11, WAF.12 | Web ACL has rules, logs to `aws-waf-logs-field-kit-amazon-ergo`, metrics on for every rule |
| Lambda.1 no public access | Invoke permission limited to this API's `POST /chat` |
| Lambda.2 supported runtime | `nodejs26.x` |
| Lambda.7 active tracing | Enabled |
| IAM least privilege | Role allows only `bedrock:InvokeModel` and `bedrock:InvokeModelWithResponseStream` on the three Ergo ARNs, writes to its own log group, and X-Ray writes (which accept no resource scope) |
| Authorization | `POST /chat` requires a token from the shared Cognito pool. No long-term keys anywhere |

Intentionally not met, or outside the kit:

| Item | Reason |
|---|---|
| Lambda.3 function in a VPC | The function only calls the Bedrock public endpoint. A VPC with endpoints adds fixed monthly cost to a demo that is idle most of the time |
| `OPTIONS /chat` has no authorizer | Browsers send no credentials on a CORS preflight. It is a mock integration that never reaches the Lambda or the model |
| Two common rule set rules count instead of block | `SizeRestrictions_BODY` and `CrossSiteScripting_BODY`: the body is a coding prompt, so it can pass 8 KB and contain markup. The Lambda caps prompt length and the page escapes model output |
| Bedrock model invocation logging and Guardrails | Invocation logging is an account-wide setting shared by every project, so the kit does not manage it. No guardrail is attached because the demo measures raw model speed; add one before using this pattern with customer data |
| Log group encryption with a customer managed key | Logs use the default CloudWatch Logs encryption. They hold request metadata and token counts, not prompts or answers |

API Gateway execution logging needs one CloudWatch role per account and Region. The shared platform owns it (`platform/terraform/apigateway.tf`), so deploy the platform before this kit.

## What the POC costs to run

| Item | Cost | Basis |
|---|---|---|
| One demo request | $0.009 to $0.037 measured | Measured 2026-12-01 on the "LRU cache with tests" preset: 83 input tokens and 3,035 to 9,079 output tokens. Output includes the reasoning, so it varies run to run. Largest run seen (hosted demo, "Retry with backoff" preset): 101 x $1.00 / 1M + 12,304 x $3.00 / 1M = $0.0370 |
| A 20-request demo session | About $0.75 at most | 20 x $0.0370 |
| Idle | Standard AWS WAF (two web ACLs), CloudFront and Route 53 charges. Not Ergo-specific; no figure in this kit's sources | See each service's pricing page |
| Lambda, API Gateway, Cognito, S3, CloudWatch Logs | Pay per use. No figure in this kit's sources | See each service's pricing page |

The playground computes each request's cost from the token usage Bedrock returns, at the global rates. `make cost` shows the actual spend by service. `make destroy` removes the fixed pieces.

## Unverified

- Knowledge cutoff: Bedrock docs say May 2026, the Hugging Face card says June 2026. Unverified which is right.
- Server-side web search: the model card lists it as supported; the Codex configuration note on the coding tools page says built-in server-side tools such as web search are not supported. Unverified which applies.
- How to join the Turbo preview: unverified.
- No Ergo-specific CloudFormation or Terraform resource; it is a model ID. Unverified against the registries.
- The model card states Zero Data Retention and Zero Operator Access on Bedrock. Seen on a second read; re-read the exact wording before quoting.
- The AWS News Blog body could not be re-loaded on a second attempt, so the two Dr. Matt Wood comparison claims (Kimi K3.1 Pro, Opus 5.5) rest on a single read. Re-read before quoting.
- The long aboutamazon.com/amazon-ergo page was only partly read, so an attributed quote may exist there.
- Throughput wording: "over 400 output tokens per second" on the model card; the product page says "generates 400".
- The limitation on the Hugging Face card is two separate fragments; do not join them into one quote.
- The GitHub samples link in the docs (https://github.com/aws-samples/amazon-ai-samples/ergo) is malformed; no working official sample repo confirmed. Use the sample code on the model card and the coding tools page.

## Detail cut from the published pages

Kept here so it is not lost. Facts are from the sources read 2026-12-01.

Access and APIs:

- IAM actions `bedrock:InvokeModel` and `bedrock:InvokeModelWithResponseStream` on `arn:aws:bedrock:*:*:inference-profile/us.amazon.ergo-1.0`, `arn:aws:bedrock:*:*:inference-profile/global.amazon.ergo-1.0` and `arn:aws:bedrock:*::foundation-model/amazon.ergo-1.0`. Policies need both the inference profile ARN and the foundation model ARN.
- OpenAI-compatible base URL: `https://bedrock-runtime.<region>.amazonaws.com/openai/v1`. boto3: `boto3.client('bedrock-runtime')`.
- OpenCode uses Chat Completions. Codex CLI uses Responses and needs `web_search = "disabled"` and `AWS_REGION`. Claude Code needs a local LiteLLM proxy. Kiro is listed.
- Also supported per the model card: implicit and explicit prompt caching, invocation logs, summarized reasoning.
- AgentCore harness supports Ergo: https://aws.amazon.com/about-aws/whats-new/2026/12/agentcore-harness-amazon-ergo/
- The global profile routes to a Region AWS selects. There is no EU or APAC geo profile.

Quotas:

```
aws service-quotas list-service-quotas --service-code bedrock --region us-east-1 \
  --query "Quotas[?contains(QuotaName, 'Ergo')].[QuotaName,Value,Adjustable]" --output table
```

- The `Ergo` name filter is an assumption. If it returns nothing, drop `--query` and search the full list.
- A fleet of agents that all set the output limit to 131,072 uses up quota far faster than its real output. Set the limit close to what each call needs, and not below 8,192.
- Provisioned throughput: not published. Self-hosting hardware requirements: not published.

Pricing:

- Worked example over 22 working days: $9,592.00 without caching, $2,983.20 with. On the US profile add 10%: $479.60 and $149.16 per day.
- A cache write costs 25% more than plain input and lasts 30 minutes.
- Agent runs resend the same context every turn, so input dominates the bill. The cache hit rate is the number to measure in a pilot.
- The output limit does not change the price, but each request reserves its full limit against the account quota.
- Self-hosting cost and a self-hosting cost comparison are not published; the customer pays for their own compute.

Demo:

- Raising the reasoning effort on the same prompt: token count, wait and cost change from run to run; in test runs higher effort did not always mean more tokens. Point at what changed and do not predict the direction.
- If tokens per second differs from the published "over 400": the published figure is AWS's number for the service; the demo is one request measured through its own path. Do not explain the gap with a cause you have not verified.
- `docs/architecture.png` step 7 shows the call through the global inference profile.

Talking points:

- The Opus 5.5 claim compares speed and cost, not quality.
- Objection "Is this lock-in?": less than with a closed model. The same weights run outside Bedrock, and the API is OpenAI-compatible as well as Converse. Read the license's acceptable use policy before committing.
- Objection "Is there a batch discount?": no. Objection "Does it work with Knowledge Bases?": no.
- Closed-model comparison: use Ergo for high-volume agent work where the agent runs tests and checks its own changes, and keep a stronger model for the hardest steps. Both can sit behind the same Bedrock API.
- More questions: Do your agents run tests and verify their own changes, or does a person review every step? Do you want to fine-tune or self-host, or is pay per token on Bedrock enough? Which coding tools do your developers use: Kiro, OpenCode, Codex CLI, Claude Code?
