Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

feat(bedrock): support external config and model catalog paths (refs #233)

Sergey Kozyrenko06e37d80267d
diff --git a/.env.example b/.env.example
index d0d159e4..faed9285 100644
--- a/.env.example
+++ b/.env.example
@@ -26,6 +26,8 @@ BEDROCK_ACCESS_KEY_ID=
BEDROCK_SECRET_ACCESS_KEY=
BEDROCK_SESSION_TOKEN=
BEDROCK_SERVER_URL=
+BEDROCK_CONFIG_PATH=
+BEDROCK_MODELS_PATH=
## DeepSeek LLM provider
DEEPSEEK_API_KEY=
@@ -145,6 +147,8 @@ PENTAGI_DOCKER_SOCKET=
PENTAGI_DOCKER_CERT_PATH=
PENTAGI_LLM_SERVER_CONFIG_PATH=
PENTAGI_OLLAMA_SERVER_CONFIG_PATH=
+PENTAGI_BEDROCK_CONFIG_PATH=
+PENTAGI_BEDROCK_MODELS_PATH=
## PentAGI security settings
PUBLIC_URL=https://localhost:8443
diff --git a/README.md b/README.md
index fbf70109..f20e717e 100644
--- a/README.md
+++ b/README.md
@@ -1878,6 +1878,8 @@ PentAGI integrates with Amazon Bedrock, offering access to 20+ foundation models
| `BEDROCK_SECRET_ACCESS_KEY` | | AWS secret access key for static credentials |
| `BEDROCK_SESSION_TOKEN` | | AWS session token for temporary credentials (optional, used with static credentials) |
| `BEDROCK_SERVER_URL` | | Custom Bedrock endpoint (VPC endpoints, local testing) |
+| `BEDROCK_CONFIG_PATH` | | Path to a YAML config that replaces the built-in per-agent model/price config |
+| `BEDROCK_MODELS_PATH` | | Path to a YAML model catalog merged onto the built-in models (adds/overrides the UI model list) |
**Authentication Priority**: `BEDROCK_DEFAULT_AUTH` → `BEDROCK_BEARER_TOKEN` → `BEDROCK_ACCESS_KEY_ID`+`BEDROCK_SECRET_ACCESS_KEY`
@@ -1904,6 +1906,26 @@ BEDROCK_SERVER_URL=https://bedrock-runtime.us-east-1.vpce-xxx.amazonaws.com
PROXY_URL=http://your-proxy:8080
```
+#### Custom Provider Config and Models (advanced)
+
+By default the Bedrock provider uses a per-agent config and model catalog compiled into the binary. Two optional paths override them without rebuilding:
+
+- `BEDROCK_CONFIG_PATH` — a YAML file (same shape as the other provider configs) that **replaces** the built-in per-agent model/price assignments. See [`examples/configs/bedrock-glm-flash.provider.yml`](examples/configs/bedrock-glm-flash.provider.yml).
+- `BEDROCK_MODELS_PATH` — a YAML model catalog that is **merged** onto the built-in models: new model ids are added and become selectable under Settings → Providers, while a matching id overrides the built-in entry. See [`examples/configs/bedrock-glm-flash.models.yml`](examples/configs/bedrock-glm-flash.models.yml).
+
+This is useful to expose a Bedrock model newer than the compiled-in catalog — for example Z.AI's `zai.glm-4.7-flash`. Use the exact Model ID from the model's AWS Bedrock detail page; add a `us.`/`eu.`/`apac.` inference-profile prefix only when that page marks the model as requiring cross-region inference (`zai.glm-4.7-flash` is In-Region, so it is used as-is, with no prefix).
+
+With Docker Compose, set the host-side mount source and the in-container path together:
+
+```bash
+# host files mounted into the container
+PENTAGI_BEDROCK_CONFIG_PATH=./examples/configs/bedrock-glm-flash.provider.yml
+PENTAGI_BEDROCK_MODELS_PATH=./examples/configs/bedrock-glm-flash.models.yml
+# tell the backend to read the mounted files
+BEDROCK_CONFIG_PATH=/opt/pentagi/conf/bedrock.provider.yml
+BEDROCK_MODELS_PATH=/opt/pentagi/conf/bedrock.models.yml
+```
+
#### Supported Models
PentAGI supports 21 AWS Bedrock models with tool calling, streaming, and multimodal capabilities. Models marked with `*` are used in default configuration.
diff --git a/backend/cmd/ctester/main.go b/backend/cmd/ctester/main.go
index e1cd7976..85f48253 100644
--- a/backend/cmd/ctester/main.go
+++ b/backend/cmd/ctester/main.go
@@ -168,7 +168,7 @@ func createProvider(providerType string, cfg *config.Config) (provider.Provider,
"BEDROCK_DEFAULT_AUTH=true, BEDROCK_BEARER_TOKEN, or " +
"BEDROCK_ACCESS_KEY_ID+BEDROCK_SECRET_ACCESS_KEY")
}
- providerConfig, err := bedrock.DefaultProviderConfig()
+ providerConfig, err := bedrock.DefaultProviderConfig(cfg)
if err != nil {
return nil, fmt.Errorf("error creating bedrock provider config: %w", err)
}
diff --git a/backend/docs/config.md b/backend/docs/config.md
index f6be6625..f62ef622 100644
--- a/backend/docs/config.md
+++ b/backend/docs/config.md
@@ -118,7 +118,7 @@ These web-console features do not replace the environment variables in this guid
The environment variables documented below remain the source of truth for configuration that is not currently editable from the web console:
-- **LLM credentials and connection settings**: API keys, base URLs, auth modes, and provider-specific connection settings for OpenAI, Anthropic, Bedrock, Ollama, custom providers, and similar backends; config-path settings apply only where supported, such as `OLLAMA_SERVER_CONFIG_PATH` and `LLM_SERVER_CONFIG_PATH`.
+- **LLM credentials and connection settings**: API keys, base URLs, auth modes, and provider-specific connection settings for OpenAI, Anthropic, Bedrock, Ollama, custom providers, and similar backends; config-path settings apply only where supported, such as `OLLAMA_SERVER_CONFIG_PATH`, `LLM_SERVER_CONFIG_PATH`, and `BEDROCK_CONFIG_PATH`/`BEDROCK_MODELS_PATH`.
- **Search provider credentials and options**: DuckDuckGo, Google, Tavily, Traversaal, Perplexity, Searxng, Sploitus, and related search configuration.
- **Third-party integrations**: Langfuse, Graphiti, and other external observability or knowledge services.
- **MCP server management**: MCP settings are not currently exposed as a live web-console feature.
@@ -607,6 +607,8 @@ There is no `VERTEX_API_KEY` or `GOOGLE_APPLICATION_CREDENTIALS` variable wired
| BedrockSecretKey | `BEDROCK_SECRET_ACCESS_KEY` | *(none)* | AWS secret access key for static credentials authentication |
| BedrockSessionToken | `BEDROCK_SESSION_TOKEN` | *(none)* | AWS session token for temporary credentials (optional, used with static credentials for STS/assumed roles) |
| BedrockServerURL | `BEDROCK_SERVER_URL` | *(none)* | Optional custom endpoint URL for Bedrock service (VPC endpoints, local testing) |
+| BedrockConfig | `BEDROCK_CONFIG_PATH` | *(none)* | Path to a custom YAML config that replaces the built-in Bedrock per-agent config (model assignments, prices) |
+| BedrockModels | `BEDROCK_MODELS_PATH` | *(none)* | Path to a custom YAML model catalog merged onto the built-in Bedrock models (adds new ids; matching names override) |
**Authentication Priority**: `BedrockDefaultAuth` (highest) → `BedrockBearerToken` → `BedrockAccessKey`+`BedrockSecretKey` (lowest)
diff --git a/backend/pkg/config/config.go b/backend/pkg/config/config.go
index 37d7ba4e..f1d890d2 100644
--- a/backend/pkg/config/config.go
+++ b/backend/pkg/config/config.go
@@ -117,6 +117,8 @@ type Config struct {
BedrockSecretKey string `env:"BEDROCK_SECRET_ACCESS_KEY"`
BedrockSessionToken string `env:"BEDROCK_SESSION_TOKEN"`
BedrockServerURL string `env:"BEDROCK_SERVER_URL"`
+ BedrockConfig string `env:"BEDROCK_CONFIG_PATH"`
+ BedrockModels string `env:"BEDROCK_MODELS_PATH"`
// === LLM Provider: DeepSeek ===
DeepSeekAPIKey string `env:"DEEPSEEK_API_KEY"`
diff --git a/backend/pkg/graph/schema.resolvers.go b/backend/pkg/graph/schema.resolvers.go
index b3467d3d..95f837f8 100644
--- a/backend/pkg/graph/schema.resolvers.go
+++ b/backend/pkg/graph/schema.resolvers.go
@@ -2074,7 +2074,7 @@ func (r *queryResolver) SettingsProviders(ctx context.Context) (*model.Providers
}
case provider.ProviderBedrock:
config.Default.Bedrock = mpcfg
- if models, err := bedrock.DefaultModels(); err == nil {
+ if models, err := bedrock.DefaultModels(r.Config); err == nil {
config.Models.Bedrock = converter.ConvertModels(models)
}
case provider.ProviderOllama:
diff --git a/backend/pkg/providers/bedrock/bedrock.go b/backend/pkg/providers/bedrock/bedrock.go
index 0c325276..ab300bad 100644
--- a/backend/pkg/providers/bedrock/bedrock.go
+++ b/backend/pkg/providers/bedrock/bedrock.go
@@ -7,6 +7,7 @@ import (
"fmt"
"net/http"
"net/url"
+ "os"
"reflect"
"sync"
@@ -48,8 +49,17 @@ func BuildProviderConfig(configData []byte) (*pconfig.ProviderConfig, error) {
return providerConfig, nil
}
-func DefaultProviderConfig() (*pconfig.ProviderConfig, error) {
- configData, err := configFS.ReadFile("config.yml")
+func DefaultProviderConfig(cfg *config.Config) (*pconfig.ProviderConfig, error) {
+ var (
+ configData []byte
+ err error
+ )
+
+ if cfg.BedrockConfig == "" {
+ configData, err = configFS.ReadFile("config.yml")
+ } else {
+ configData, err = os.ReadFile(cfg.BedrockConfig)
+ }
if err != nil {
return nil, err
}
@@ -57,13 +67,53 @@ func DefaultProviderConfig() (*pconfig.ProviderConfig, error) {
return BuildProviderConfig(configData)
}
-func DefaultModels() (pconfig.ModelsConfig, error) {
+func DefaultModels(cfg *config.Config) (pconfig.ModelsConfig, error) {
configData, err := configFS.ReadFile("models.yml")
if err != nil {
return nil, err
}
- return pconfig.LoadModelsConfigData(configData)
+ models, err := pconfig.LoadModelsConfigData(configData)
+ if err != nil {
+ return nil, err
+ }
+
+ if cfg.BedrockModels == "" {
+ return models, nil
+ }
+
+ externalData, err := os.ReadFile(cfg.BedrockModels)
+ if err != nil {
+ return nil, err
+ }
+
+ externalModels, err := pconfig.LoadModelsConfigData(externalData)
+ if err != nil {
+ return nil, err
+ }
+
+ return mergeModels(models, externalModels), nil
+}
+
+// mergeModels returns base plus override; on a name collision the override entry wins.
+func mergeModels(base, override pconfig.ModelsConfig) pconfig.ModelsConfig {
+ indexByName := make(map[string]int, len(base))
+ merged := make(pconfig.ModelsConfig, len(base))
+ for i, m := range base {
+ indexByName[m.Name] = i
+ merged[i] = m
+ }
+
+ for _, m := range override {
+ if i, ok := indexByName[m.Name]; ok {
+ merged[i] = m
+ } else {
+ indexByName[m.Name] = len(merged)
+ merged = append(merged, m)
+ }
+ }
+
+ return merged
}
type bedrockProvider struct {
@@ -129,7 +179,7 @@ func New(
bclient := bedrockruntime.NewFromConfig(bcfg)
- models, err := DefaultModels()
+ models, err := DefaultModels(cfg)
if err != nil {
return nil, err
}
diff --git a/backend/pkg/providers/bedrock/bedrock_test.go b/backend/pkg/providers/bedrock/bedrock_test.go
index c9470eb4..42e0c52c 100644
--- a/backend/pkg/providers/bedrock/bedrock_test.go
+++ b/backend/pkg/providers/bedrock/bedrock_test.go
@@ -2,6 +2,8 @@ package bedrock
import (
"fmt"
+ "os"
+ "path/filepath"
"sort"
"testing"
@@ -21,7 +23,7 @@ func TestConfigLoading(t *testing.T) {
BedrockSecretKey: "test-key",
}
- providerConfig, err := DefaultProviderConfig()
+ providerConfig, err := DefaultProviderConfig(&config.Config{})
if err != nil {
t.Fatalf("Failed to create provider config: %v", err)
}
@@ -68,7 +70,7 @@ func TestProviderType(t *testing.T) {
BedrockSecretKey: "test-key",
}
- providerConfig, err := DefaultProviderConfig()
+ providerConfig, err := DefaultProviderConfig(&config.Config{})
if err != nil {
t.Fatalf("Failed to create provider config: %v", err)
}
@@ -84,7 +86,7 @@ func TestProviderType(t *testing.T) {
}
func TestModelsLoading(t *testing.T) {
- models, err := DefaultModels()
+ models, err := DefaultModels(&config.Config{})
if err != nil {
t.Fatalf("Failed to load models: %v", err)
}
@@ -113,8 +115,72 @@ func TestModelsLoading(t *testing.T) {
}
}
+func TestBedrockProviderConfigPathOverride(t *testing.T) {
+ dir := t.TempDir()
+ path := filepath.Join(dir, "bedrock.provider.yml")
+ external := "simple:\n model: zai.glm-4.7-flash\n temperature: 0.5\n n: 1\n max_tokens: 1000\n price:\n input: 0.15\n output: 0.6\n"
+ if err := os.WriteFile(path, []byte(external), 0o600); err != nil {
+ t.Fatalf("Failed to write external config: %v", err)
+ }
+
+ cfg := &config.Config{
+ BedrockRegion: "us-east-1",
+ BedrockAccessKey: "test-key",
+ BedrockSecretKey: "test-key",
+ BedrockConfig: path,
+ }
+
+ providerConfig, err := DefaultProviderConfig(cfg)
+ if err != nil {
+ t.Fatalf("Failed to load external provider config: %v", err)
+ }
+
+ prov, err := New(cfg, provider.DefaultProviderNameBedrock, providerConfig)
+ if err != nil {
+ t.Fatalf("Failed to create provider: %v", err)
+ }
+
+ if got := prov.Model(pconfig.OptionsTypeSimple); got != "zai.glm-4.7-flash" {
+ t.Errorf("simple agent model = %q, want zai.glm-4.7-flash (external override)", got)
+ }
+}
+
+func TestBedrockModelsPathMerge(t *testing.T) {
+ embedded, err := DefaultModels(&config.Config{})
+ if err != nil {
+ t.Fatalf("Failed to load embedded models: %v", err)
+ }
+
+ dir := t.TempDir()
+ path := filepath.Join(dir, "bedrock.models.yml")
+ external := "- name: zai.glm-4.7-flash\n description: GLM 4.7 Flash on Bedrock\n thinking: false\n price:\n input: 0.15\n output: 0.6\n"
+ if err := os.WriteFile(path, []byte(external), 0o600); err != nil {
+ t.Fatalf("Failed to write external models: %v", err)
+ }
+
+ merged, err := DefaultModels(&config.Config{BedrockModels: path})
+ if err != nil {
+ t.Fatalf("Failed to load merged models: %v", err)
+ }
+
+ if len(merged) != len(embedded)+1 {
+ t.Errorf("merged models = %d, want %d (embedded + 1 external)", len(merged), len(embedded)+1)
+ }
+
+ found := false
+ for _, m := range merged {
+ if m.Name == "zai.glm-4.7-flash" {
+ found = true
+ break
+ }
+ }
+ if !found {
+ t.Error("external model zai.glm-4.7-flash not found in merged catalog")
+ }
+}
+
func TestBedrockSpecificFeatures(t *testing.T) {
- models, err := DefaultModels()
+ models, err := DefaultModels(&config.Config{})
if err != nil {
t.Fatalf("Failed to load models: %v", err)
}
@@ -154,7 +220,7 @@ func TestGetUsage(t *testing.T) {
BedrockSecretKey: "test-key",
}
- providerConfig, err := DefaultProviderConfig()
+ providerConfig, err := DefaultProviderConfig(&config.Config{})
if err != nil {
t.Fatalf("Failed to create provider config: %v", err)
}
@@ -877,7 +943,7 @@ func TestExtractToolsFromOptions(t *testing.T) {
// TestAuthenticationStrategies verifies all supported authentication methods.
func TestAuthenticationStrategies(t *testing.T) {
- providerConfig, err := DefaultProviderConfig()
+ providerConfig, err := DefaultProviderConfig(&config.Config{})
if err != nil {
t.Fatalf("Failed to create provider config: %v", err)
}
@@ -1020,7 +1086,7 @@ func TestAuthenticationStrategies(t *testing.T) {
// TestAuthenticationErrors verifies error handling for invalid configurations.
func TestAuthenticationErrors(t *testing.T) {
- providerConfig, err := DefaultProviderConfig()
+ providerConfig, err := DefaultProviderConfig(&config.Config{})
if err != nil {
t.Fatalf("Failed to create provider config: %v", err)
}
diff --git a/backend/pkg/providers/providers.go b/backend/pkg/providers/providers.go
index 1c243f7b..4ae6d360 100644
--- a/backend/pkg/providers/providers.go
+++ b/backend/pkg/providers/providers.go
@@ -193,7 +193,7 @@ func NewProviderController(
defaultConfigs[provider.ProviderGemini] = config
}
- if config, err := bedrock.DefaultProviderConfig(); err != nil {
+ if config, err := bedrock.DefaultProviderConfig(cfg); err != nil {
return nil, fmt.Errorf("failed to create bedrock provider config: %w", err)
} else {
defaultConfigs[provider.ProviderBedrock] = config
diff --git a/docker-compose.yml b/docker-compose.yml
index 25599af5..025a6118 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -55,6 +55,8 @@ services:
- BEDROCK_SECRET_ACCESS_KEY=${BEDROCK_SECRET_ACCESS_KEY:-}
- BEDROCK_SESSION_TOKEN=${BEDROCK_SESSION_TOKEN:-}
- BEDROCK_SERVER_URL=${BEDROCK_SERVER_URL:-}
+ - BEDROCK_CONFIG_PATH=${BEDROCK_CONFIG_PATH:-}
+ - BEDROCK_MODELS_PATH=${BEDROCK_MODELS_PATH:-}
- DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY:-}
- DEEPSEEK_SERVER_URL=${DEEPSEEK_SERVER_URL:-}
- DEEPSEEK_PROVIDER=${DEEPSEEK_PROVIDER:-}
@@ -182,6 +184,8 @@ services:
- ${PENTAGI_DOCKER_SOCKET:-/var/run/docker.sock}:/var/run/docker.sock
- ${PENTAGI_LLM_SERVER_CONFIG_PATH:-./example.custom.provider.yml}:/opt/pentagi/conf/custom.provider.yml
- ${PENTAGI_OLLAMA_SERVER_CONFIG_PATH:-./example.ollama.provider.yml}:/opt/pentagi/conf/ollama.provider.yml
+ - ${PENTAGI_BEDROCK_CONFIG_PATH:-./example.bedrock.provider.yml}:/opt/pentagi/conf/bedrock.provider.yml
+ - ${PENTAGI_BEDROCK_MODELS_PATH:-./example.bedrock.models.yml}:/opt/pentagi/conf/bedrock.models.yml
- ${PENTAGI_DOCKER_CERT_PATH:-./docker-ssl}:/opt/pentagi/docker/ssl
user: root:root # while using docker.sock
networks:
diff --git a/examples/configs/bedrock-glm-flash.models.yml b/examples/configs/bedrock-glm-flash.models.yml
new file mode 100644
index 00000000..ac037732
--- /dev/null
+++ b/examples/configs/bedrock-glm-flash.models.yml
@@ -0,0 +1,9 @@
+# Extra Bedrock model catalog merged on top of the built-in models (BEDROCK_MODELS_PATH).
+# Entries with a new name are added; an entry whose name matches a built-in one replaces it.
+- name: zai.glm-4.7-flash
+ description: Z.AI GLM 4.7 Flash on AWS Bedrock — lightweight, low-latency model (203K context, 4K max output)
+ thinking: false
+ release_date: 2026-01-19
+ price:
+ input: 0.15
+ output: 0.6
diff --git a/examples/configs/bedrock-glm-flash.provider.yml b/examples/configs/bedrock-glm-flash.provider.yml
new file mode 100644
index 00000000..3f635eca
--- /dev/null
+++ b/examples/configs/bedrock-glm-flash.provider.yml
@@ -0,0 +1,119 @@
+simple:
+ model: zai.glm-4.7-flash
+ temperature: 0.5
+ top_p: 0.5
+ n: 1
+ max_tokens: 4000
+ price:
+ input: 0.15
+ output: 0.6
+
+simple_json:
+ model: zai.glm-4.7-flash
+ temperature: 0.5
+ top_p: 0.5
+ n: 1
+ max_tokens: 4000
+ json: true
+ price:
+ input: 0.15
+ output: 0.6
+
+primary_agent:
+ model: zai.glm-4.7-flash
+ temperature: 1.0
+ n: 1
+ max_tokens: 4000
+ price:
+ input: 0.15
+ output: 0.6
+
+assistant:
+ model: zai.glm-4.7-flash
+ temperature: 1.0
+ n: 1
+ max_tokens: 4000
+ price:
+ input: 0.15
+ output: 0.6
+
+generator:
+ model: zai.glm-4.7-flash
+ temperature: 1.0
+ n: 1
+ max_tokens: 4000
+ price:
+ input: 0.15
+ output: 0.6
+
+refiner:
+ model: zai.glm-4.7-flash
+ temperature: 1.0
+ n: 1
+ max_tokens: 4000
+ price:
+ input: 0.15
+ output: 0.6
+
+adviser:
+ model: zai.glm-4.7-flash
+ temperature: 1.0
+ n: 1
+ max_tokens: 4000
+ price:
+ input: 0.15
+ output: 0.6
+
+reflector:
+ model: zai.glm-4.7-flash
+ temperature: 1.0
+ n: 1
+ max_tokens: 4000
+ price:
+ input: 0.15
+ output: 0.6
+
+searcher:
+ model: zai.glm-4.7-flash
+ temperature: 1.0
+ n: 1
+ max_tokens: 4000
+ price:
+ input: 0.15
+ output: 0.6
+
+enricher:
+ model: zai.glm-4.7-flash
+ temperature: 1.0
+ n: 1
+ max_tokens: 4000
+ price:
+ input: 0.15
+ output: 0.6
+
+coder:
+ model: zai.glm-4.7-flash
+ temperature: 1.0
+ n: 1
+ max_tokens: 4000
+ price:
+ input: 0.15
+ output: 0.6
+
+installer:
+ model: zai.glm-4.7-flash
+ temperature: 1.0
+ n: 1
+ max_tokens: 4000
+ price:
+ input: 0.15
+ output: 0.6
+
+pentester:
+ model: zai.glm-4.7-flash
+ temperature: 1.0
+ n: 1
+ max_tokens: 4000
+ price:
+ input: 0.15
+ output: 0.6