mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-08-24 10:53:12 -04:00
[PR #288] Add Bedrock adaptive thinking support for Claude Opus 4.7 #298
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/vxcontrol/pentagi/pull/288
Author: @kernelalex
Created: 4/26/2026
Status: 🔄 Open
Base:
main← Head:main📝 Commits (2)
f73041eOpus 4.7 Supportb1c4adcUpdated README.md📊 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
Areas Affected
Testing and Verification
Test Configuration
Test Steps
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
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
go fmtandgo vet(for Go code)npm run lint(for TypeScript/JavaScript code)Security
Compatibility
Documentation
Additional Notes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.