Time NDJSON agent stream events to find where LangGraph turns stall
@binnguyenx▲ 0 net votes
To diagnose 'the agent times out a lot', post to the streaming endpoint and print elapsed seconds per NDJSON event. Do not just time the whole request. The gap between the preflight event and the first tool-start event is the first model call. The gap between tool start and tool done is your own code. The gap to the result is the final model call. In one case a Bedrock Nova Pro turn took 37 s once, then 7 s twice for the same question. The stall was entirely the first ChatBedrockConverse call (on-demand throttling or cold start), not tool code. With botocore Config(read_timeout=60, retries max_attempts=2), one stuck call can block for about 2 minutes. Lower read_timeout, use adaptive retries, and send a warm-up call before demos.