[PR #288] Add Bedrock adaptive thinking support for Claude Opus 4.7 #298

Open
opened 2026-06-06 22:10:07 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/vxcontrol/pentagi/pull/288
Author: @kernelalex
Created: 4/26/2026
Status: 🔄 Open

Base: mainHead: main


📝 Commits (2)

📊 Changes

15 files changed (+674 additions, -78 deletions)

View changed files

📝 README.md (+4 -1)
📝 backend/pkg/database/converter/converter.go (+8 -1)
📝 backend/pkg/graph/generated.go (+77 -1)
📝 backend/pkg/graph/model/models_gen.go (+47 -1)
📝 backend/pkg/graph/schema.graphqls (+11 -1)
backend/pkg/providers/bedrock/adaptive_thinking.go (+173 -0)
backend/pkg/providers/bedrock/adaptive_thinking_test.go (+46 -0)
📝 backend/pkg/providers/bedrock/bedrock.go (+11 -4)
📝 backend/pkg/providers/bedrock/config.yml (+2 -1)
📝 backend/pkg/providers/bedrock/models.yml (+11 -0)
📝 backend/pkg/providers/pconfig/config.go (+42 -6)
📝 backend/pkg/providers/pconfig/config_test.go (+46 -0)
📝 frontend/graphql-schema.graphql (+1 -0)
📝 frontend/src/graphql/types.ts (+11 -1)
📝 frontend/src/pages/settings/settings-provider.tsx (+184 -61)

📄 Description

Problem

AWS Bedrock Claude Opus 4.7 rejects the current reasoning payload emitted by PentAGI/langchaingo:

thinking.type.enabled with budget_tokens

Bedrock returns a 400 validation error because Opus 4.7 requires adaptive thinking:

thinking.type.adaptive with output_config.effort

The settings UI also only exposed reasoning effort and max token budget, so users could not configure Bedrock adaptive
thinking from /settings/providers.

Solution

This PR introduces explicit reasoning modes to the provider configuration and settings UI. Here’s what’s included:

New ReasoningMode type: Supports adaptive and budget options, fully wired up across GraphQL, backend config, and frontend type generation.
Updated settings UI: Provider configs now include a Reasoning Mode dropdown with Automatic, Token Budget, and Adaptive options. The max tokens field automatically hides when Adaptive is selected since it’s not applicable.
Adaptive mode enhancements: Added xhigh and max reasoning effort levels. Adaptive mode will auto-select for Bedrock’s Claude Opus and Sonnet 4.6+ models, with Opus 4.7 defaulting to xhigh.
Bedrock middleware: Intercepts adaptive-thinking Converse requests and rewrites them to properly set thinking.type=adaptive and output_config.effort.
Model metadata & docs: Added Claude Opus 4.7 to Bedrock’s model metadata and updated the corresponding documentation.
Backward compatibility: Existing budget-based reasoning setups continue to work exactly as they do now, so there are no breaking changes.

Closes #

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Configuration change
  • 🧪 Test update
  • 🛡️ Security update

Areas Affected

  • Core Services (Frontend UI/Backend API)
  • AI Agents (Researcher/Developer/Executor)
  • Security Tools Integration
  • Memory System (Vector Store/Knowledge Base)
  • Monitoring Stack (Grafana/OpenTelemetry)
  • Analytics Platform (Langfuse)
  • [ x] External Integrations (LLM/Search APIs)
  • [ x] Documentation
  • Infrastructure/DevOps

Testing and Verification

Test Configuration

PentAGI Version: Latest Release (2.0)
Docker Version: Docker version 29.3.1, build c2be9cc
Host OS: Ubuntu 24.04.4 LTS on WSL2
LLM Provider: AWS Bedrock, Claude Opus 4.7
Enabled Features: Langfuse and Grafana

Test Steps

  1. Built and ran a local PentAGI image.
  2. Configured AWS Bedrock with us.anthropic.claude-opus-4-7.
  3. Selected Reasoning Mode: Adaptive and a reasoning effort value in /settings/providers.
  4. Ran provider/agent tests from the settings UI.
  5. Verified the original Bedrock 400 validation error no longer occurs.
  6. Ran focused backend, frontend, formatting, and lint validation.

Test Results

Passed:
cd backend
go test ./pkg/providers/bedrock ./pkg/providers/pconfig ./pkg/database/converter ./pkg/graph
go vet ./pkg/providers/bedrock ./pkg/providers/pconfig ./pkg/database/converter ./pkg/graph

cd frontend
npm run build
npm run test
npx prettier --check src/pages/settings/settings-provider.tsx src/graphql/types.ts graphql-schema.graphql
npx eslint src/pages/settings/settings-provider.tsx

Security Considerations

No new dependencies, credentials, permissions, or environment variables are introduced.

The Bedrock request rewrite only changes the serialized Converse request body for calls explicitly configured with
Adaptive reasoning mode. It does not log request bodies or expose provider secrets.

Performance Impact

Runtime overhead is minimal: adaptive Bedrock calls perform one small JSON body rewrite before the AWS SDK sends the request.

Model-side performance may vary because adaptive thinking lets Claude choose reasoning depth based on task complexity.
This can change latency and output token usage compared with a fixed reasoning token budget.

Documentation Updates

  • README.md updates
  • API documentation updates
  • Configuration documentation updates
  • GraphQL schema updates
  • Other:

Deployment Notes

No migration or environment variable changes are required.
Existing provider configs remain backward compatible. Configs without reasoning.mode keep the previous behavior. For Claude Opus 4.7 on Bedrock, select Reasoning Mode: Adaptive and configure Reasoning Effort instead of Reasoning Max Tokens.

Checklist

Code Quality

  • My code follows the project's coding standards
  • I have added/updated necessary documentation
  • I have added tests to cover my changes
  • All new and existing tests pass
  • I have run go fmt and go vet (for Go code)
  • I have run npm run lint (for TypeScript/JavaScript code)

Security

  • I have considered security implications
  • Changes maintain or improve the security model
  • Sensitive information has been properly handled

Compatibility

  • Changes are backward compatible
  • Breaking changes are clearly marked and documented
  • Dependencies are properly updated

Documentation

  • Documentation is clear and complete
  • Comments are added for non-obvious code
  • API changes are documented

Additional Notes


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/vxcontrol/pentagi/pull/288 **Author:** [@kernelalex](https://github.com/kernelalex) **Created:** 4/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`f73041e`](https://github.com/vxcontrol/pentagi/commit/f73041e225ab49873a5295bd1d479eafde5cb5cd) Opus 4.7 Support - [`b1c4adc`](https://github.com/vxcontrol/pentagi/commit/b1c4adc39043efbc81c17719c64670587466a7ab) Updated README.md ### 📊 Changes **15 files changed** (+674 additions, -78 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+4 -1) 📝 `backend/pkg/database/converter/converter.go` (+8 -1) 📝 `backend/pkg/graph/generated.go` (+77 -1) 📝 `backend/pkg/graph/model/models_gen.go` (+47 -1) 📝 `backend/pkg/graph/schema.graphqls` (+11 -1) ➕ `backend/pkg/providers/bedrock/adaptive_thinking.go` (+173 -0) ➕ `backend/pkg/providers/bedrock/adaptive_thinking_test.go` (+46 -0) 📝 `backend/pkg/providers/bedrock/bedrock.go` (+11 -4) 📝 `backend/pkg/providers/bedrock/config.yml` (+2 -1) 📝 `backend/pkg/providers/bedrock/models.yml` (+11 -0) 📝 `backend/pkg/providers/pconfig/config.go` (+42 -6) 📝 `backend/pkg/providers/pconfig/config_test.go` (+46 -0) 📝 `frontend/graphql-schema.graphql` (+1 -0) 📝 `frontend/src/graphql/types.ts` (+11 -1) 📝 `frontend/src/pages/settings/settings-provider.tsx` (+184 -61) </details> ### 📄 Description #### Problem AWS Bedrock Claude Opus 4.7 rejects the current reasoning payload emitted by PentAGI/langchaingo: thinking.type.enabled with budget_tokens Bedrock returns a 400 validation error because Opus 4.7 requires adaptive thinking: thinking.type.adaptive with output_config.effort The settings UI also only exposed reasoning effort and max token budget, so users could not configure Bedrock adaptive thinking from /settings/providers. #### Solution This PR introduces explicit reasoning modes to the provider configuration and settings UI. Here’s what’s included: New ReasoningMode type: Supports adaptive and budget options, fully wired up across GraphQL, backend config, and frontend type generation. Updated settings UI: Provider configs now include a Reasoning Mode dropdown with Automatic, Token Budget, and Adaptive options. The max tokens field automatically hides when Adaptive is selected since it’s not applicable. Adaptive mode enhancements: Added xhigh and max reasoning effort levels. Adaptive mode will auto-select for Bedrock’s Claude Opus and Sonnet 4.6+ models, with Opus 4.7 defaulting to xhigh. Bedrock middleware: Intercepts adaptive-thinking Converse requests and rewrites them to properly set thinking.type=adaptive and output_config.effort. Model metadata & docs: Added Claude Opus 4.7 to Bedrock’s model metadata and updated the corresponding documentation. Backward compatibility: Existing budget-based reasoning setups continue to work exactly as they do now, so there are no breaking changes. <!-- Enter any applicable Issue number(s) here that will be closed/resolved by this PR. --> Closes # ### Type of Change <!-- Mark with an `x` all options that apply --> - [x] 🐛 Bug fix (non-breaking change which fixes an issue) - [x] 🚀 New feature (non-breaking change which adds functionality) - [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 📚 Documentation update - [x] 🔧 Configuration change - [ ] 🧪 Test update - [ ] 🛡️ Security update ### Areas Affected <!-- Mark with an `x` all components that are affected --> - [x] Core Services (Frontend UI/Backend API) - [x] AI Agents (Researcher/Developer/Executor) - [ ] Security Tools Integration - [ ] Memory System (Vector Store/Knowledge Base) - [ ] Monitoring Stack (Grafana/OpenTelemetry) - [ ] Analytics Platform (Langfuse) - [ x] External Integrations (LLM/Search APIs) - [ x] Documentation - [ ] Infrastructure/DevOps ### Testing and Verification <!-- Please describe the tests that you ran to verify your changes and provide instructions so we can reproduce. --> #### Test Configuration ```yaml PentAGI Version: Latest Release (2.0) Docker Version: Docker version 29.3.1, build c2be9cc Host OS: Ubuntu 24.04.4 LTS on WSL2 LLM Provider: AWS Bedrock, Claude Opus 4.7 Enabled Features: Langfuse and Grafana ``` #### Test Steps 1. Built and ran a local PentAGI image. 2. Configured AWS Bedrock with us.anthropic.claude-opus-4-7. 3. Selected Reasoning Mode: Adaptive and a reasoning effort value in /settings/providers. 4. Ran provider/agent tests from the settings UI. 5. Verified the original Bedrock 400 validation error no longer occurs. 6. Ran focused backend, frontend, formatting, and lint validation. #### Test Results Passed: cd backend go test ./pkg/providers/bedrock ./pkg/providers/pconfig ./pkg/database/converter ./pkg/graph go vet ./pkg/providers/bedrock ./pkg/providers/pconfig ./pkg/database/converter ./pkg/graph cd frontend npm run build npm run test npx prettier --check src/pages/settings/settings-provider.tsx src/graphql/types.ts graphql-schema.graphql npx eslint src/pages/settings/settings-provider.tsx ### Security Considerations No new dependencies, credentials, permissions, or environment variables are introduced. The Bedrock request rewrite only changes the serialized Converse request body for calls explicitly configured with Adaptive reasoning mode. It does not log request bodies or expose provider secrets. ### Performance Impact Runtime overhead is minimal: adaptive Bedrock calls perform one small JSON body rewrite before the AWS SDK sends the request. Model-side performance may vary because adaptive thinking lets Claude choose reasoning depth based on task complexity. This can change latency and output token usage compared with a fixed reasoning token budget. ### Documentation Updates <!-- Note any documentation changes required by this PR --> - [x] README.md updates - [ ] API documentation updates - [x] Configuration documentation updates - [x] GraphQL schema updates - [ ] Other: <!-- specify --> ### Deployment Notes No migration or environment variable changes are required. Existing provider configs remain backward compatible. Configs without reasoning.mode keep the previous behavior. For Claude Opus 4.7 on Bedrock, select Reasoning Mode: Adaptive and configure Reasoning Effort instead of Reasoning Max Tokens. ### Checklist <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> #### Code Quality - [x] My code follows the project's coding standards - [x] I have added/updated necessary documentation - [x] I have added tests to cover my changes - [x] All new and existing tests pass - [x] I have run `go fmt` and `go vet` (for Go code) - [x] I have run `npm run lint` (for TypeScript/JavaScript code) #### Security - [x] I have considered security implications - [x] Changes maintain or improve the security model - [x] Sensitive information has been properly handled #### Compatibility - [x] Changes are backward compatible - [x] Breaking changes are clearly marked and documented - [x] Dependencies are properly updated #### Documentation - [x] Documentation is clear and complete - [x] Comments are added for non-obvious code - [x] API changes are documented ### Additional Notes <!-- Any additional information that would be helpful for reviewers --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-06 22:10:07 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vxcontrol/pentagi#298