epam / epam/statgpt-backend

Agent: make the out-of-scope guardrail and Supreme Agent prompts aware of Deep Research

Open
#620 0 comments 0 reactions 1 assignee Claimed by @navalnica View on GitHub
enhancement
Dominant language
Python
Stars
26
Forks
1
Avg merge
1d 17h
Merged PRs (30d)
25

Description

## Context

Follow-up from the review of #575 (Deep Research mediated clarification flow).

Deep Research is deliberately excluded from `ChannelConfig.tool_fields`, so it never appears in the general agent's tool set, the MCP server, or the out-of-scope checker. It is reachable only via the `deep_research` toggle ("button") — see `SupremeAgentExecutor._resolve_deep_research_mode` in `statgpt/app/chains/supreme_agent.py`.

A side effect of that isolation is that two prompts have no idea Deep Research exists. Both should be made aware of it.

## 1. Out-of-scope guardrail prompt

The guardrail runs on **every** turn (`OutOfScopeChecker` in `statgpt/app/chains/out_of_scope_checker.py`; prompt in `statgpt/app/default_prompts/assets/guardrails.yaml` → `checkerPrompt`). Its tool descriptions come from `channel_config.agent_tools`, which excludes Deep Research. If it classifies a Deep Research request as out of scope, `MainChainFactory._main_chain` skips the Supreme Agent entirely — so the request is blocked even though the user pressed the Deep Research button.

**Goal:** the guardrail must not block a request while the Deep Research toggle is on.

- The toggle state is available as `configuration.deep_research` (`StatGPTConfiguration`); it is not currently passed to the guardrail.
- Acceptance: with the toggle on, an otherwise-borderline research request is treated as in scope and reaches the mediated Deep Research turn.

## 2. Supreme Agent system prompt

The Supreme Agent system prompt (`statgpt/app/default_prompts/assets/supreme_agent.yaml`) only mentions Deep Research inside the mediation-only `deepResearchSection`, which is appended solely on Deep Research turns. On a normal turn the agent has no awareness of the feature, yet `defaultGeneralSection` already instructs it to explain its capabilities when asked ("If asked about your capabilities, clearly explain the tools you have access to and their functions").

**Goal:** when the user asks about functionality/capabilities, the agent should mention that a Deep Research mode is supported, but that it is only available when the Deep Research button is enabled.

- Acceptance: asked "what can you do?" on a normal turn, the agent lists Deep Research as an available mode and notes it is enabled via the button.

## Notes

- Both prompts are admin-configurable, so wording belongs in the default prompt assets (and should remain overridable per channel), not hard-coded.
- Keep routing deterministic: this issue is only about prompt/guardrail awareness, not about changing how a Deep Research turn is selected (that stays driven by the toggle + session flag).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.