autogen icon indicating copy to clipboard operation
autogen copied to clipboard

Added capability to customize read and connection timeout for bedrock models

Open akshay20t opened this issue 11 months ago • 9 comments

Why are these changes needed?

With existing AutoGen implementation of Bedrock client class BedrockClient, the Amazon Bedrock inference request gets timed out when the input token size is large (>~10,000 tokens). This happens because the current implementation uses default read and connection timeout values (60 seconds) from boto3 while initializing the Config class. Due to this default value the create method in BedrockClient class raises RuntimeError even though bedrock model is still generating response (as monitored in AWS CloudWatch).

With increasing context window size of LLM in today's Generative AI era, it is important to introduce capability for user-defined read timeouts to support large input tokens for agents.

Related issue number

Closes #5505

Checks

  • [x] I've included any doc changes needed for https://microsoft.github.io/autogen/. See https://microsoft.github.io/autogen/docs/Contribute#documentation to build and test documentation locally.
  • [x] I've added tests (if relevant) corresponding to the changes introduced in this PR.
  • [x] I've made sure all auto checks have passed.

akshay20t avatar Feb 13 '25 09:02 akshay20t

To quick fix the formatting error. Run pre-commit --all-files

ekzhu avatar Feb 13 '25 22:02 ekzhu

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 29.50%. Comparing base (ad3bed3) to head (09486a3).

Files with missing lines Patch % Lines
autogen/oai/bedrock.py 0.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##              0.2    #5529      +/-   ##
==========================================
+ Coverage   29.26%   29.50%   +0.23%     
==========================================
  Files         117      117              
  Lines       13038    13040       +2     
  Branches     2473     2473              
==========================================
+ Hits         3816     3847      +31     
+ Misses       8876     8846      -30     
- Partials      346      347       +1     
Flag Coverage Δ
unittests 29.50% <0.00%> (+0.23%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 13 '25 22:02 codecov[bot]

To quick fix the formatting error. Run pre-commit --all-files

Thanks @ekzhu! Done with reformatting as per pre-commit configuration of the project.

akshay20t avatar Feb 14 '25 08:02 akshay20t

Please agree to the contributor license

ekzhu avatar Feb 14 '25 09:02 ekzhu

@akshay20t - please see above re: license

rysweet avatar Feb 17 '25 16:02 rysweet

@akshay20t it looks like we should add these values to autogen/autogen/oai /client.py in function _configure_openai_config_for_bedrock optional_keys should looks like: optional_keys = ["aws_session_token", "aws_profile_name", "aws_read_timeout","aws_connect_timeout"]

maxx-ukoo avatar Feb 21 '25 16:02 maxx-ukoo

If you would like to contribute this @akshay20t please read and accept the CLA

jackgerrits avatar Feb 26 '25 18:02 jackgerrits

@akshay20t it looks like we should add these values to autogen/autogen/oai /client.py in function _configure_openai_config_for_bedrock optional_keys should looks like: optional_keys = ["aws_session_token", "aws_profile_name", "aws_read_timeout","aws_connect_timeout"]

Thanks @maxx-ukoo for your inputs! I have updated the same.

akshay20t avatar Apr 12 '25 12:04 akshay20t

@akshay20t please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

akshay20t avatar Apr 12 '25 12:04 akshay20t