Skip to content

Conversation

@ibehren1
Copy link
Contributor

Add Configurable Request Timeout Setting

Summary

This PR adds a configurable timeout setting for agent chat requests, replacing the hardcoded 15-minute timeout with a user-configurable option while maintaining all existing timeout functionality.

Changes Made

🔧 Settings Infrastructure

  • SettingsContext.tsx: Added requestTimeout state with 15-minute default value
  • AgentChatSection.tsx: Added timeout input field in Agent Chat settings
  • SettingPage.tsx: Connected timeout setting to UI components
  • Persistent storage integration with existing agentChatConfig

💬 Agent Chat Integration

  • useAgentChat.ts: Updated to use configurable requestTimeout instead of hardcoded value
  • Dynamic timeout calculation: requestTimeout * 60 * 1000 (minutes to milliseconds)
  • Enhanced error messages showing actual configured timeout duration

👤 User Experience Improvements

  • Console Logging: Added detailed timeout logging when request is aborted
  • Chat Messages: Timeout notifications now appear directly in chat interface
  • Toast Notifications: Existing toast errors updated with dynamic timeout values
  • Visual Feedback: Maintains existing heartbeat dots and loading indicators

Key Features

Configurable Timeout: Users can set custom timeout values (default: 15 minutes)
Persistent Settings: Timeout preference survives app restarts
Enhanced Feedback: Multiple notification channels (console, chat, toast)
Backward Compatible: Maintains existing 15-minute default behavior
Heartbeat Integration: Works seamlessly with existing 30-second heartbeat monitoring
Request Abortion: Proper cleanup when timeout is reached

Technical Implementation

Settings Flow

  1. User configures timeout in Settings → Agent Chat
  2. Value stored in agentChatConfig.requestTimeout
  3. useAgentChat hook reads setting via useSettings()
  4. Timeout applied to streaming requests dynamically

Timeout Handling

const TIMEOUT_MS = requestTimeout * 60 * 1000 // Convert minutes to milliseconds

// When timeout occurs:
1. Console log: "Request timed out after X minutes - aborting request"
2. Chat message: Assistant message with timeout notification  
3. Toast error: "Request timed out after X minutes"
4. Request abortion: Clean AbortController.abort() call

UI Components

  • Input Field: Number input with validation (min: 1 minute)
  • Help Text: Clear description of timeout functionality
  • Integration: Seamlessly fits into existing Agent Chat settings section

Testing Considerations

  • ✅ Default behavior unchanged (15 minutes)
  • ✅ Settings persistence across app restarts
  • ✅ Dynamic timeout calculation accuracy
  • ✅ Proper request abortion and cleanup
  • ✅ User feedback in all channels (console, chat, toast)
  • ✅ Heartbeat monitoring continues to function
  • ✅ Auto-scroll maintains focus on latest messages

Breaking Changes

None - this is a purely additive feature with backward compatibility.

Related Issues

Addresses timeout configuration requests and improves user control over agent response timeouts.

Screenshots

Settings UI showing new timeout configuration field in Agent Chat section


Ready for Review

Isaac Behrens added 3 commits December 9, 2025 16:51
- Add explicit 5-minute request timeout and 30-second connection timeout to AWS SDK clients
- Implement visual countdown timer showing time remaining until timeout
- Add processing indicator when no data received for 10+ seconds
- Apply timeout configurations to both runtime and agent runtime clients
- Update proxy utils with timeout settings for HTTP handlers

Resolves issue where Bedrock agent interactions would hang indefinitely
during long-running operations without proper timeout handling.
- Add requestTimeout setting to SettingsContext with 15-minute default
- Add timeout input field to Agent Chat settings UI
- Update useAgentChat to use configurable timeout instead of hardcoded 15 minutes
- Add console logging when timeout kills request
- Add timeout message to chat interface for user visibility
- Maintain existing heartbeat monitoring and visual feedback
- Preserve all timeout handling functionality with dynamic configuration
- Add requestTimeout?: number to AgentChatConfig interface
- Resolves TypeScript compilation errors in SettingsContext.tsx
- Ensures type safety for timeout configuration functionality
@ibehren1
Copy link
Contributor Author

Updated to fix type error. Ready for workflow to run again.

@daisuke-awaji daisuke-awaji merged commit 9d3a803 into aws-samples:main Dec 18, 2025
2 checks passed
@daisuke-awaji
Copy link
Contributor

@ibehren1 thanks for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants