narashq opened a new pull request, #77091:
URL: https://github.com/apache/airflow/pull/77091

   Adds `BedrockAgentRuntimeReadySensor` to the Amazon provider.
   
   **Why**
   
   Other Bedrock resources in the provider (knowledge bases, customization 
jobs, provisioned throughput, batch inference) have sensors, but an AgentCore 
Runtime does not. When the runtime is created or updated outside the DAG (for 
example by an infrastructure pipeline), there was no way to wait for it to 
become `READY` before `BedrockInvokeAgentRuntimeOperator` calls it.
   
   **What**
   
   - `sensors/bedrock.py`: 
`BedrockAgentRuntimeReadySensor(BedrockBaseSensor[BedrockAgentCoreControlHook])`
     - polls `get_agent_runtime`; `CREATING` / `UPDATING` keep waiting, `READY` 
succeeds
     - `CREATE_FAILED` / `UPDATE_FAILED` / `DELETING` / `DELETE_FAILED` fail 
with the service `failureReason` (through the existing `get_failure_reason` 
hook of `BedrockBaseSensor`; the describe response from `get_state` is reused, 
so a failure does not describe the runtime twice)
     - `agent_runtime_version` is optional; when given it is passed through to 
`get_agent_runtime`, for example to watch the version returned by an update
     - deferrable mode resolves the version and ARN once and defers to the 
existing `BedrockAgentRuntimeReadyTrigger` / `agent_runtime_ready` waiter
     - the `_GenericBedrockHook` TypeVar gains `BedrockAgentCoreControlHook`
   - `tests/unit/.../sensors/test_bedrock.py`: hook wiring, every state, 
failure reason with/without, single describe on failure, version passthrough, 
deferrable hand-off
   - `docs/operators/bedrock.rst`: new 
`howto/sensor:BedrockAgentRuntimeReadySensor` section
   - `tests/system/.../example_bedrock_agentcore.py`: the system test now 
creates the runtime with `wait_for_completion=False` and waits with the sensor 
before invoking it
   
   **Notes**
   
   - `DELETE_FAILED` is in the sensor's failure states because 
`BedrockBaseSensor.poke` treats any non-intermediate state as success. The 
`agent_runtime_ready` waiter does not list `DELETE_FAILED` yet; happy to add it 
there in a follow-up if wanted.
   - Verified locally: `ruff format --check` / `ruff check` (ruff 0.17.3) 
clean; `pytest providers/amazon/tests/unit/amazon/aws/sensors/test_bedrock.py` 
→ 54 passed.
   - End to end against a real account (ap-northeast-1, control-plane calls 
only, no invocations), running the sensor and 
`BedrockCreateAgentRuntimeOperator(wait_for_completion=False)` directly:
     - poke path: observed `CREATING` → `READY` on the second poke (15 s)
     - deferrable path: one `get_agent_runtime` resolved 
`agent_runtime_version='1'` and the ARN, `TaskDeferred` to 
`BedrockAgentRuntimeReadyTrigger`, the `agent_runtime_ready` waiter logged 
`CREATING` then returned `{'status': 'success', ...}`, and the follow-up `poke` 
confirmed `READY`
     - failure path: a runtime created from an artifact without its entry point 
went `CREATE_FAILED`; the sensor raised `Bedrock AgentCore Runtime ready sensor 
failed. Failure reasons: The specified entrypoint could not be found or 
accessed in your artifact. Please verify the entrypoint path is correct.`
     - The full `example_bedrock_agentcore` system test DAG was not run through 
a scheduler on my side.
   
   <!-- SPDX-License-Identifier: Apache-2.0
        https://www.apache.org/licenses/LICENSE-2.0 -->
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (Kiro)
   
   Generated-by: Kiro following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   ---
   
   * Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information. Note: commit author/co-author name and email in commits 
become permanently public when merged.
   * For fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [PR] Add BedrockAgentRuntimeRe... narashq (via GitHub) via commits

Reply via email to