DocsFeaturesAI Agent Configuration

AI Agent Configuration

The AI Agent configuration system gives administrators fine-grained control over agent behavior at two levels: global defaults that apply to all repositories, and per-repository overrides for specific projects. All configuration is managed through REST API endpoints.

For an overview of the AI Agent itself, see AI Agent. To extend the agent with external tools, see MCP Integration.

Configuration hierarchy

Global defaults live in the Lifecycle global_config table under the aiAgent key. Per-repository overrides are stored in the ai_agent_repo_config table and merged on top of global defaults at runtime.

Fields

FieldTypeDefaultDescription
enabledbooleanfalseWhether the AI Agent is available
maxMessagesPerSessionnumber50Maximum messages per chat session
sessionTTLnumber3600Session time-to-live in seconds
providersProviderConfig[][]LLM provider configurations (global only)
additiveRulesstring[][]Extra rules appended to the system prompt
systemPromptOverridestringundefinedFull replacement for the system prompt
excludedToolsstring[][]Tools the agent cannot use
excludedFilePatternsstring[][]Glob patterns for files the agent cannot access
allowedWritePatternsstring[]["lifecycle.yaml", "lifecycle.yml"]Glob patterns for additional file paths the agent is allowed to write to
maxIterationsnumber20Maximum orchestration loop iterations (global only)
maxToolCallsnumber50Maximum total tool calls per query (global only)
maxRepeatedCallsnumber1Maximum repeated calls with same arguments before loop detection (global only)
compressionThresholdnumber80000Token count before conversation history is compressed (global only)
observationMaskingRecencyWindownumber3Number of recent tool results preserved when masking (global only)
observationMaskingTokenThresholdnumber25000Token count before observation masking activates (global only)
toolExecutionTimeoutnumber30000Tool execution timeout in milliseconds (global only)
toolOutputMaxCharsnumber30000Maximum characters in tool output before truncation (global only)
retryBudgetnumber10Maximum retry attempts per query on provider errors (global only)

How merging works

When a repository has an override, the effective configuration is computed by merging the override on top of global defaults:

  • Scalar fields (enabled, maxMessagesPerSession, sessionTTL, systemPromptOverride) — the repository value replaces the global value.
  • Array fields (additiveRules, excludedTools, excludedFilePatterns, allowedWritePatterns) — repository values are appended to global values. Duplicates are removed automatically.

Here’s a concrete example. Say your global config looks like this:

And myorg/frontend has this override:

The effective config for myorg/frontend:

Provider and model configuration

The providers field defines which LLM providers and models are available. This is a global-only field — repository overrides cannot change provider configuration.

Each provider entry has the following structure:

FieldTypeRequiredDescription
namestringYesProvider identifier (anthropic, openai, gemini)
enabledbooleanYesWhether this provider is available
apiKeyEnvVarstringYesEnvironment variable containing the API key
modelsModelConfig[]YesList of models for this provider

Each model entry:

FieldTypeRequiredDescription
idstringYesModel identifier sent to the provider API
displayNamestringYesHuman-readable name shown in the UI dropdown
enabledbooleanYesWhether this model is selectable
defaultbooleanYesWhether this is the default model (one per provider)
maxTokensintegerYesMaximum output tokens for the model
inputCostPerMillionnumberNoCost per 1M input tokens (USD). Enables cost display in the UI
outputCostPerMillionnumberNoCost per 1M output tokens (USD). Enables cost display in the UI

When inputCostPerMillion and outputCostPerMillion are both set for a model, the UI displays a computed cost alongside token counts in the X-Ray debug panel. If either field is omitted, cost is not shown.

Example with pricing configured:

Caching

Configurations are cached at three layers: in-memory (30 seconds), Redis (5 minutes), and the database (source of truth). Updating via the API immediately invalidates both the Redis and in-memory caches for that repository.


Prompt customization

Additive rules

The additiveRules field accepts an array of strings appended to the system prompt. Use this to add organization-specific guidelines, restrict behaviors, or provide extra context.

Because additive rules use additive merge, global rules and repository rules are combined. Set organization-wide rules globally and layer project-specific rules per repository.

System prompt override

The systemPromptOverride field replaces the entire default system prompt. This is a full replacement, not additive.

⚠️

Setting systemPromptOverride replaces the entire built-in system prompt, including safety instructions. Use this only when you need complete control over the agent’s behavior. Maximum length is 50,000 characters.

When set at the repository level, the override applies only to that repository. The scalar merge rule means the repository value fully replaces any global override.


Access control

Excluded tools

The excludedTools field prevents the agent from using specific tools. This is useful for restricting write operations in sensitive repositories.

Available tool names:

  • get_k8s_resources
  • get_lifecycle_logs
  • patch_k8s_resource
  • query_database
  • get_github_file
  • list_github_directory
  • update_github_file
  • get_issue_comment
⚠️

query_database is a core tool and cannot be excluded. Attempting to exclude it returns a 400 error.

Because excluded tools use additive merge, tools excluded at the global level cannot be “un-excluded” at the repository level.

Excluded file patterns

The excludedFilePatterns field accepts glob patterns that restrict which files the agent can access through the GitHub tools.

Validation rules:

RuleLimit
Maximum number of patterns50
Maximum pattern length200 characters
Forbidden patterns*, **, **/* (overly broad)
Path traversal../ is not allowed
Absolute pathsPatterns starting with / not allowed

Like other array fields, file patterns use additive merge. Global patterns and repository patterns are combined and deduplicated.

Allowed write patterns

The allowedWritePatterns field controls which file paths the agent is permitted to modify through the update_file tool. By default, the agent can only write to lifecycle.yaml and lifecycle.yml (plus any files explicitly referenced in the lifecycle configuration such as Dockerfiles and Helm value files).

To allow the agent to modify additional files, add glob patterns to this field. For example, to allow modifications to Helm charts, Dockerfiles, and Ansible playbooks:

⚠️

Setting allowedWritePatterns at the global or repository level defines the full set of writable paths (in addition to files referenced in the lifecycle config). Keep the list minimal to limit the blast radius of agent changes.

Like other array fields, allowed write patterns use additive merge. Global patterns and repository patterns are combined and deduplicated.


Orchestration limits

These fields control the agent’s internal behavior. They are all global-only settings — repository overrides cannot change them. If omitted, the defaults below are used.

Loop protection

Controls for the agent’s tool-calling loop that prevent runaway behavior.

FieldDefaultDescription
maxIterations20Maximum number of LLM round-trips in a single query. Prevents runaway conversations.
maxToolCalls50Maximum total tool invocations across all iterations. Caps resource usage for broad investigations.
maxRepeatedCalls1How many times the same tool can be called with identical arguments before loop detection kicks in.

When a limit is hit, the agent stops and returns an error message to the user explaining what happened.

Context management

Controls how the agent manages conversation context to stay within LLM token limits.

FieldDefaultDescription
compressionThreshold80000Token count at which the conversation history is summarized into a compact form. Higher values preserve more context but use more tokens.
observationMaskingRecencyWindow3Number of recent tool results kept in full when masking older observations. Older results are replaced with placeholders.
observationMaskingTokenThreshold25000Token count at which observation masking activates. Below this threshold, all tool results are kept in full.

Tool execution

Controls for tool execution behavior and output handling.

FieldDefaultDescription
toolExecutionTimeout30000Maximum time in milliseconds a single tool call can run before being terminated. Increase for slow K8s clusters or MCP servers.
toolOutputMaxChars30000Maximum characters in a tool’s output before truncation. Larger values give the agent more data but cost more tokens.

Resilience

Controls for error recovery when communicating with LLM providers.

FieldDefaultDescription
retryBudget10Maximum retry attempts per query when the LLM provider returns transient errors. Higher values improve reliability at the cost of latency.

Increasing these limits allows the agent to perform deeper investigations but consumes more LLM tokens. Lower values are safer for cost control.


Managing configuration via API

All endpoints are under /api/v2/ai/agent-config. Request and response bodies use JSON.

Global configuration

Get the current global config:

Update the global config:

Returns the updated configuration on success. Returns 400 for validation failures (invalid schema, prompt too long, core tool exclusion, bad file patterns).


Repository overrides

List all repository overrides:

Get a single repository override:

Returns only the override fields, not the merged result. Returns 404 if no override exists.

Get the effective (merged) configuration:

Use the /effective endpoint to verify exactly what configuration a repository uses at runtime, after merge.

Create or update a repository override:

Uses upsert semantics. Only include the fields you want to override.

Returns the saved override on success. Returns 400 for validation failures.

Delete a repository override:

Soft-deletes the override. The repository reverts to global defaults.


Troubleshooting

Config changes not taking effect

Configuration is cached at multiple layers. The API automatically invalidates caches on update, but if you changed the database directly, you may need to wait:

  • In-memory cache — expires after 30 seconds
  • Redis cache — expires after 5 minutes

Use the /effective endpoint to confirm what the agent sees.

Cannot exclude a core tool

query_database is required for agent operation. If you include it in excludedTools, the API returns:

Remove it from your exclusion list.

Excluded tool still being used

Array fields use additive merge. If you removed a tool from a repository override but it’s still excluded, check the global config — the tool may be excluded there. Global exclusions cannot be overridden at the repo level.

System prompt override not working as expected

systemPromptOverride completely replaces the built-in prompt, including safety instructions and tool usage guidelines. If the agent behaves unexpectedly, try additiveRules instead — it appends to the default prompt rather than replacing it.