onboard-repo · diff

git:20260613.140b89d to git:20260702.7723355

120 added, 90 removed. Audit A to A.

---
name: onboard-repo
description: >-
- Onboard a new GitHub repository to the ABCA platform by adding a Blueprint CDK
- construct. Use when the user says "onboard a repo", "add a repository",
- "register a repo", "new repo", "Blueprint construct", "REPO_NOT_ONBOARDED error",
- or gets a 422 error about an unregistered repository.
+ Onboard a new GitHub repository to the ABCA platform so the agent can target it.
+ Use when the user says "onboard a repo", "add a repository", "register a repo",
+ "new repo", or gets a `REPO_NOT_ONBOARDED` / 422 error about an unregistered
+ repository.
---
# Repository Onboarding
- You are guiding the user through onboarding a new GitHub repository to ABCA. Repositories must be registered as `Blueprint` constructs in the CDK stack before tasks can target them.
+ You are helping an **operator** register a GitHub repository with their running ABCA
+ deployment so tasks can target it.
- ## Step 1: Gather Repository Details
+ There are two paths.
- Use AskUserQuestion to collect:
- - **Repository**: GitHub `owner/repo` format
- - **Compute type**: `agentcore` (default) or `ecs`
- - **Model preference**: Claude Sonnet 4 (default), Claude Opus 4 (complex repos), or Claude Haiku (lightweight). **Important:** Models must be specified using their cross-region inference profile ID (e.g. `us.anthropic.claude-opus-4-20250514-v1:0`), not the raw foundation model ID. On-demand invocation of raw model IDs is not supported for most models.
- - **Max turns**: Default 100 (range: 1-500)
- - **Max budget**: USD cost ceiling per task (optional)
- - **Custom GitHub PAT**: If this repo needs a different token than the platform default
+ **Prefer the CLI operator path (Path A)** when the repo can run on the
+ **platform/default-blueprint** setup — the default GitHub token secret, a model
+ already granted to the runtime, and the default egress allowlist. It's a single
+ runtime command against the deployed stack: no code change, no redeploy.
- ## Step 2: Read the Current Stack
+ **Use the CDK Blueprint path (Path B)** when the repo needs its **own** config that
+ the CLI can't provision at runtime — a per-repo GitHub token, a model not yet
+ granted to the runtime, custom egress domains, Cedar HITL policies, or
+ system-prompt overrides. These are baked into infrastructure and require a redeploy
+ (with the correct permissions). When in doubt, start with Path A; if a task later
+ fails on a missing token / model grant / blocked egress, promote the repo to a
+ Blueprint.
- Read the CDK stack file to understand existing Blueprint definitions:
+ > **This is an operation, not a contribution.** Onboarding a repo into your own
+ > deployment writes a record to the platform's RepoTable — it is **not** a change to
+ > the `aws-samples` codebase, so the ADR-003 contribution flow (GitHub issue →
+ > approval → feature branch) does **not** apply. Only invoke ADR-003 if the user is
+ > actually changing the platform source (e.g. wiring a brand-new Bedrock model into
+ > the stack — see "Model not yet wired into the runtime" below).
- ```
- Read cdk/src/stacks/agent.ts
- ```
+ ## Gather repository details
- Identify:
- - Where existing Blueprint constructs are defined
- - The `repoTable` reference used
- - Any patterns for compute/model overrides
+ Use AskUserQuestion to collect (only the repository is required — the rest fall back to platform defaults):
- ### Sample blueprint repo without a code change
+ - **Repository** — GitHub `owner/repo`. Must match exactly what's passed to `bgagent submit --repo` later.
+ - **Compute type** — `agentcore` (default) or `ecs`.
+ - **Model** — default is the platform model (Sonnet 4.6). If overriding, it must be a model **already granted to the runtime** (see "Model not yet wired into the runtime"), specified as a cross-Region **inference-profile ID** (e.g. `us.anthropic.claude-sonnet-4-6`), not a raw `anthropic.*` foundation-model ID.
+ - **Max turns** — default 100 (range 1–500).
+ - **Per-repo GitHub token** — only if this repo needs a different token than the platform default (provide its Secrets Manager ARN).
- The stack’s **AgentPlugins** blueprint uses a `repo` value resolved in this order: **`BLUEPRINT_REPO`** (environment variable) → CDK context **`blueprintRepo`** → default `awslabs/agent-plugins` (see `blueprintRepo` in `cdk/src/stacks/agent.ts`). If the user only needs to target a fork of the sample repo, they can set `export BLUEPRINT_REPO=owner/repo` or pass `-c blueprintRepo=owner/repo` (or set `"context": { "blueprintRepo": "..." }` in `cdk/cdk.json`) and redeploy, instead of adding a new `Blueprint` construct.
+ > **Per-task cost limits aren't set here.** `max_budget` / `max_turns` *per task* are flags on `bgagent submit` (the `submit-task` skill), not repo-onboarding fields. Onboarding sets only the per-repo **default** `max_turns`.
- ## Step 3: Add the Blueprint Construct
+ If the repo needs config the CLI can't provision (per-repo egress, Cedar policies, system-prompt overrides, or a not-yet-granted model), use **Path B** instead.
- Add a new `Blueprint` construct instance to the stack. Follow the existing pattern. Example:
+ ## Path A — CLI operator onboarding (default)
- ```typescript
- new Blueprint(this, 'MyRepoBlueprint', {
- repo: 'owner/repo',
- repoTable: repoTable.table,
- // Optional overrides:
- // computeType: 'agentcore',
- // modelId: 'us.anthropic.claude-sonnet-4-20250514-v1:0',
- // maxTurns: 100,
- // maxBudgetUsd: 50,
- // runtimeArn: runtime.runtimeArn,
- // githubTokenSecretArn: 'arn:aws:secretsmanager:...',
- });
+ `bgagent repo onboard` writes (or re-activates) the repository's `RepoConfig` row in
+ the deployed RepoTable directly. It takes effect immediately — **no `agent.ts` edit,
+ no `cdk deploy`.**
+
+ ```bash
+ bgagent repo onboard <owner/repo>
+ # common overrides:
+ # --model <inference-profile-id> e.g. us.anthropic.claude-sonnet-4-6 (must be runtime-granted)
+ # --compute-type <agentcore|ecs>
+ # --max-turns <n> per-repo default turn limit
+ # --token-secret-arn <arn> per-repo GitHub token (else platform default)
+ # --runtime-arn <arn> override AgentCore runtime ARN (agentcore only)
+ # --poll-interval <ms> agent completion poll interval
```
- Use a descriptive construct ID derived from the repo name.
+ Then confirm it landed:
- ### Model ID and IAM Permissions
+ ```bash
+ bgagent repo list # status should be "active"
+ bgagent repo show <owner/repo> # full resolved config (secret ARNs redacted)
+ ```
- When specifying a non-default model via `agent.modelId`, three things are required:
+ That's it — the repo is onboarded. Submit a task with the `submit-task` skill.
- 1. **Use the inference profile ID, not the raw model ID, when Bedrock requires it.** For `InvokeModel` / streaming, specify the cross-Region **inference profile** identifier (or ARN) where the Bedrock User Guide calls for it — not only the bare `anthropic.*` foundation model ID. Examples:
- - Sonnet 4.6 (US geography profile): `us.anthropic.claude-sonnet-4-6`
- - Sonnet 4: `us.anthropic.claude-sonnet-4-20250514-v1:0`
- - Opus 4: `us.anthropic.claude-opus-4-20250514-v1:0`
- - Haiku 4.5: `us.anthropic.claude-haiku-4-5-20251001-v1:0`
+ **Pick a model that is already wired into the runtime.** With no `--model`, the repo
+ uses the platform default (Sonnet 4.6). If you pass `--model`, use a cross-Region
+ **inference profile ID** (e.g. `us.anthropic.claude-sonnet-4-6`), not a raw
+ `anthropic.*` foundation-model ID. Only models the stack has granted the runtime can
+ be invoked — see "Model not yet wired into the runtime" before choosing a model the
+ deployment doesn't already support.
- See [Use an inference profile in model invocation](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-use.html).
+ ## Path B — CDK Blueprint (declarative / canonical)
- 2. **Grant the runtime IAM permissions for the model.** The Blueprint construct does not automatically grant `bedrock:InvokeModel*` — this is by design (least privilege). You must add a `grantInvoke` block in the stack for each model used:
- ```typescript
- const opusModel = new bedrock.BedrockFoundationModel('anthropic.claude-opus-4-20250514-v1:0', {
- supportsAgents: true,
- supportsCrossRegion: true,
- });
- opusModel.grantInvoke(runtime);
+ Use this when the operator wants the repo committed to infrastructure-as-code (so a
+ fresh deploy re-creates it) rather than set as a runtime record. This **does** require
+ editing the stack and redeploying.
- const opusProfile = bedrock.CrossRegionInferenceProfile.fromConfig({
- geoRegion: bedrock.CrossRegionInferenceProfileRegion.US,
- model: opusModel,
+ 1. Read `cdk/src/stacks/agent.ts` to find where `Blueprint` constructs are defined and
+ the `repoTable` reference.
+ 2. Add a construct following the existing pattern:
+
+ ```typescript
+ new Blueprint(this, 'MyRepoBlueprint', {
+ repo: 'owner/repo',
+ repoTable: repoTable.table,
+ // Optional overrides:
+ // computeType: 'agentcore',
+ // modelId: 'us.anthropic.claude-sonnet-4-6',
+ // maxTurns: 100,
+ // maxBudgetUsd: 50,
+ // githubTokenSecretArn: 'arn:aws:secretsmanager:...',
});
- opusProfile.grantInvoke(runtime);
```
- 3. **Account-level Bedrock model access (separate from IAM).** The runtime role must be allowed to invoke the model, and the **AWS account** must be able to use that model in Bedrock: complete [model access](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html) prerequisites (AWS Marketplace actions on first serverless use where applicable, Anthropic first-time use / `PutUseCaseForModelAccess` for Anthropic models, valid payment method for Marketplace-backed models). For geographic cross-Region inference profiles, IAM and SCPs must allow Bedrock in **source and destination** Regions per [Supported Regions and models for inference profiles](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html).
-
- ## Step 4: Deploy
-
- After adding the Blueprint, the stack must be redeployed:
+ 3. Redeploy: `mise //cdk:compile` → `mise //cdk:diff` (show the diff) → `mise //cdk:deploy -- --require-approval never`.
- ```bash
- export MISE_EXPERIMENTAL=1
- mise //cdk:compile # Verify TypeScript compiles
- mise //cdk:test # Run tests
- mise //cdk:diff # Preview changes
- ```
+ > **Sample-repo shortcut:** the stack's AgentPlugins blueprint resolves its `repo` from
+ > `BLUEPRINT_REPO` (env) → CDK context `blueprintRepo` → default `awslabs/agent-plugins`.
+ > To target a fork of the sample without adding a construct, set
+ > `export BLUEPRINT_REPO=owner/repo` (or `cdk.json` context) and redeploy.
- Show the diff to the user. If it looks correct, ask if they want to deploy now.
+ ## Model not yet wired into the runtime (the one real code change)
- ```bash
- mise //cdk:deploy
- ```
+ A repo can only use a model the **runtime IAM role has `grantInvoke` for**. As of now
+ the stack wires **Sonnet 4.6, Opus 4 (`claude-opus-4-20250514`), and Haiku 4.5** (see
+ the `grantInvoke` block in `agent.ts`). Onboarding a repo pinned to any **other** model
+ (e.g. Opus 4.8 / `us.anthropic.claude-opus-4-8`) will fail at invoke with a 403 — the
+ CLI onboard succeeds, but tasks can't run.
- ## Step 5: Verify
+ Adding a new model **is** a platform source change, so it follows ADR-003 (issue →
+ approval → feature branch) and requires:
- After deployment, verify the repo config was written to DynamoDB:
+ 1. **Wire the model + inference profile and grant the runtime**, in `agent.ts`:
+ ```typescript
+ const model = new bedrock.BedrockFoundationModel('anthropic.claude-opus-4-8', {
+ supportsAgents: true,
+ supportsCrossRegion: true,
+ });
+ model.grantInvoke(runtime);
+ const profile = bedrock.CrossRegionInferenceProfile.fromConfig({
+ geoRegion: bedrock.CrossRegionInferenceProfileRegion.US,
+ model,
+ });
+ profile.grantInvoke(runtime);
+ ```
+ then redeploy.
+ 2. **Account-level Bedrock model access** (separate from IAM): the account must have the
+ model enabled for the Region — complete [model access](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html)
+ prerequisites (Marketplace actions / Anthropic first-time use where applicable). For
+ cross-Region profiles, IAM and SCPs must allow Bedrock in source **and** destination
+ Regions.
- ```bash
- aws dynamodb scan --table-name <RepoTableName> \
- --filter-expression "repo = :r" \
- --expression-attribute-values '{":r":{"S":"owner/repo"}}' \
- --output json
- ```
+ If the user just wants the agent working now, steer them to a wired model (Sonnet 4.6)
+ via Path A and treat "add model X" as a separate, later change.
- ## Per-Repository Configuration Reference
+ ## Per-repository configuration reference
| Setting | Purpose | Default |
|---------|---------|---------|
| `compute_type` | Execution strategy | `agentcore` |
| `runtime_arn` | AgentCore runtime override | Platform default |
- | `model_id` | AI model for tasks | Platform default (Sonnet 4) |
+ | `model_id` | AI model for tasks (inference profile ID) | Platform default (Sonnet 4.6) |
| `max_turns` | Turn limit per task | 100 |
| `max_budget_usd` | Cost ceiling per task | Unlimited |
| `system_prompt_overrides` | Custom system instructions | None |
| `github_token_secret_arn` | Repo-specific GitHub token | Platform default |
| `poll_interval_ms` | Completion polling frequency | 30000ms |
- Task-level parameters override Blueprint defaults. If neither specifies a value, platform defaults apply.
+ Task-level parameters override per-repo defaults; if neither specifies a value, platform defaults apply.
- ## Common Issues
+ ## Common issues
- - **422 "Repository not onboarded"** — Blueprint hasn't been deployed yet. Add the construct and redeploy.
- - **Preflight failures after onboarding** — GitHub PAT may lack permissions for the new repo. Check the PAT's fine-grained access includes the target repository with Contents (read/write) and Pull requests (read/write) permissions.
- - **400 "Invocation with on-demand throughput isn't supported"** — The Blueprint `modelId` is using a raw foundation model ID instead of an inference profile ID. Change e.g. `anthropic.claude-opus-4-20250514-v1:0` to `us.anthropic.claude-opus-4-20250514-v1:0`.
- - **403 "not authorized to perform bedrock:InvokeModelWithResponseStream"** — The runtime IAM role lacks permissions for the model specified in the Blueprint. Add `grantInvoke` for both the model and its cross-region inference profile in `agent.ts`.
- - **Model not available / "not available on your Bedrock deployment"** — IAM is not the whole story: the account must meet [Bedrock model access](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html) for that model family and Region, and `modelId` should be an **enabled** inference profile ID (for example `us.anthropic.claude-sonnet-4-6`) where Bedrock requires it. After fixing access in the console, align Blueprint / DynamoDB `model_id` and redeploy if you change IAM grants.
+ - **`REPO_NOT_ONBOARDED` / 422** — the repo isn't registered. Run `bgagent repo onboard <owner/repo>` (Path A). Confirm the `owner/repo` matches exactly what you pass to `bgagent submit --repo`.
+ - **Preflight failure after onboarding** — the GitHub PAT lacks access to the new repo. Ensure the token has Contents (read/write) + Pull requests (read/write) on it, or onboard with a repo-specific `--token-secret-arn`.
+ - **400 "Invocation with on-demand throughput isn't supported"** — `model_id` is a raw foundation-model ID; use the inference-profile ID (e.g. `us.anthropic.claude-sonnet-4-6`).
+ - **403 "not authorized to perform bedrock:InvokeModelWithResponseStream"** — the repo's model isn't wired into the runtime. See "Model not yet wired into the runtime."
+ - **Model not available / "not available on your Bedrock deployment"** — account-level Bedrock access isn't enabled for that model/Region (separate from IAM); complete [model access](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html), then use an enabled inference-profile ID.