Skip to content

AWS Bedrock AgentCore issues

0

I’m running a long-running agentic workflow on AgentCore. Most of the time it works as expected, but I’m seeing an intermittent failure where the agent stops part-way through execution with no corresponding error in the logs. The stop consistently happens around the same point in the workflow - right when the agent makes an outbound request to another service for data. Since the issue doesn’t occur reliably, it’s been difficult to reproduce.

I also noticed another suspicious pattern: the process appears to restart repeatedly even when there are no incoming requests. There are no crash or shutdown logs, but it looks as if the runtime may be restarting silently (or process spawning indefinitely).

Has anyone seen similar behavior or have guidance on how to debug silent restarts or mid-workflow terminations in AgentCore?

1 Answer
0

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:

  1. 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
  1. Increase the session timeout parameter when starting sessions. If you're experiencing browser session timeouts, you can increase the sessionTimeoutSeconds parameter 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

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.