Skip to content

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

feat(providers): expose per-agent extra_body in the provider config

Sergey Kozyrenkocae0295e8b24
diff --git a/backend/pkg/database/converter/converter.go b/backend/pkg/database/converter/converter.go
index 7153833b..e24a5167 100644
--- a/backend/pkg/database/converter/converter.go
+++ b/backend/pkg/database/converter/converter.go
@@ -723,6 +723,10 @@ func ConvertAgentConfigToGqlModel(ac *pconfig.AgentConfig) *model.AgentConfig {
}
}
+ if ac.ExtraBody != nil {
+ result.ExtraBody = ac.ExtraBody
+ }
+
return result
}
@@ -816,6 +820,10 @@ func ConvertAgentConfigFromGqlModel(ac *model.AgentConfig) *pconfig.AgentConfig
}
}
+ if ac.ExtraBody != nil {
+ rawConfig["extra_body"] = ac.ExtraBody
+ }
+
jsonConfig, err := json.Marshal(rawConfig)
if err != nil {
return nil
diff --git a/backend/pkg/graph/generated.go b/backend/pkg/graph/generated.go
index cacfa2b1..e6c1ac11 100644
--- a/backend/pkg/graph/generated.go
+++ b/backend/pkg/graph/generated.go
@@ -76,6 +76,7 @@ type ComplexityRoot struct {
}
AgentConfig struct {
+ ExtraBody func(childComplexity int) int
FrequencyPenalty func(childComplexity int) int
MaxLength func(childComplexity int) int
MaxTokens func(childComplexity int) int
@@ -1020,6 +1021,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.APITokenWithSecret.UserID(childComplexity), true
+ case "AgentConfig.extraBody":
+ if e.complexity.AgentConfig.ExtraBody == nil {
+ break
+ }
+
+ return e.complexity.AgentConfig.ExtraBody(childComplexity), true
+
case "AgentConfig.frequencyPenalty":
if e.complexity.AgentConfig.FrequencyPenalty == nil {
break
@@ -9868,6 +9876,47 @@ func (ec *executionContext) fieldContext_AgentConfig_price(_ context.Context, fi
return fc, nil
}
+func (ec *executionContext) _AgentConfig_extraBody(ctx context.Context, field graphql.CollectedField, obj *model.AgentConfig) (ret graphql.Marshaler) {
+ fc, err := ec.fieldContext_AgentConfig_extraBody(ctx, field)
+ if err != nil {
+ return graphql.Null
+ }
+ ctx = graphql.WithFieldContext(ctx, fc)
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ExtraBody, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(map[string]interface{})
+ fc.Result = res
+ return ec.marshalOMap2map(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) fieldContext_AgentConfig_extraBody(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
+ fc = &graphql.FieldContext{
+ Object: "AgentConfig",
+ Field: field,
+ IsMethod: false,
+ IsResolver: false,
+ Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
+ return nil, errors.New("field of type Map does not have child fields")
+ },
+ }
+ return fc, nil
+}
+
func (ec *executionContext) _AgentLog_id(ctx context.Context, field graphql.CollectedField, obj *model.AgentLog) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_AgentLog_id(ctx, field)
if err != nil {
@@ -10639,6 +10688,8 @@ func (ec *executionContext) fieldContext_AgentsConfig_simple(_ context.Context,
return ec.fieldContext_AgentConfig_reasoning(ctx, field)
case "price":
return ec.fieldContext_AgentConfig_price(ctx, field)
+ case "extraBody":
+ return ec.fieldContext_AgentConfig_extraBody(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AgentConfig", field.Name)
},
@@ -10709,6 +10760,8 @@ func (ec *executionContext) fieldContext_AgentsConfig_simpleJson(_ context.Conte
return ec.fieldContext_AgentConfig_reasoning(ctx, field)
case "price":
return ec.fieldContext_AgentConfig_price(ctx, field)
+ case "extraBody":
+ return ec.fieldContext_AgentConfig_extraBody(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AgentConfig", field.Name)
},
@@ -10779,6 +10832,8 @@ func (ec *executionContext) fieldContext_AgentsConfig_primaryAgent(_ context.Con
return ec.fieldContext_AgentConfig_reasoning(ctx, field)
case "price":
return ec.fieldContext_AgentConfig_price(ctx, field)
+ case "extraBody":
+ return ec.fieldContext_AgentConfig_extraBody(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AgentConfig", field.Name)
},
@@ -10849,6 +10904,8 @@ func (ec *executionContext) fieldContext_AgentsConfig_assistant(_ context.Contex
return ec.fieldContext_AgentConfig_reasoning(ctx, field)
case "price":
return ec.fieldContext_AgentConfig_price(ctx, field)
+ case "extraBody":
+ return ec.fieldContext_AgentConfig_extraBody(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AgentConfig", field.Name)
},
@@ -10919,6 +10976,8 @@ func (ec *executionContext) fieldContext_AgentsConfig_generator(_ context.Contex
return ec.fieldContext_AgentConfig_reasoning(ctx, field)
case "price":
return ec.fieldContext_AgentConfig_price(ctx, field)
+ case "extraBody":
+ return ec.fieldContext_AgentConfig_extraBody(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AgentConfig", field.Name)
},
@@ -10989,6 +11048,8 @@ func (ec *executionContext) fieldContext_AgentsConfig_refiner(_ context.Context,
return ec.fieldContext_AgentConfig_reasoning(ctx, field)
case "price":
return ec.fieldContext_AgentConfig_price(ctx, field)
+ case "extraBody":
+ return ec.fieldContext_AgentConfig_extraBody(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AgentConfig", field.Name)
},
@@ -11059,6 +11120,8 @@ func (ec *executionContext) fieldContext_AgentsConfig_adviser(_ context.Context,
return ec.fieldContext_AgentConfig_reasoning(ctx, field)
case "price":
return ec.fieldContext_AgentConfig_price(ctx, field)
+ case "extraBody":
+ return ec.fieldContext_AgentConfig_extraBody(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AgentConfig", field.Name)
},
@@ -11129,6 +11192,8 @@ func (ec *executionContext) fieldContext_AgentsConfig_reflector(_ context.Contex
return ec.fieldContext_AgentConfig_reasoning(ctx, field)
case "price":
return ec.fieldContext_AgentConfig_price(ctx, field)
+ case "extraBody":
+ return ec.fieldContext_AgentConfig_extraBody(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AgentConfig", field.Name)
},
@@ -11199,6 +11264,8 @@ func (ec *executionContext) fieldContext_AgentsConfig_searcher(_ context.Context
return ec.fieldContext_AgentConfig_reasoning(ctx, field)
case "price":
return ec.fieldContext_AgentConfig_price(ctx, field)
+ case "extraBody":
+ return ec.fieldContext_AgentConfig_extraBody(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AgentConfig", field.Name)
},
@@ -11269,6 +11336,8 @@ func (ec *executionContext) fieldContext_AgentsConfig_enricher(_ context.Context
return ec.fieldContext_AgentConfig_reasoning(ctx, field)
case "price":
return ec.fieldContext_AgentConfig_price(ctx, field)
+ case "extraBody":
+ return ec.fieldContext_AgentConfig_extraBody(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AgentConfig", field.Name)
},
@@ -11339,6 +11408,8 @@ func (ec *executionContext) fieldContext_AgentsConfig_coder(_ context.Context, f
return ec.fieldContext_AgentConfig_reasoning(ctx, field)
case "price":
return ec.fieldContext_AgentConfig_price(ctx, field)
+ case "extraBody":
+ return ec.fieldContext_AgentConfig_extraBody(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AgentConfig", field.Name)
},
@@ -11409,6 +11480,8 @@ func (ec *executionContext) fieldContext_AgentsConfig_installer(_ context.Contex
return ec.fieldContext_AgentConfig_reasoning(ctx, field)
case "price":
return ec.fieldContext_AgentConfig_price(ctx, field)
+ case "extraBody":
+ return ec.fieldContext_AgentConfig_extraBody(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AgentConfig", field.Name)
},
@@ -11479,6 +11552,8 @@ func (ec *executionContext) fieldContext_AgentsConfig_pentester(_ context.Contex
return ec.fieldContext_AgentConfig_reasoning(ctx, field)
case "price":
return ec.fieldContext_AgentConfig_price(ctx, field)
+ case "extraBody":
+ return ec.fieldContext_AgentConfig_extraBody(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type AgentConfig", field.Name)
},
@@ -36650,7 +36725,7 @@ func (ec *executionContext) unmarshalInputAgentConfigInput(ctx context.Context,
asMap[k] = v
}
- fieldsInOrder := [...]string{"model", "maxTokens", "temperature", "topK", "topP", "minLength", "maxLength", "repetitionPenalty", "frequencyPenalty", "presencePenalty", "reasoning", "price"}
+ fieldsInOrder := [...]string{"model", "maxTokens", "temperature", "topK", "topP", "minLength", "maxLength", "repetitionPenalty", "frequencyPenalty", "presencePenalty", "reasoning", "price", "extraBody"}
for _, k := range fieldsInOrder {
v, ok := asMap[k]
if !ok {
@@ -36741,6 +36816,13 @@ func (ec *executionContext) unmarshalInputAgentConfigInput(ctx context.Context,
return it, err
}
it.Price = data
+ case "extraBody":
+ ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("extraBody"))
+ data, err := ec.unmarshalOMap2map(ctx, v)
+ if err != nil {
+ return it, err
+ }
+ it.ExtraBody = data
}
}
@@ -37486,6 +37568,8 @@ func (ec *executionContext) _AgentConfig(ctx context.Context, sel ast.SelectionS
out.Values[i] = ec._AgentConfig_reasoning(ctx, field, obj)
case "price":
out.Values[i] = ec._AgentConfig_price(ctx, field, obj)
+ case "extraBody":
+ out.Values[i] = ec._AgentConfig_extraBody(ctx, field, obj)
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -45617,6 +45701,22 @@ func (ec *executionContext) marshalOKnowledgeGuideType2ᚖpentagiᚋpkgᚋgraph
return v
}
+func (ec *executionContext) unmarshalOMap2map(ctx context.Context, v interface{}) (map[string]interface{}, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := graphql.UnmarshalMap(v)
+ return res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ res := graphql.MarshalMap(v)
+ return res
+}
+
func (ec *executionContext) marshalOMessageLog2ᚕᚖpentagiᚋpkgᚋgraphᚋmodelᚐMessageLogᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.MessageLog) graphql.Marshaler {
if v == nil {
return graphql.Null
diff --git a/backend/pkg/graph/model/models_gen.go b/backend/pkg/graph/model/models_gen.go
index b1acc8b0..ebfb1370 100644
--- a/backend/pkg/graph/model/models_gen.go
+++ b/backend/pkg/graph/model/models_gen.go
@@ -35,18 +35,19 @@ type APITokenWithSecret struct {
}
type AgentConfig struct {
- Model string `json:"model"`
- MaxTokens *int `json:"maxTokens,omitempty"`
- Temperature *float64 `json:"temperature,omitempty"`
- TopK *int `json:"topK,omitempty"`
- TopP *float64 `json:"topP,omitempty"`
- MinLength *int `json:"minLength,omitempty"`
- MaxLength *int `json:"maxLength,omitempty"`
- RepetitionPenalty *float64 `json:"repetitionPenalty,omitempty"`
- FrequencyPenalty *float64 `json:"frequencyPenalty,omitempty"`
- PresencePenalty *float64 `json:"presencePenalty,omitempty"`
- Reasoning *ReasoningConfig `json:"reasoning,omitempty"`
- Price *ModelPrice `json:"price,omitempty"`
+ Model string `json:"model"`
+ MaxTokens *int `json:"maxTokens,omitempty"`
+ Temperature *float64 `json:"temperature,omitempty"`
+ TopK *int `json:"topK,omitempty"`
+ TopP *float64 `json:"topP,omitempty"`
+ MinLength *int `json:"minLength,omitempty"`
+ MaxLength *int `json:"maxLength,omitempty"`
+ RepetitionPenalty *float64 `json:"repetitionPenalty,omitempty"`
+ FrequencyPenalty *float64 `json:"frequencyPenalty,omitempty"`
+ PresencePenalty *float64 `json:"presencePenalty,omitempty"`
+ Reasoning *ReasoningConfig `json:"reasoning,omitempty"`
+ Price *ModelPrice `json:"price,omitempty"`
+ ExtraBody map[string]interface{} `json:"extraBody,omitempty"`
}
type AgentLog struct {
diff --git a/backend/pkg/graph/schema.graphqls b/backend/pkg/graph/schema.graphqls
index 9f8f2f96..7fb3f410 100644
--- a/backend/pkg/graph/schema.graphqls
+++ b/backend/pkg/graph/schema.graphqls
@@ -1,4 +1,5 @@
scalar Time
+scalar Map
# Core execution status for flows, tasks and agents
enum StatusType {
@@ -816,6 +817,7 @@ type AgentConfig {
presencePenalty: Float
reasoning: ReasoningConfig
price: ModelPrice
+ extraBody: Map
}
# All agent type configurations for a provider
@@ -866,6 +868,7 @@ input AgentConfigInput {
presencePenalty: Float
reasoning: ReasoningConfigInput
price: ModelPriceInput
+ extraBody: Map
}
# Input type for AgentsConfig
diff --git a/frontend/e2e/mocks/cassettes/settings-providers.ts b/frontend/e2e/mocks/cassettes/settings-providers.ts
index 6ad39910..7ca89a22 100644
--- a/frontend/e2e/mocks/cassettes/settings-providers.ts
+++ b/frontend/e2e/mocks/cassettes/settings-providers.ts
@@ -18,6 +18,7 @@ const T = '2026-01-15T09:00:00Z';
const agentConfig = (): AgentConfigFragmentFragment =>
entity('AgentConfig', {
+ extraBody: null,
frequencyPenalty: null,
maxLength: null,
maxTokens: null,
diff --git a/frontend/graphql-codegen.ts b/frontend/graphql-codegen.ts
index fe73779a..2e62d8ba 100644
--- a/frontend/graphql-codegen.ts
+++ b/frontend/graphql-codegen.ts
@@ -9,7 +9,7 @@ const config: CodegenConfig = {
enumType: 'native',
exportFragmentSpreadSubTypes: true,
inlineFragmentTypes: 'combine',
- scalars: { Time: 'string' },
+ scalars: { Map: 'Record<string, unknown>', Time: 'string' },
skipTypename: true,
useTypeImports: true,
},
diff --git a/frontend/graphql-schema.graphql b/frontend/graphql-schema.graphql
index 0cc6479d..115c39e1 100644
--- a/frontend/graphql-schema.graphql
+++ b/frontend/graphql-schema.graphql
@@ -332,6 +332,7 @@ fragment agentConfigFragment on AgentConfig {
cacheRead
cacheWrite
}
+ extraBody
}
fragment userPromptFragment on UserPrompt {
diff --git a/frontend/src/graphql/types.ts b/frontend/src/graphql/types.ts
index 18428ba0..62ad1541 100644
--- a/frontend/src/graphql/types.ts
+++ b/frontend/src/graphql/types.ts
@@ -4,6 +4,7 @@ type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
export type AgentConfigInput = {
+ extraBody?: Record<string, unknown> | null | undefined;
frequencyPenalty?: number | null | undefined;
maxLength?: number | null | undefined;
maxTokens?: number | null | undefined;
@@ -546,6 +547,7 @@ export type AgentConfigFragmentFragment = {
repetitionPenalty: number | null;
frequencyPenalty: number | null;
presencePenalty: number | null;
+ extraBody: Record<string, unknown> | null;
reasoning: { mode: ReasoningMode | null; effort: ReasoningEffort | null; maxTokens: number | null } | null;
price: { input: number; output: number; cacheRead: number; cacheWrite: number } | null;
};
@@ -2189,6 +2191,7 @@ export const AgentConfigFragmentFragmentDoc = {
],
},
},
+ { kind: 'Field', name: { kind: 'Name', value: 'extraBody' } },
],
},
},
@@ -2379,6 +2382,7 @@ export const AgentsConfigFragmentFragmentDoc = {
],
},
},
+ { kind: 'Field', name: { kind: 'Name', value: 'extraBody' } },
],
},
},
@@ -2454,6 +2458,7 @@ export const ProviderConfigFragmentFragmentDoc = {
],
},
},
+ { kind: 'Field', name: { kind: 'Name', value: 'extraBody' } },
],
},
},
@@ -3904,6 +3909,7 @@ export const SettingsProvidersDocument = {
],
},
},
+ { kind: 'Field', name: { kind: 'Name', value: 'extraBody' } },
],
},
},
@@ -8808,6 +8814,7 @@ export const CreateProviderDocument = {
],
},
},
+ { kind: 'Field', name: { kind: 'Name', value: 'extraBody' } },
],
},
},
@@ -9080,6 +9087,7 @@ export const UpdateProviderDocument = {
],
},
},
+ { kind: 'Field', name: { kind: 'Name', value: 'extraBody' } },
],
},
},
@@ -11308,6 +11316,7 @@ export const ProviderCreatedDocument = {
],
},
},
+ { kind: 'Field', name: { kind: 'Name', value: 'extraBody' } },
],
},
},
@@ -11543,6 +11552,7 @@ export const ProviderUpdatedDocument = {
],
},
},
+ { kind: 'Field', name: { kind: 'Name', value: 'extraBody' } },
],
},
},
@@ -11778,6 +11788,7 @@ export const ProviderDeletedDocument = {
],
},
},
+ { kind: 'Field', name: { kind: 'Name', value: 'extraBody' } },
],
},
},
diff --git a/frontend/src/pages/settings/settings-provider-extra-body.test.ts b/frontend/src/pages/settings/settings-provider-extra-body.test.ts
new file mode 100644
index 00000000..ad6b0d45
--- /dev/null
+++ b/frontend/src/pages/settings/settings-provider-extra-body.test.ts
@@ -0,0 +1,81 @@
+import { describe, expect, it } from 'vitest';
+
+import type { ProviderType } from '@/graphql/types';
+
+import { normalizeGraphQLData, optionalJsonObject, transformFormToGraphQL } from './settings-provider';
+
+describe('extraBody JSON validation', () => {
+ it.each([
+ ['undefined', undefined],
+ ['empty string', ''],
+ ['whitespace only', ' \n '],
+ ['empty object', '{}'],
+ ['nested object', '{"chat_template_kwargs": {"enable_thinking": false}}'],
+ ])('accepts %s', (_label, value) => {
+ expect(optionalJsonObject.safeParse(value).success).toBe(true);
+ });
+
+ it.each([
+ ['an array', '[1, 2]'],
+ ['a bare string', '"hello"'],
+ ['a bare number', '42'],
+ ['malformed JSON', '{not: json}'],
+ ['a trailing comma', '{"a": 1,}'],
+ ])('rejects %s', (_label, value) => {
+ expect(optionalJsonObject.safeParse(value).success).toBe(false);
+ });
+});
+
+const formWithExtraBody = (extraBody: string) => ({
+ agents: { simple: { extraBody, model: 'm' } },
+ name: 'provider',
+ type: 'openai' as ProviderType,
+});
+
+describe('transformFormToGraphQL extraBody', () => {
+ it('parses the JSON text into an object for the mutation', () => {
+ const { agents } = transformFormToGraphQL(formWithExtraBody('{"a": 1, "b": {"c": 2}}'));
+
+ expect(agents.simple.extraBody).toEqual({ a: 1, b: { c: 2 } });
+ });
+
+ it('sends null for empty or whitespace-only text', () => {
+ expect(transformFormToGraphQL(formWithExtraBody('')).agents.simple.extraBody).toBeNull();
+ expect(transformFormToGraphQL(formWithExtraBody(' ')).agents.simple.extraBody).toBeNull();
+ });
+});
+
+describe('normalizeGraphQLData extraBody', () => {
+ it('serializes an object into indented JSON text for the field', () => {
+ const result = normalizeGraphQLData({ extraBody: { enable_thinking: false } }) as { extraBody: string };
+
+ expect(result.extraBody).toBe('{\n "enable_thinking": false\n}');
+ });
+
+ it('renders a missing extraBody as an empty string', () => {
+ expect((normalizeGraphQLData({ extraBody: null }) as { extraBody: string }).extraBody).toBe('');
+ });
+
+ it('does not recurse into the user JSON (keeps a nested __typename key)', () => {
+ const result = normalizeGraphQLData({ extraBody: { __typename: 'kept' } }) as { extraBody: string };
+
+ expect(result.extraBody).toContain('__typename');
+ });
+});
+
+describe('extraBody load → submit round-trip', () => {
+ it('preserves the object through normalize then transform', () => {
+ const original = { chat_template_kwargs: { enable_thinking: false }, top_k: 20 };
+ const normalized = normalizeGraphQLData({ simple: { extraBody: original, model: 'm' } }) as {
+ simple: { extraBody: string; model: string };
+ };
+
+ const { agents } = transformFormToGraphQL({
+ agents: normalized,
+ name: 'provider',
+ type: 'openai' as ProviderType,
+ });
+
+ expect(agents.simple.extraBody).toEqual(original);
+ });
+});
diff --git a/frontend/src/pages/settings/settings-provider.tsx b/frontend/src/pages/settings/settings-provider.tsx
index a05e5853..0cbda151 100644
--- a/frontend/src/pages/settings/settings-provider.tsx
+++ b/frontend/src/pages/settings/settings-provider.tsx
@@ -57,6 +57,7 @@ import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
import { Spinner } from '@/components/ui/spinner';
+import { Textarea } from '@/components/ui/textarea';
import {
AgentConfigType,
CreateProviderDocument,
@@ -546,8 +547,59 @@ function FormModelComboboxItem<T extends FieldValues = FieldValues>({
);
}
+function FormTextareaItem<T extends FieldValues = FieldValues>({
+ control,
+ description,
+ disabled,
+ label,
+ name,
+ placeholder,
+}: FormInputStringItemProps<T>) {
+ const { field, fieldState } = useController({ control, defaultValue: undefined, disabled, name });
+
+ return (
+ <FormItem>
+ <FormLabel>{label}</FormLabel>
+ <FormControl>
+ <Textarea
+ {...field}
+ aria-invalid={fieldState.error ? true : undefined}
+ className="font-mono text-xs"
+ maxHeight={320}
+ minHeight={80}
+ placeholder={placeholder}
+ value={field.value ?? ''}
+ />
+ </FormControl>
+ {description && <FormDescription>{description}</FormDescription>}
+ {fieldState.error && <FormMessage>{fieldState.error.message}</FormMessage>}
+ </FormItem>
+ );
+}
+
const optionalNumber = z.number().nullable().optional();
+// Only a JSON object round-trips: extraBody merges into the request body as key/value pairs.
+export const optionalJsonObject = z
+ .string()
+ .optional()
+ .refine(
+ (value) => {
+ if (!value?.trim()) {
+ return true;
+ }
+
+ try {
+ const parsed: unknown = JSON.parse(value);
+
+ return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed);
+ } catch {
+ return false;
+ }
+ },
+ { message: 'Must be a valid JSON object' },
+ );
+
const requiredString = (message: string) =>
z
.string()
@@ -557,6 +609,7 @@ const requiredString = (message: string) =>
const agentConfigSchema = z
.object({
+ extraBody: optionalJsonObject,
frequencyPenalty: optionalNumber,
maxLength: optionalNumber,
maxTokens: optionalNumber,
@@ -820,7 +873,7 @@ function ReasoningFields({
);
}
-const transformFormToGraphQL = (
+export const transformFormToGraphQL = (
formData: FormInput,
): {
agents: AgentsConfigInput;
@@ -831,6 +884,7 @@ const transformFormToGraphQL = (
.filter(([key, data]) => key !== '__typename' && data?.model)
.reduce((configs, [key, data]) => {
const config: AgentConfigInput = {
+ extraBody: data?.extraBody?.trim() ? (JSON.parse(data.extraBody) as Record<string, unknown>) : null,
frequencyPenalty: data?.frequencyPenalty ?? null,
maxLength: data?.maxLength ?? null,
maxTokens: data?.maxTokens ?? null,
@@ -873,7 +927,7 @@ const transformFormToGraphQL = (
};
};
-const normalizeGraphQLData = (obj: unknown): unknown => {
+export const normalizeGraphQLData = (obj: unknown): unknown => {
if (obj === null || obj === undefined) {
return obj;
}
@@ -886,7 +940,13 @@ const normalizeGraphQLData = (obj: unknown): unknown => {
return Object.fromEntries(
Object.entries(obj)
.filter(([key]) => key !== '__typename')
- .map(([key, value]) => [key, normalizeGraphQLData(value)]),
+ .map(([key, value]) => {
+ if (key === 'extraBody') {
+ return [key, value && typeof value === 'object' ? JSON.stringify(value, null, 4) : ''];
+ }
+
+ return [key, normalizeGraphQLData(value)];
+ }),
);
}
@@ -1865,6 +1925,20 @@ function SettingsProvider() {
</div>
</div>
</div>
+
+ <div className="col-span-full p-px">
+ <div className="mt-6 flex flex-col gap-4">
+ <h4 className="text-sm font-medium">Extra Body</h4>
+ <FormTextareaItem
+ control={control}
+ description="Provider-specific request body fields as a JSON object, merged into every call (e.g. vLLM chat_template_kwargs)."
+ disabled={isLoading}
+ label="Extra Body (JSON)"
+ name={`agents.${agentKey}.extraBody`}
+ placeholder={'{\n "chat_template_kwargs": { "enable_thinking": false }\n}'}
+ />
+ </div>
+ </div>
</AccordionContent>
</AccordionItem>
))}