ag2 icon indicating copy to clipboard operation
ag2 copied to clipboard

feat:[response_format] Bedrock client structured output

Open priyansh4320 opened this issue 1 month ago • 5 comments

Why are these changes needed?

This pull removes the bedrock unsupported warning on structured output / response_format param and adds support for response format referanced via beedrock documentation. https://aws.amazon.com/blogs/machine-learning/structured-data-response-with-amazon-bedrock-prompt-engineering-and-tool-use/

Related issue number

#2225

Checks

  • [x] I've included any doc changes needed for https://docs.ag2.ai/. See https://docs.ag2.ai/latest/docs/contributor-guide/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.

priyansh4320 avatar Nov 25 '25 19:11 priyansh4320

📝 Documentation Analysis

All docs are up to date! 🎉


✅ Latest commit analyzed: e4dc1b7326e5c6d3d51fc36b68d3b831a6f0f2e7 | Powered by Joggr

joggrbot[bot] avatar Nov 25 '25 19:11 joggrbot[bot]

So Im testing out the new changes here but I seem to be getting an error with my async tool calls not being awaited

Call ID: tooluse_o4Tw0b5bS9mZJTlg5dcs3w
Input arguments: {'query': 'FACULTY SCIENCE LTD technology consultancy Old Street London'}
Output:
<coroutine object web_search at 0x10a823e20>
_Group_Tool_Executor (to chat_manager):

***** Response from calling tool (tooluse_o4Tw0b5bS9mZJTlg5dcs3w) *****
<coroutine object web_search at 0x10a823e20>```

KojoOwusu avatar Dec 01 '25 17:12 KojoOwusu

So Im testing out the new changes here but I seem to be getting an error with my async tool calls not being awaited

Call ID: tooluse_o4Tw0b5bS9mZJTlg5dcs3w
Input arguments: {'query': 'FACULTY SCIENCE LTD technology consultancy Old Street London'}
Output:
<coroutine object web_search at 0x10a823e20>
_Group_Tool_Executor (to chat_manager):

***** Response from calling tool (tooluse_o4Tw0b5bS9mZJTlg5dcs3w) *****
<coroutine object web_search at 0x10a823e20>```

solved in this PR: https://github.com/ag2ai/ag2/pull/2221

priyansh4320 avatar Dec 01 '25 18:12 priyansh4320

So the changes in 2221 solved the async. Agent runs but when it tries to call structured_output tool i get error:


***** Response from calling tool (tooluse_WcVAwKeaQgyEyO1KAHaTSg) *****
Error: Function __structured_output not found.`

KojoOwusu avatar Dec 02 '25 11:12 KojoOwusu

@priyansh4320 Please add integration tests with real API calls.

randombet avatar Dec 03 '25 00:12 randombet

@priyansh4320 sorry to be impatient but wanted to check in on this

DanCorvesor avatar Dec 03 '25 09:12 DanCorvesor

@priyansh4320 sorry to be impatient but wanted to check in on this

@DanCorvesor integration tests should be done by today. and then we will merge bedrock PRs. :) thank you checking.

priyansh4320 avatar Dec 03 '25 10:12 priyansh4320

Did you see @KojoOwusu 's above comment tho, seems we've found an issue

DanCorvesor avatar Dec 03 '25 10:12 DanCorvesor

Codecov Report

:x: Patch coverage is 62.68657% with 25 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
autogen/oai/bedrock.py 62.68% 15 Missing and 10 partials :warning:
Files with missing lines Coverage Δ
autogen/oai/bedrock.py 62.30% <62.68%> (+15.61%) :arrow_up:

... and 13 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Dec 08 '25 13:12 codecov[bot]