aws / aws/bedrock-agentcore-sdk-python

[BUG] StrandsA2AExecutor served via serve_a2a never hits AgentCore idle session timeout (causes runaway execution environments)

Đang mở
#583 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
761
Fork
147
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
7

Mô tả

### SDK Language

Python

### Strands Version

strands-agents[otel,a2a]==1.45.0

### Language Runtime Version

Python 3.13

### Operating System

python:3.13-slim-bookworm docker image running in agentcore runtime

### Installation Method

other

### Steps to Reproduce

- Create a minimal vanilla Strands agent using the bedrock-agentcore-sdk-python and strands-agents SDKs.
- Wrap the agent using StrandsA2AExecutor(..., enable_a2a_compliant_streaming=True) and serve it using serve_a2a().
- Deploy the application to an AWS Bedrock AgentCore Runtime.
- Invoke the agent normally.
- Monitor the AWS CloudWatch metrics and log streams for the execution environment.

```python
import os

from bedrock_agentcore.runtime import serve_a2a
from strands import Agent
from strands.models.bedrock import BedrockModel
from strands.multiagent.a2a.executor import StrandsA2AExecutor

_MODEL_ID = os.getenv("MODEL_ID", "")
_AGENT_CARD_CONTEXT_ID = "__agent_card__"
_AGENT_DESCRIPTION = (
"An analytics agent"
)
_SYSTEM_PROMPT = (
"You are an analytics assistant."
)

def _build_agent() -> Agent:
return Agent(
model=BedrockModel(model_id=_MODEL_ID),
name="Agent",
description=_AGENT_DESCRIPTION,
system_prompt=_SYSTEM_PROMPT,
)

def _agent_factory(context_id: str) -> Agent:
return _build_agent()

if __name__ == "__main__":
executor = StrandsA2AExecutor(
agent_factory=_agent_factory,
enable_a2a_compliant_streaming=True,
)
serve_a2a(executor)

```

### Expected Behavior

After the client request finishes (or the client disconnects), the underlying ASGI server should cleanly resolve the request. The AgentCore Runtime should then recognize the environment as "Idle", start the idleRuntimeSessionTimeout countdown, and cleanly shut down the microVM once the timeout is reached.

### Actual Behavior

- The AgentCore Runtime considers the environment continuously "Active".
- The idleRuntimeSessionTimeout is never reached.
- Despite there being no further requests for the session, the execution environment remains alive, indefinitely racking up continuous GB-hour billing, until it hits the platform's absolute hard maximum lifetime limit (e.g., 8 hours) and is forcefully killed.

### Additional Context

I don't have the same issue for regular (non-A2A) strands agents.

I originally opened a bug report to the Strands developers https://github.com/strands-agents/harness-sdk/issues/3120 and they said they internally diverted it to the agentcore team. I am making this ticket so there is a publicly accessible way to track the progress.

### Possible Solution

_No response_

### Related Issues

_No response_

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với điểm vào serve_a2a() và StrandsA2AExecutor được cấu hình bằng enable_a2a_compliant_streaming=True, sau đó tái hiện các luồng hoàn tất yêu cầu và ngắt kết nối máy khách trên AWS Bedrock AgentCore. Sử dụng các chỉ số và luồng nhật ký của CloudWatch để xác minh rằng môi trường chuyển sang Idle và idleRuntimeSessionTimeout có thể tắt môi trường sau khi yêu cầu kết thúc.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
aws, python
Lĩnh vực
backend, cloud
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.