-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Bug Description
The agentcore invoke command can invoke an agent in the wrong AWS region. The TUI displays one region (e.g. us-east-1) but the actual API call targets a different region (e.g. us-west-2), causing an error like:
ResourceNotFoundException: Agent runtime arn:aws:bedrock-agentcore:us-west-2:... not found
Root Cause
In src/lib/schemas/io/config-io.ts:122-153, the readAWSDeploymentTargets() method silently overrides the saved deployment region with:
AWS_REGIONorAWS_DEFAULT_REGIONenvironment variables- The region from the user's AWS profile config
This override happens at read time, so the region used for invocation can differ from the region where the agent was actually deployed. The agent's runtime ARN still contains the original deploy region, creating a mismatch.
Steps to Reproduce
- Deploy an agent to
us-east-1:agentcore deploy - Set
AWS_REGION=us-west-2in your environment (or have a profile that defaults tous-west-2) - Run
agentcore invoke - The TUI shows
Target: us-east-1but the invoke call targetsus-west-2, resulting in aResourceNotFoundException
Expected Behavior
The invoke command should use the region where the agent was actually deployed (i.e. the region embedded in the runtime ARN or saved in aws-targets.json), not the environment/profile region override.
Suggested Fix
For the invoke command, the region should be derived from the deployed agent's ARN or the saved deployment targets, not overridden by environment variables. The environment/profile region override makes sense for deploy (choosing where to deploy) but not for invoke (targeting an already-deployed resource).
Affected Code
src/lib/schemas/io/config-io.tslines 134-147 — region override logicsrc/cli/commands/invoke/action.tslines 88, 98, 130 — uses overridden regionsrc/cli/tui/screens/invoke/useInvokeFlow.tslines 62, 149 — loads and uses overridden region