- Newest
- Most votes
- Most comments
Based on your description, it sounds like you're encountering session timeout issues with Amazon Bedrock AgentCore. By default, AgentCore automatically terminates sessions after 15 minutes (900 seconds) of inactivity. This could explain why your long-running workflow stops at a consistent point, particularly when making outbound requests that might take time to complete.
To address this issue, you have two main options:
- Implement a ping handler with HEALTHY_BUSY status for your async tasks. This keeps the session alive by periodically sending a ping to AgentCore. Here's how you can do it:
import asyncio from bedrock_agentcore.runtime import BedrockAgentCoreApp app = BedrockAgentCoreApp() @app.entrypoint async def long_running_agent(payload, context): # Track if task is still running task_running = True # For long-running tasks, create async task with ping handler async def ping_handler(): while task_running: await context.ping(status="HEALTHY_BUSY") await asyncio.sleep(30) # Ping every 30 seconds # Start ping handler ping_task = asyncio.create_task(ping_handler()) # Your long-running work here result = await perform_long_task() # Clean up task_running = False ping_task.cancel() return result
- Increase the session timeout parameter when starting sessions. If you're experiencing browser session timeouts, you can increase the
sessionTimeoutSecondsparameter from the default 900 seconds (15 minutes) to a longer duration, such as 1800 seconds (30 minutes).
For the repeated process restarts, I recommend enabling comprehensive logging and using Amazon CloudWatch to monitor your agent's performance. AgentCore Observability can help you trace, debug, and monitor your agent's performance in production environments. It provides detailed visualizations of each step in the agent workflow, allowing you to inspect execution paths and debug performance bottlenecks and failures.
By instrumenting your agent code with additional span and trace data, you can gain better visibility into what's happening during these silent failures and identify the root cause of the restarts.
Sources
Troubleshoot AgentCore Runtime - Amazon Bedrock AgentCore
Troubleshoot AgentCore built-in tools - Amazon Bedrock AgentCore
Observe your agent applications on Amazon Bedrock AgentCore Observability - Amazon Bedrock AgentCore
answered a year ago
Relevant content
asked 9 months ago
asked a year ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 7 months ago

I wrote mine without starter toolkit, but do I still need to implement ping handler like the above?
https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/getting-started-custom.html