Skip to content

feat: update runtime client with passthrough#434

Open
nborges-aws wants to merge 2 commits intomainfrom
feat/runtimeClient
Open

feat: update runtime client with passthrough#434
nborges-aws wants to merge 2 commits intomainfrom
feat/runtimeClient

Conversation

@nborges-aws
Copy link
Copy Markdown
Contributor

Issue #, if available: Issue #391

Description of changes:

  • Add __getattr__ passthrough with accept_snake_case_kwargs to AgentCoreRuntimeClient
  • Update __init__ to create cp_client and dp_client boto3 clients
  • Control plane allowlisted methods (12):
    • Runtime CRUD: create_agent_runtime, get_agent_runtime, list_agent_runtimes, update_agent_runtime, delete_agent_runtime
    • Endpoint CRUD: create_agent_runtime_endpoint, get_agent_runtime_endpoint, update_agent_runtime_endpoint, delete_agent_runtime_endpoint, list_agent_runtime_endpoints
    • Other: list_agent_runtime_versions, delete_agent_runtime_version
  • Data plane allowlisted methods (2):
    • invoke_agent_runtime, stop_runtime_session
  • Add *_and_wait polling methods using shared wait_until/wait_until_deleted utilities:
    • create_agent_runtime_and_wait, update_agent_runtime_and_wait, delete_agent_runtime_and_wait
    • create_agent_runtime_endpoint_and_wait, update_agent_runtime_endpoint_and_wait
  • Add higher-level orchestration methods:
    • get_aggregated_status — returns runtime + endpoint status in a single call
    • teardown_endpoint_and_runtime — ordered deletion: waits for endpoint deletion then deletes runtime
  • All *_and_wait methods accept WaitConfig for configurable polling behavior and apply convert_kwargs for snake_case support
  • Existing methods (generate_ws_connection, generate_presigned_url, generate_ws_connection_oauth) are untouched

Test plan

  • Unit tests (16 new):
    • Passthrough: CP forwarding, DP forwarding, snake_case conversion, AttributeError on unknown method, CP allowlist contents, DP allowlist contents
    • *_and_wait: create_agent_runtime_and_wait (success + failure), update_agent_runtime_and_wait, delete_agent_runtime_and_wait, update_agent_runtime_endpoint_and_wait
    • Orchestration: get_aggregated_status (success, not found, reraises non-not-found), teardown_endpoint_and_runtime (success, skips missing endpoint)
  • Integration tests (10 total):
    • Passthrough (3): list_agent_runtimes, list_agent_runtimes with snake_case, non-allowlisted method raises
    • Runtime + endpoint CRUD (7): create_agent_runtime_and_wait → get_agent_runtime (camelCase + snake_case) → update_agent_runtime_and_wait → create_agent_runtime_endpoint_and_wait → get_aggregated_status (verifies both runtime + endpoint READY) → teardown_endpoint_and_runtime
    • Requires RUNTIME_ROLE_ARN and RUNTIME_S3_CODE_URI environment variables

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

⚠️ Breaking Change Warning

Found 1 potential breaking change(s) in this PR:

�[1msrc/bedrock_agentcore/runtime/agent_core_runtime_client.py�[0m:84: AgentCoreRuntimeClient.region: �[33mAttribute value was changed�[39m: region -> validate_region(region or session.region_name or 'us-west-2')


Note: This is an automated static analysis check. Some flagged changes may be intentional.
Please confirm each item is expected and, if so, add a migration note to CHANGELOG.md.

max_wait.
"""
response = self.cp_client.create_agent_runtime_endpoint(
**convert_kwargs(kwargs),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we call convert_kwargs once and re-use?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep I'll make this change

response = self.cp_client.create_agent_runtime_endpoint(
**convert_kwargs(kwargs),
)
rid = kwargs.get(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would the behavior here be the same if we checked the field on the converted kwargs once?

My current understanding of the flow is we check for agentRuntimeId, then fallback to the converted ones. However, I thought converting it handled it for us here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct, we can check the converted kwargs once with the same end behavior. I will update

validate_region(region)
self.region = region
session = session if session else boto3.Session()
self.region = region or session.region_name or "us-west-2"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need to validate the region or does boto3 handle this for us? Wondering if this opens us up to poisoning the endpoint? Context: #417

Copy link
Copy Markdown
Contributor Author

@nborges-aws nborges-aws Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boto3 validates the region for its client creation (raises botocore.exceptions.InvalidRegionError for malicious inputs). Self.region is used to construct the websocket URLs, but that method calls validate_region() internally, so technically we are still fine with this region construction

However, we can validate_region on the __init__ construction for safety. I'll make this change

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants