Skip to content

fix(bedrock): scheduled automations are refused on AWS SDK credential-chain routes - #192576

Open
yubingjiaocn wants to merge 14 commits into
openclaw:mainfrom
yubingjiaocn:fix/bedrock-aws-sdk-auth-profile
Open

yubingjiaocn wants to merge 14 commits into
openclaw:mainfrom
yubingjiaocn:fix/bedrock-aws-sdk-auth-profile

Conversation

@yubingjiaocn

@yubingjiaocn yubingjiaocn commented Nov 4, 2026 •

Copy link
Copy Markdown

fix(bedrock): give the AWS SDK route an account scheduled runs can record

Fixes #192524.

What Problem This Solves

Fixes: every scheduled automation on an Amazon Bedrock route that authenticates
through the AWS SDK default credential chain fails with "Automation has no
recorded inference account", and its advice cannot be followed.

models.providers.amazon-bedrock.auth: "aws-sdk" resolves credentials from the
host chain (instance role, container role, SSO profile, env), so nothing owned
the route in the auth store and the plugin registered no auth method — there was
no account id to name in openclaw automations edit <jobId> --model <model>@<profileId>. Creating a new automation on that route was refused for the
same reason ("Automation requires a stored inference account or a key in the
environment or provider config"). The route worked interactively and was
unusable on a schedule, with no way out from the CLI.

User Impact

User impact: Bedrock hosts that authenticate through the AWS SDK chain can run
scheduled automations again, and that authority is revocable like any other
account.

  • Setup gains an "AWS credentials (SDK default chain)" choice for Amazon Bedrock.
    It stores no AWS credentials: it creates the account amazon-bedrock:aws-sdk
    holding OpenClaw's non-secret aws-sdk-credentials marker, sets the provider's
    auth: "aws-sdk", and records the region when one is given. The choice is
    declared on the runtime provider registration too, which is where
    non-interactive setup reads a plugin's auth methods from
    (openclaw onboard --auth-choice amazon-bedrock-aws-sdk).
  • openclaw doctor --fix creates that account on hosts already configured with
    auth: "aws-sdk" and adopts it for automations that have no recorded account,
    so existing installs are repaired without re-running setup.
  • openclaw models auth logout amazon-bedrock:aws-sdk revokes it: bound
    automations are refused ("was removed or signed out"), and recreating the same
    id does not revive them ("was replaced") until the account is selected again
    explicitly — Doctor does not silently re-adopt a retired binding. Removing the
    record while a scheduled run is preparing its provider auth is refused too
    ("was removed or replaced during the run"), before the credential is installed
    for the request.
  • Required action for existing installs: run openclaw doctor --fix once.
  • If amazon-bedrock:aws-sdk is already taken by a different account, nothing is
    overwritten; Doctor reports the conflict and asks you to sign that account out
    or rename it.

Why This Change Was Made

An OpenClaw authorization is the lifetime of an OpenClaw-owned auth-store
record, not a provider-side identity: auth-profiles/authorization.ts derives
authorizationId from opaque store incarnations. So the fix gives the AWS SDK
route a real store record instead of inventing a second notion of identity.

  • The record is a credential-shaped marker (api_key /
    key: "aws-sdk-credentials", already in the core non-secret marker list, same
    pattern as gcp-vertex-credentials and the Entra dynamic marker). Credentials
    are still resolved per request from the AWS chain; the record only says which
    account OpenClaw owns.
  • Because the binding names a normal record, revocation, recreation and
    re-selection all go through the existing scheduler contract — assertCurrent
    and revalidate already fail closed on a removed or re-created incarnation.
    Nothing hashes config, and no new authorization path was added.
  • captureCronInferenceBinding and Doctor's cron migration previously rejected
    the direct aws-sdk route as an ambient credential; they now record that
    stored account when the planner takes it. The runtime guard in
    embedded-agent-runner/run/auth-plan.ts is untouched: an AWS SDK route with no
    stored account still produces no binding and its scheduled runs are still
    refused.
  • The binding deliberately does not pin an AWS principal. OpenClaw never
    observes one for this route (no sts:GetCallerIdentity is called, see System agent / openclaw tool permanently blocked on ambient AWS credentials: no execution-owner fingerprint for EKS Pod Identity / IRSA / instance roles #141983),
    and pinning one would make the scheduler depend on IAM state it cannot
    re-check.
  • Two owner-side gaps on the way there are fixed with the existing checks. The
    post-preparation re-check in embedded-agent-runner/run/auth-controller.ts
    only ran for a captured OAuth authorization, so an api-key route could install
    a credential whose record had just been removed (the run's own pre-dispatch
    guard still refused the request); a scheduled run's binding owns every auth
    mode, so it is re-observed there too, and Cron names the automation and its
    account in the refusal. Doctor's account creation derived the store owner from
    the default agent, which refuses an explicit multi-agent fleet; the record is a
    shared credential, so it resolves the shared store's own owner.

Docs: docs/providers/bedrock.md gains a scheduled-run section; the
credential-semantics and gateway-auth pages describe the marker account and how
signing it out revokes bindings.

Evidence

Unit and integration coverage: extensions/amazon-bedrock/aws-sdk-auth.test.ts,
extensions/amazon-bedrock/lazy-import.test.ts,
src/agents/auth-profiles/order.test.ts,
src/agents/embedded-agent-runner/run/auth-controller.binding.test.ts,
src/cron/inference-binding.aws-sdk-profile.test.ts,
src/cron/inference-binding-executor.test.ts,
src/cron/isolated-agent.auth-continuity.integration.test.ts,
src/commands/doctor/cron/inference-binding-migration.test.ts,
src/commands/doctor/shared/aws-sdk-auth-account.test.ts — all green, plus
pnpm tsgo:core, tsgo:extensions, tsgo:extensions:test, tsgo:test:src,
oxlint and format on the touched paths.

Live validation on an EC2 host with only an instance role: isolated gateway in a
container, fresh state dir, port 28789, no messaging channels, live Bedrock
global.anthropic.claude-sonnet-5-5 in us-west-2. No IAM or STS call is made
by the change or by its validation.

# Scenario Result
1 Legacy automation with no recorded account (refused on unpatched base: "Automation has no recorded inference account"), then doctor --fix on the patched tree Account created ("Created auth profile amazon-bedrock:aws-sdk … it stores no AWS credentials"), job adopted ("retain amazon-bedrock:aws-sdk"), run "status": "ok", reply READY
2 models auth logout amazon-bedrock:aws-sdk --yes, then trigger the bound job Refused: "Automation inference account amazon-bedrock:aws-sdk … was removed or signed out. Explicitly select an authorized account again."
3 Recreate the same id, trigger again; doctor --fix; then automations edit --model …@amazon-bedrock:aws-sdk Refused: "… was replaced"; doctor --fix leaves the retired binding untouched; after explicit re-selection the binding carries a new authorizationId and the run is "status": "ok", READY
4 Restart the gateway in a new container, record and binding untouched Credentials re-resolved from the chain, run "status": "ok", READY
5 Interactive openclaw agent -m … on the same route Replied INTERACTIVE
6 amazon-bedrock:aws-sdk pre-occupied by a different credential, then doctor --fix Conflict reported, the occupying record left byte-identical, no account created
7 Upgrade from npm [email protected] on the same state dir: explicit ownership, two agents + systemAgent, one Bedrock automation per agent plus one on a non-Bedrock apiKey provider, then doctor --fix on this build Both Bedrock jobs adopted with per-agent authorization ids, both live runs "status": "ok" / READY; config keeps every authored setting (Doctor adds only its own defaults and run metadata)
8 Fresh install: openclaw onboard --non-interactive --auth-choice amazon-bedrock-aws-sdk on clean state Account saved (marker only), auth: "aws-sdk" written, a new automation runs "status": "ok" / READY
9 24 raced attempts removing the record through models.authLogout at measured offsets into a scheduled run, Bedrock requests counted outside the product by a CONNECT-tunnel proxy Every removal that landed before the run's last pre-dispatch check prevented the request: 13 attempts with zero Bedrock requests and a refusal naming the retired account

The stored record is the marker only, read straight out of the state database:

amazon-bedrock:aws-sdk -> {"type":"api_key","provider":"amazon-bedrock","key":"aws-sdk-credentials"}

and the binding scenario 1 produces is

{"version":1,"provider":"amazon-bedrock","profileId":"amazon-bedrock:aws-sdk",
 "authorizationId":"ca9ddee0…","authRequirement":"api-key","source":"auto"}

(authRequirement is "api-key" because CronInferenceBinding admits only
api-key | subscription; it records the requirement class, not a stored key.)
Signing out rotates the account's authorization lifetime, which is what retires
the binding. A scan for AKIA|ASIA|SecretAccessKey|SessionToken across every
state directory and evidence log matches nothing, and no IAM or STS call is made
anywhere in the change or its validation.

Known limits

  • Per-account awsProfile / roleArn are out of scope; the region is carried by
    the plugin's discovery.region, otherwise the chain's own environment applies.
  • One account per provider: if several marker records exist for one provider the
    lexicographically first is used. Choosing among multiple AWS accounts is
    [Feature]: Explicitly authorize cross-provider cron fallback accounts #192009.
  • A retired binding needs an explicit automations edit --model <model>@<profileId>
    (or a fresh unbound job); Doctor only adopts accounts for automations that have
    no binding at all.
  • Revocation is observed at the owner checks a run makes, so a removal that
    commits in the last few tens of milliseconds before the request is written to
    the socket does not cancel that one in-flight request (measured live: 8 of 24
    raced attempts). Signing out stops every later run, and a whole-provider sign
    out aborts runs that have not dispatched yet.

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Maintainer security review required

This external contributor PR changes sensitive security components. A maintainer must review these changes before merging.

Current SHA: 4842a0ec169c341b568a179c3f49aaa65d3b5184

These sensitive security changes were made:

  • src/agents/auth-profiles/aws-sdk-account.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/order.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/embedded-agent-runner/run/auth-controller.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/model-auth-markers.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

After reviewing the changes, post a new PR comment containing only approval commands, each on its own line:

/allow-security-sensitive-change

A later push requires a fresh approval comment.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 4, 2026
@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Adds a revocable AWS SDK marker account that Bedrock setup creates and Doctor adopts for unbound scheduled automations.

Example: A Bedrock automation uses an EC2 instance role and has no recorded inference account.

  • Before: The run fails with “Automation has no recorded inference account,” and no stored profile exists to select.
  • After: Doctor creates amazon-bedrock:aws-sdk, records its authorization lifetime on the automation, and the supplied live run returns READY.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong production-path and upgrade evidence supports a coherent repair with no open code findings; workflow gates remain separate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): Contributor logs exercise Bedrock setup, Doctor adoption, successful scheduled inference, logout/recreation refusal, and post-capture revocation on an isolated EC2 container using instance-role credentials; observed pre-dispatch revocation prevents provider requests.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Bedrock works interactively with host AWS credentials but scheduled automations are refused without an account they can select.
Reason: Restores an existing provider workflow using the established stored-account contract; the new setup and repair paths serve that same failure.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR repairs a current Bedrock scheduling failure, and the earlier findings are resolved; maintainer security approval and an unexplained CI failure remain.

Priority: P1
Reviewed head: e4a22a3358cf0a1a1a4a280ce73c88eb80faad38

Before merge

  • Await maintainer action - A maintainer must review and approve the security-sensitive changes at e4a22a3358cf0a1a1a4a280ce73c88eb80faad38 before merge.

Findings

None.

Tests

  • Missing end-to-end proof: The Doctor-adoption test's supplied negative replay failed on a missing export rather than the behavioral assertion; the live stable-to-patched comparison separately demonstrates the user-visible repair.
Agent review details

How this fits together

Bedrock setup and Doctor create a non-secret account record; Cron binds its lifetime, and the agent checks that authority before dispatching inference through the AWS SDK credential chain.

flowchart LR
  A[Setup or Doctor] --> B[Auth store marker account]
  B --> C[Cron inference binding]
  C --> D[Agent authority checks]
  D --> E[Bedrock transport]
  F[AWS credential chain] --> E
Loading

Technical review

Best possible solution:

Use the existing auth-store lifetime for the AWS SDK marker, with Doctor adoption and unchanged revocation checks.

Do we have a high-confidence way to reproduce the issue?

Current-main capture and Doctor paths reject AWS SDK sources without a stored account, and the contributor supplied a matching 2026.10.10 CLI failure; no target code was executed during this review.

Is this the best way to solve the issue?

The marker-account approach fits the existing authorization owner, preserves config-only interactive routing, and avoids a second identity or revocation mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 42a23ab0744c.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still lacks the repair: Fetched main rejects a direct AWS SDK source during binding capture, while Bedrock setup still registers no auth methods. (src/cron/inference-binding.runtime.ts:213, 42a23ab0744c)
  • Introduced patch and existing authority owner: The pinned introduction diff adds a stored marker and reuses captureAuthProfileAuthorization; the authorization owner hashes store incarnations and observes retirement rather than treating a profile name as authority. (src/cron/inference-binding.runtime.ts:222, e4a22a3358cf)
  • Upgrade proof: The contributor's raw logs show the 2026.10.10 refusal, preserved authored configuration and Bedrock job fields after Doctor, and successful live runs for both agents. Source comment 6630929544 has supplied body SHA-256 5f60d9ead727d90913683256c3e3416edb1ccded33a564498472661a7b792af7.
  • Fresh setup and final-effect proof: The raw logs show non-interactive onboarding saving only the marker, a successful live automation, and post-capture logout attempts refused with zero Bedrock tunnels when observed before dispatch. The discussion explicitly identifies the final-check-to-socket window. Source comment 6630929987 has supplied body SHA-256 c2a944332f897fe39f5cf7039b0cba93994c22f6cdc850b3b9b1a9311b99c392.
  • Preserved scheduling contract: fix(cron): record the planned account for legacy automations instead of failing every run #173509 explicitly left AWS SDK adoption for a follow-up; this PR supplies a durable record while preserving refusal without one and preserving explicit recovery after revocation. (src/cron/inference-binding.runtime.ts:214, 3114e87f42b3)
  • Enforced security approval: The current-head security status remains pending and explicitly requires maintainer approval; no approving PR review was returned. (e4a22a3358cf)

Likely related people:

  • Jason (Json): Raw commit d25a316 adds src/cron/inference-binding.runtime.ts:58 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d25a316fc7c3; files: src/cron/inference-binding.runtime.ts)
  • Vincent Koc: Raw commit bcd1117 adds extensions/amazon-bedrock/register.runtime.ts:66 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bcd11176ef77; files: extensions/amazon-bedrock/register.runtime.ts)

PR surface

Source +426, Tests +472, Docs +42, Other +6. Total +946 across 28 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 15 448 22 +426
Tests 9 489 17 +472
Docs 3 43 1 +42
Config 0 0 0 0
Generated 0 0 0 0
Other 1 6 0 +6
Total 28 986 40 +946

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The official affected release refuses scheduled Bedrock work on AWS SDK credential-chain routes without a usable account-adoption path.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-11-04T06:14:33.230Z sha c39c9f6f1c734365efaa921835f0e0ac5072efc7 :: needs real behavior proof before merge. :: [P1] Preserve revocation across removal and recreation | [P1] Observe declaration revocation after authorization capture | [P1] Preserve existing declarations at the migration profile ID
  • reviewed 2026-11-04T09:08:52.503Z sha 262473359de601062d3eeeb7d8cc0c7875b10e49 :: needs real behavior proof before merge. :: [P1] Resolve the credential owner without requiring a legacy default agent | [P2] Require explicit re-selection when recovering a retired binding
  • reviewed 2026-11-04T12:54:18.392Z sha e4a22a3358cf0a1a1a4a280ce73c88eb80faad38 :: blocked before merge. :: none
  • reviewed 2026-11-04T13:05:05.419Z sha e4a22a3358cf0a1a1a4a280ce73c88eb80faad38 :: blocked before merge. :: none

Reviewed November 4, 2026, 9:24 AM ET / 14:24 UTC (Revision 5).

@yubingjiaocn

Copy link
Copy Markdown
Author

Thanks for the review. Short answer to the decision question first, then how the next revision addresses the findings.

Decision: the binding should not retain an AWS principal. OpenClaw's existing authorization model never binds to a provider-side identity. auth-profiles/authorization.ts derives authorizationId from opaque, owner-issued store incarnations ("never credential or token material"). That holds for API keys and OAuth alike: a profile is "the same account" while its OpenClaw-owned record is the same record. On the AWS side, fingerprintAwsSdkRuntimeOwner deliberately declines to fingerprint AWS_PROFILE and instance/container roles, and nothing in the repo calls STS or IAM. Locking a scheduled binding to a role ARN or account would therefore:

  • introduce a provider-identity check that no other auth route has. GCP ADC passes as synthetic, and Azure Entra is a stored marker profile;
  • make OpenClaw depend on IAM state it does not own;
  • break routine operations such as swapping an instance profile, rotating roles, or moving from EC2 to Pod Identity, where operator intent is unchanged.

IAM decides what the host's credentials can do. OpenClaw only needs to decide whether the operator has authorized scheduled runs on this route, and keep that authorization revocable.

What changes: the root cause of findings 1–2 is that this revision put the declaration in config auth.profiles. That is metadata with no store incarnation, so the id had to be hashed from the name. The next revision follows the microsoft-foundry:entra pattern instead:

  • amazon-bedrock:aws-sdk becomes a real auth-store record holding only a dynamic marker, with no credential material.
  • authorizationId and assertCurrent / revalidate use the existing incarnation and revocation facts. Delete-then-recreate yields a new incarnation, so the old binding is rejected. Deleting or replacing the record mid-run is observed before provider effects.
  • The migration preserves an occupied amazon-bedrock:aws-sdk entry of a different shape. It reports a conflict instead of overwriting it.
  • CI: prune the assertion-safety baseline, and offset or justify the test-lines growth.

Live proof planned (same isolated-container setup on a real AWS account):

  1. Delete the profile record → the bound job is refused.
  2. Recreate the record under the same id → the old binding is refused; doctor --fix re-adopts it and the job runs.
  3. Unchanged record, credentials re-resolved from the chain in a fresh process → the job still runs. This shows credential refresh does not invalidate the binding.

I'll request re-review once the revision and the logs are up.

@yubingjiaocn
yubingjiaocn force-pushed the fix/bedrock-aws-sdk-auth-profile branch from c39c9f6 to 2624733 Compare November 4, 2026 08:59
@yubingjiaocn

Copy link
Copy Markdown
Author

Revised per the direction in my earlier reply: the authorization identity is now
the lifetime of an OpenClaw-owned auth-store record, so none of the four findings
have a code path left to live in. src/agents/auth-profiles/declared-authorization.ts
(and its test) are deleted, and extensions/amazon-bedrock/config-compat.ts is
back to its base shape.

What replaced the config-only declaration

  • The AWS SDK route now owns a real auth-store record, amazon-bedrock:aws-sdk,
    holding OpenClaw's non-secret marker and nothing else:
    {"type":"api_key","provider":"amazon-bedrock","key":"aws-sdk-credentials"}
    (aws-sdk-credentials is registered in CORE_NON_SECRET_API_KEY_MARKERS, the
    same pattern as gcp-vertex-credentials). Credentials are still resolved per
    request from the AWS SDK default chain; the record only names the account
    OpenClaw owns.
  • Bindings are captured by the existing captureAuthProfileAuthorization over
    that record, so authorizationId is the store incarnation. There is no custom
    hash, no new authorization path, and nothing derived from configuration.
  • Doctor creates the record for providers configured with auth: "aws-sdk" and
    adopts it for automations with no recorded account
    (src/commands/doctor/shared/aws-sdk-auth-account.ts).

Per finding

[P1] Preserve revocation across removal and recreation — the name hash is
gone. The id now rotates with the record's incarnation, so a removed account
refuses its bindings and recreating the same id does not revive them:

# after `models auth logout amazon-bedrock:aws-sdk --yes`
"error": "Automation inference account amazon-bedrock:aws-sdk (no recorded runtime)
          was removed or signed out. Explicitly select an authorized account again."

# after recreating the same id, old binding still held by the job
"summary": "Automation inference account amazon-bedrock:aws-sdk (no recorded runtime)
            was replaced. Explicitly select an authorized account again."

doctor --fix does not re-adopt that retired binding — it only records accounts
for automations that have none — so recovery is the explicit re-selection the
refusal asks for:

openclaw automations edit <jobId> --model amazon-bedrock/global.anthropic.claude-sonnet-5-5@amazon-bedrock:aws-sdk
# binding before: authorizationId ca9ddee0… (retired)
# binding after:  authorizationId 8ad645e5…  source "user"  → run "status": "ok"

[P1] Observe declaration revocation after authorization capture — there is no
declaration predicate any more. assertCurrent and revalidate are the existing
store-backed ones, which read the record's incarnation on every check, so a
mid-run removal is observed by the same code that observes it for an API-key
account. Scenario 2 above is that check failing closed (MCP_AUTHORIZATION_RETIRED
in the recorded error chain).

[P1] Preserve existing declarations at the migration profile ID — the config
migration that overwrote auth.profiles[...] is gone; config-compat.ts is
unchanged from base. Doctor creates the record only when the id is free, and
re-checks that under the store lock before writing. An occupied id is preserved
and reported:

Auth profile amazon-bedrock:aws-sdk already holds a api_key credential for
amazon-bedrock, so the amazon-bedrock AWS SDK account was left uncreated.
Sign that account out or rename it, then rerun openclaw doctor --fix.

The occupying record is byte-identical after doctor --fix (live scenario 6, and
src/commands/doctor/shared/aws-sdk-auth-account.test.ts).

[high] Route identity does not establish current account authority — agreed,
and that is why route identity is no longer used. Authority is the auth-store
record's lifetime, i.e. exactly the owner-issued incarnation the scheduler
contract already relies on. The binding deliberately does not pin an AWS
principal: OpenClaw never observes one on this route (no sts:GetCallerIdentity
is called anywhere in this change — see #141983), and pinning one would make
scheduled runs depend on IAM state the gateway cannot re-check. What the account
guarantees is OpenClaw-side: it is the thing an operator can revoke.

This matches how the other cloud routes already work. On AWS, IAM is the authorization system: if the host can obtain credentials from the default chain (instance role, Pod Identity, SSO), IAM has explicitly granted them, and IAM policy decides what they may call. That is the same trust GCP ADC (gcp-vertex-credentials, accepted as synthetic) and Azure Entra (microsoft-foundry:entra, a stored marker profile) get today. OpenClaw's record is the operator's opt-in for scheduled use, revocable on OpenClaw's side. It is not a second check of the cloud principal, so routine role or instance-profile changes don't break scheduled jobs (scenario 4).

Evidence (live, redacted)

EC2 host with only an instance role; isolated gateway in a container on a fresh
state dir, port 28789, no messaging channels; live Bedrock
global.anthropic.claude-sonnet-5-5 in us-west-2.

# Scenario Result
1 legacy automation with no recorded account — refused on unpatched base ("Automation has no recorded inference account"), then doctor --fix on this branch record created (marker only), job adopted, run "status": "ok", reply READY
2 sign the account out, trigger the bound job refused: "was removed or signed out"
3 recreate the same id, trigger; doctor --fix; explicit automations edit --model …@amazon-bedrock:aws-sdk refused: "was replaced"; Doctor leaves the retired binding alone; after re-selection new authorizationId, run "status": "ok"
4 restart the gateway process, record and binding untouched credentials re-resolved from the chain, run "status": "ok"
5 interactive turn on the same route replied INTERACTIVE
6 amazon-bedrock:aws-sdk pre-occupied by a different credential, then doctor --fix conflict reported, occupant unchanged, no record created

Red-on-base is scenario 1's first half (base refuses the same job in the same
state directory) plus the unchanged unit refusal for a route with no stored
account (src/cron/inference-binding-executor.test.ts); the runtime guard in
embedded-agent-runner/run/auth-plan.ts is untouched.

A scan for AKIA|ASIA|SecretAccessKey|SessionToken over every state directory
and evidence log matches nothing: the stored record is the marker, and the state
databases hold no AWS credential material. No IAM or STS API is called by the
change or by its validation.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 4, 2026
@yubingjiaocn
yubingjiaocn force-pushed the fix/bedrock-aws-sdk-auth-profile branch from 2624733 to e4a22a3 Compare November 4, 2026 12:44
@clawsweeper clawsweeper Bot added status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Nov 4, 2026
The plugin registered no auth method, so a Bedrock host using the AWS
default credential chain had no named account. Register an `aws-sdk` method
that declares `auth.profiles.amazon-bedrock:aws-sdk` (mode only, no
credential material) and migrate configs that already set
`models.providers.amazon-bedrock.auth: "aws-sdk"` onto that declaration.
Scheduled agentTurn jobs on an `auth: "aws-sdk"` Bedrock route were refused
with "Automation has no recorded inference account": the route has no stored
credential, so binding capture found nothing to record. A config-declared
`mode: "aws-sdk"` profile is now the account for that route — the
authorization identifies the declaration, so it retires when config stops
declaring it — and Doctor adopts it for legacy automations that have no
binding. The runtime guard is unchanged: an undeclared route stays unbound
and its runs stay refused.
The AWS SDK route's authorization identity now lives in an auth-store
record (`amazon-bedrock:aws-sdk`) that holds only the non-secret
`aws-sdk-credentials` marker, the shape `extensions/microsoft-foundry`
already uses for Entra ID. The record's incarnation is what scheduled
runs bind, so deleting or recreating it revokes an old binding through
the existing store facts instead of a provider-specific hash.

Drops the config-only `auth.profiles` declaration and its name hashing
(`declared-authorization.ts`), restoring `authorization.ts` and the
Bedrock config compatibility path to hashing only owner-issued
incarnations. A legacy `mode: "aws-sdk"` declaration stays eligible when
the store holds the marker, and `runNonInteractive` persists the same
record interactive setup does.
A scheduled run on an AWS SDK route records the stored marker account,
so its binding carries that record's incarnation. Signing the account
out, or recreating it under the same id, refuses the old binding; a
route with no stored account stays unbound and refused, as before.
Doctor creates the `<provider>:aws-sdk` marker record for installs that
only set `models.providers.<provider>.auth: "aws-sdk"`, then adopts it
for legacy unbound automations. An id already held by a different
provider or credential type is preserved and reported as a conflict,
never overwritten; a preview run reports the missing record instead of
writing it.
Documents the stored marker record as the authorization identity for
scheduled Bedrock runs, how Doctor creates or adopts it, what a
conflicting id does, and that signing out revokes bound automations.
Allocates the net test lines the account's regressions add.
…baseUrl

The provider config type requires baseUrl, so the Bedrock fixtures in the new
account tests have to carry one. The eligibility fixture now shares that route
object instead of repeating it, which is why the test-line allocation drops.
The Doctor repair derived the record's owner from the default agent, which
refuses an explicit multi-agent fleet whose default comes from the system
agent. The account is a shared credential every agent's store inherits, so
resolve the shared store's own owner the way the rest of the auth-profile
code does.

Regressions use the shipped fleet shape (explicit ownership, two agents, a
system agent): creation lands in the shared store, an occupied id is left
alone, and each agent's legacy Bedrock automation adopts the record while a
job on another provider's configured key stays untouched.
Doctor records an account only on automations that have none, so rerunning
doctor --fix cannot rebind one whose account was signed out. Name the
refusals and the explicit automations edit --model <model>@<profileId>
recovery instead.
The post-preparation owner check only ran for a captured OAuth
authorization, so an api-key route (the AWS SDK account among them) could
install a credential whose record was removed or replaced while provider
preparation awaited. The run's own request guard still refused the dispatch,
but the revoked credential reached the runtime first. A scheduled run's
binding owns every auth mode, so check it there too.

Mid-run owner failures also surfaced the shared owner's MCP wording; Cron
now names the automation, its account and the recovery instead.

Regressions: the controller rejects without installing the credential when
the record is removed while preparation awaits, and a real isolated Cron run
on an aws-sdk route refuses with zero transport calls.
The plugin test asserted the shape of the config patch against a mocked
store. Assert what the setup owes a later run instead: the saved account is
the one the host resolves for Bedrock, it holds a non-secret marker, no AWS
material reaches the config, a pre-existing account keeps its credential,
and discovery opts in only for a usable region.

Also drop the stored-marker group from the auth-profile order suite, whose
resolver is already covered by the Cron and Doctor regressions.
The runtime provider registration listed no auth methods, so non-interactive
setup refused the choice its own manifest advertises:

  Installed plugin "Amazon Bedrock" did not expose auth choice
  "amazon-bedrock-aws-sdk".

Declare the method on that registration too, which is where the setup choice
resolver reads a plugin's methods from.
The preparation-race regression asserted the message first, so a run of it
against the pre-fix source stopped at the wording and said nothing about the
request. Assert the zero transport calls first: the pre-dispatch check already
prevented the request there, and this change is what moves the refusal to the
preparation boundary and names the retired account.
@beezly

beezly commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

@vincentkoc are you able to review? Automations are pretty unusable for users making use of aws-sdk without this PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation extensions: amazon-bedrock gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. security-review-required security-sensitive-changed size: L status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

2 participants