Skip to content

feat(context): fail fast when searchDuringIngestion lacks its feature flag - #1118

Open
CalebMartinUiPath wants to merge 1 commit into
mainfrom
caleb/ff-search-during-ingestion
Open

CalebMartinUiPath wants to merge 1 commit into
mainfrom
caleb/ff-search-during-ingestion

Conversation

@CalebMartinUiPath

@CalebMartinUiPath CalebMartinUiPath commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Why

Review feedback on the designer PR: the checkbox is flag-gated in the UI, so the backend should honour the same flag rather than trusting agent.json alone.

Today the runtime acts on settings.searchDuringIngestion as soon as it appears. An agent.json can carry it from a designer build, or by hand, before the tenant has the feature — so the setting alone is not enough to turn the behaviour on.

What

A resource that asks to search during ingestion without EnableContextGroundingSearchDuringIngestion now fails at graph build with AgentStartupError / INVALID_TOOL_CONFIG / USER:

Context resource '<name>' has 'search during ingestion' turned on, but the
'EnableContextGroundingSearchDuringIngestion' feature is not enabled for this
tenant. Turn the setting off on the context resource, or ask your administrator
to enable the feature.

Why fail rather than downgrade. Silently coercing to False would look like the toggle was on while every search against an ingesting index kept being rejected — the harder thing to diagnose. Failing at startup puts the misconfiguration in front of whoever deployed it.

Three decisions worth reviewing

Build time, not invocation. prefetch_all_flags() runs at the top of runtime creation, before the graph is compiled, so the registry is populated by the time handle_semantic_search runs — the same assumption the ontology gate already makes. Checking here means a bad config never produces a runnable agent.

In handle_semantic_search, not ensure_valid_fields. That validator is shared with the DeepRAG and BatchTransform handlers, where the setting is inert — failing those would reject agents over a setting that does nothing. Covered by a test.

Not in unified_search. The registry is populated by the agents runtime, so an SDK or CLI user has an empty registry; gating the SDK would make default=False silently break uipath context-grounding search --search-during-ingestion. The SDK keeps the capability; the runtime owns the policy. Same layering as DataFabricOntologyEnabled.

Merge order — this one first

UiPath/uipath-agents-python#771 registers the flag in _ALL_FLAGS. Without it the check falls through to env var then default=False, so a resource with the setting on would fail to start.

Merge this PR first and let it release. #771 then bumps the agents repo's exact uipath-langchain== pin to that release in the same PR as the flag registration, so the gate and the flag it reads go live in one commit — no window where one exists without the other. That bundling matches UiPath/uipath-agents-python#760, which moved the pin alongside the change that needed it.

Nothing uses searchDuringIngestion today, so there is no exposure either way.

Testing

agent.json flag result
absent off False
false off False
true off AgentStartupError
false on False
true on True
true on a DeepRAG resource off builds fine (setting inert)

6 tests. Negative-checked: removed the fail-fast, confirmed the test fails, restored. ruff, ruff format (404 files), mypy (210 files) and the httpx linter clean; context-tool and retriever suites green.

🤖 Generated with Claude Code

… flag

The agent.json ``searchDuringIngestion`` opt-in was honoured as soon as it
appeared in the resource settings. An agent.json can carry it from a
designer build, or by hand, before the tenant has the feature, so the
setting alone is not enough to turn the behaviour on.

Require EnableContextGroundingSearchDuringIngestion as well, and treat the
mismatch as a configuration error: a resource that asks to search during
ingestion without the feature enabled raises AgentStartupError at graph
build, rather than quietly downgrading to the old blocking behaviour.
Downgrading silently would look like the toggle was on while every search
against an ingesting index kept failing, which is the harder thing to
diagnose.

The check sits in handle_semantic_search rather than ensure_valid_fields:
that validator is shared with the DeepRAG and BatchTransform handlers,
where the setting is inert, and failing those would reject agents over a
setting that does nothing.

Gated here rather than in unified_search: the flag registry is populated
by the agents runtime at startup, so gating the SDK would silently
disable `uipath context-grounding search --search-during-ingestion` for
anyone using the SDK or CLI directly. The SDK keeps the capability; the
runtime owns the policy.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@CalebMartinUiPath
CalebMartinUiPath force-pushed the caleb/ff-search-during-ingestion branch from ac61d69 to c150672 Compare September 28, 2026 20:55
@CalebMartinUiPath CalebMartinUiPath changed the title feat(context): gate searchDuringIngestion behind a feature flag feat(context): fail fast when searchDuringIngestion lacks its feature flag Sep 28, 2026
@sonarqubecloud

Copy link
Copy Markdown

@CalebMartinUiPath
CalebMartinUiPath marked this pull request as ready for review September 28, 2026 23:00
Copilot AI balanced review requested due to automatic review settings September 28, 2026 23:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Newly added and modified test functions lack required complete type annotations.

Review effort: Balanced
Findings: 2 Low severity

Open (2)
What changed in this PR

Adds startup validation so semantic context resources cannot enable search-during-ingestion without the tenant feature flag.

Changes:

  • Adds feature-flag validation with a structured startup error.
  • Tests enabled, disabled, absent, and DeepRAG scenarios.
File Description
src/​uipath_langchain/​agent/​tools/​context_tool.py Enforces the feature flag during semantic tool creation.
tests/​agent/​tools/​test_context_tool.py Covers feature-flag combinations and unaffected modes.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.


@staticmethod
async def _retriever_kwargs_for(resource):
async def _retriever_kwargs_for(resource, *, flag_enabled: bool = False):

assert kwargs["search_during_ingestion"] is False

def test_opt_in_without_the_flag_fails_fast(self):
AgentToolArgumentProperties,
LowCodeAgentDefinition,
)
from uipath.core.feature_flags import FeatureFlags

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there no precedent on FF gating for any of the context tool features? idk much about this codebase so I cant comment if this is the ideal place or not.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants