Context Management & Safeguards Reference¶
This page covers three agent-level configuration areas visible in the ASK platform UI: Context Management, Safeguards, and Tool Access Mode — including how each feature is wired in the codebase, what model it uses, and how it is enabled or disabled.
How Settings Are Applied¶
All three features are configured per-assistant via AssistantSettings (stored in the database) and exposed through the platform UI. The relevant models live in:
| File | Purpose |
|---|---|
src/shared/models/assistant/assistant_contract.py |
Canonical assistant contract — defines all config shapes |
src/assistants/models/assistant_models/settings_model.py |
AssistantSettings Pydantic model |
src/safety/config/settings.py |
Global safety service settings (env vars SAFETY_*) |
src/intelligence/modules/callbacks/before_node_execution.py |
Applies context management before every LLM call |
src/intelligence/modules/callbacks/after_tool_execution.py |
Applies tool output offloading after every tool call |
Context Management¶
Accessed via Configure → Context management in the agent settings UI. Controls what happens when a conversation approaches the model's memory limit.
| Feature | Sheet Feature Name | Description | Config Field | Default | Model Used | Logic File | Enable / Disable | Deployed in MOD SC |
|---|---|---|---|---|---|---|---|---|
| Conversation Summarizer | — | Automatically condenses older parts of the conversation into compact summaries, preserving key context while freeing space for new messages | history_summary.enabledSub-fields: summary_budget_ratio (default 0.5)recent_turns (default 5)max_summary_tokens (default 1024) |
enabled = true | anthropic/claude-haiku-4-5 |
src/shared/llm/context_management/summary_history_manager.pysrc/intelligence/modules/callbacks/before_node_execution.py (lines 93–150) |
Toggle history_summary.enabled true/false in assistant settings |
|
| Context Compaction | — | Reduces token consumption by trimming old conversation turns once the context reaches 75% of the model's limit. Tool call/output pairs are kept or discarded atomically | Implicit — triggered at 75% of llm_config.model.context_limit. No standalone toggle field |
always active | None (local trimming logic, no LLM call) | src/shared/llm/context_management/history_trimming.py (lines 319–451)src/intelligence/modules/callbacks/before_node_execution.py (lines 63–91) |
Cannot be disabled — runs automatically before every LLM call. Controlled indirectly via context_limit on the model config |
|
| Tool Output Storage | — | Saves full tool results to external Daytona storage so they are never lost when the context window fills up. Agents can retrieve and reference them throughout the conversation | tool_output_offloading.enabledPer-tool char limits defined in src/intelligence/modules/callbacks/tool_output_offloading/tool_output_offloading.yaml (default 100,000 chars) |
enabled = false | None (Daytona volume at /home/daytona/volume) |
src/intelligence/modules/callbacks/tool_output_offloading/ (directory)src/intelligence/modules/callbacks/after_tool_execution.py |
Toggle tool_output_offloading.enabled true/false in assistant settings. Requires Daytona sandbox to be running |
Safeguards¶
Accessed via Set safeguards in the agent settings UI. Three categories: Custom Policies, Keyword Filters, and Safety Filters.
All safeguards are controlled via safety_config in AssistantSettings. The safety orchestrator (src/safety/services/safety_orchestrator.py) evaluates all enabled guardrails on every user message.
| Category | Sheet Feature Name | Guardrail / Filter | Config Field | Default | Model Used | Logic File | Enable / Disable | Deployed in MOD SC |
|---|---|---|---|---|---|---|---|---|
| Custom Policies | Guardrails — Custom Policy and Keyword Filter | Policy Guardrail — LLM-evaluated custom rules defined in YAML files. Each policy has a prompt, threshold, and action (block/warn) | guidelines_config in assistant settingsYAML policies loaded from SAFETY_SAFETY_CONFIG_DIR env var pathGlobal settings: guidelines_confidence_threshold (default 0.70), guidelines_validation_temperature (default 0.0), guidelines_max_chars_per_batch (default 8,000) |
varies per policy | gpt-oss-safeguard-120b (configurable per policy in YAML) |
src/safety/guardrails/registry/policy_guardrail.pysrc/safety/services/safety_orchestrator.pysrc/safety/models/guideline_models.py |
Add/remove policy YAML files in SAFETY_SAFETY_CONFIG_DIR. Each policy has its own enabled flag |
|
| Fuzzy Ban List — variant of keyword filter with approximate/fuzzy matching | safety_config.guardrails[].name = "fuzzy_ban_list" |
enabled = false | None (fuzzy string matching, no LLM) | src/safety/guardrails/registry/fuzzy_ban_list_guardrail.py |
Set guardrails[].enabled true/false |
|||
| Keyword Filters | Guardrails — Custom Policy and Keyword Filter | Ban List — exact keyword/phrase matching using a Trie data structure. Blocks messages containing any banned word instantly with no LLM call | safety_config.guardrails[].name = "ban_list"params.banned_words: list of strings to block |
enabled = true (if configured; default banned_words = []) |
None (local Trie-based matching, no LLM) | src/safety/guardrails/registry/ban_list_guardrail.pysrc/safety/guardrails/helpers.py (Trie implementation) |
Set guardrails[].enabled true/false, or add/remove words from banned_words list |
|
| Safety Filters | Guardrails — Safety Filters (default guardrails) | Hate Speech — detected via OpenAI Moderation API (harassment/hate categories) or LLAMA Guard S10 (Hate) |
safety_config.guardrails[].name = "openai_moderation"params.model: omni-moderation-latestparams.timeout: 30s |
enabled = true | OpenAI Moderation API (omni-moderation-latest) |
src/safety/guardrails/registry/openai_moderation_guardrail.py |
Set guardrails[].enabled true/false per guardrail entry |
|
Sexual — detected via OpenAI Moderation (sexual, sexual/minors) or LLAMA Guard S12 (Sexual Content), S3 (Sex-Related Crimes), S4 (Child Sexual Exploitation) |
||||||||
| Prompt Injection — jailbreak and prompt injection detection. Evaluated via custom policy guardrail using a dedicated YAML policy | guidelines_config (custom policy YAML with prompt injection policy objective) |
enabled = true | gpt-oss-safeguard-120b |
src/safety/guardrails/registry/policy_guardrail.pysrc/safety/config/settings.py |
Enable/disable the specific prompt-injection policy YAML file in SAFETY_SAFETY_CONFIG_DIR |
|||
Violence — detected via OpenAI Moderation (violence, violence/graphic) or LLAMA Guard S1 (Violent Crimes) |
safety_config.guardrails[].name = "openai_moderation" or "llama_guard" with blocked_categories_codes: ["S1"] |
enabled = true | OpenAI Moderation API or meta-llama/llama-guard-3-8b |
src/safety/guardrails/registry/openai_moderation_guardrail.pysrc/safety/guardrails/registry/llama_guard.py |
Set guardrails[].enabled true/false |
LLAMA Guard categories (full list): S1 Violent Crimes · S2 Non-Violent Crimes · S3 Sex-Related Crimes · S4 Child Sexual Exploitation · S5 Defamation · S6 Specialized Advice · S7 Privacy · S8 Intellectual Property · S9 Indiscriminate Weapons · S10 Hate · S11 Suicide & Self-Harm · S12 Sexual Content · S13 Elections
Tool Access Mode¶
Displayed as a dropdown with option "Load tools when needed" in the agent UI.
| Feature | Description | Config Field | Default | Logic File | Notes | Deployed in MOD SC |
|---|---|---|---|---|---|---|
| Tool Access Mode | Controls how connector tools are loaded into agent conversations. "Load tools when needed" is the UI label for lazy/on-demand tool loading | ⚠️ Not found in codebase — no tool_access_mode or equivalent field exists in AssistantSettings or any config schema at the time of this analysis |
N/A | The related flow is tool activation (OAuth/bearer/env-var gating before first use) — see src/assistants/models/assistant_models/settings_model.py and config/default.toml [assistants.tool_activation] section |
The UI dropdown may be a frontend-only label for the existing MCP activation flow, or a feature not yet fully implemented in the service layer. Verify with the frontend team (ask-frontend repo) |
Summary¶
| Feature | Category | Config Field | Default | Model | Deployed in MOD SC |
|---|---|---|---|---|---|
| Conversation Summarizer | Context Management | history_summary.enabled |
✅ true | claude-haiku-4-5 |
— |
| Context Compaction | Context Management | Auto (75% threshold) | ✅ always on | none | — |
| Tool Output Storage | Context Management | tool_output_offloading.enabled |
❌ false | none (Daytona) | — |
| Custom Policies | Safeguards | guidelines_config (YAML) |
varies | gpt-oss-safeguard-120b |
— |
| Keyword Filters (Ban List) | Safeguards | safety_config.guardrails[ban_list] |
✅ true | none (Trie) | — |
| Fuzzy Ban List | Safeguards | safety_config.guardrails[fuzzy_ban_list] |
❌ false | none | — |
| Hate Speech | Safety Filters | openai_moderation / llama_guard S10 |
✅ true | OpenAI Moderation API | — |
| Prompt Injection | Safety Filters | guidelines_config (policy YAML) |
✅ true | gpt-oss-safeguard-120b |
— |
| Sexual Content | Safety Filters | openai_moderation / llama_guard S12 |
✅ true | OpenAI Moderation API | — |
| Violence | Safety Filters | openai_moderation / llama_guard S1 |
✅ true | OpenAI Moderation / llama-guard-3-8b | — |
| Tool Access Mode | Tool Loading | ⚠️ not found in service layer | N/A | N/A | — |