Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-langchain"
version = "0.18.7"
version = "0.18.8"
description = "Python SDK that enables developers to build and deploy LangGraph agents to the UiPath Cloud Platform"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@

**Examples:**
- SELECT country, COUNT(id) FROM Customer GROUP BY country
- SELECT dept, SUM(price*qty) as total FROM LineItem GROUP BY dept
- SELECT dept, SUM(price) as total FROM LineItem GROUP BY dept
- SELECT country, COUNT(id) as cnt FROM Customer GROUP BY country HAVING COUNT(id)>10

### 5. Expressions (Minimal)
Expand Down Expand Up @@ -350,4 +350,6 @@
9. **Simple aggregations only** - No DISTINCT in aggregates
10. **ORDER BY only selected columns** - Cannot ORDER BY columns not in SELECT list
11. **Limit unbounded row queries** - Queries without WHERE that could return many rows must include a LIMIT clause (e.g., LIMIT 100). Scalar aggregate queries do not require LIMIT
12. **Choice-set fields use display labels** - Choice-set fields list their allowed values in the Description column of the schema table. Use the display label as a string in WHERE clauses (e.g. ``WHERE Priority = 'Critical'``). Multi-select (array) choice-set fields cannot be filtered via SQL — only SELECT them."""
12. **Choice-set fields use display labels** - Choice-set fields list their allowed values in the Description column of the schema table. Use the display label as a string in WHERE clauses (e.g. ``WHERE Priority = 'Critical'``). Multi-select (array) choice-set fields cannot be filtered via SQL — only SELECT them.
13. **More than 4 columns needs a filter** - Selecting more than 4 columns is only allowed when the query has a WHERE clause
14. **Aggregate arguments are a single column** - COUNT/SUM/AVG/MIN/MAX take one plain column, never a CASE or a calculation; keep to 5 aggregate functions and 5 GROUP BY columns per query"""
17 changes: 16 additions & 1 deletion src/uipath_langchain/agent/tools/datafabric_tool/prompts/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
QUERY PLANNING (think through these steps before writing SQL):
1. ENTITY SELECTION — Which entity (table) answers this question? List the \
candidates. Prefer the fewest entities possible — do NOT add a JOIN unless the \
question requires fields from multiple entities.
question requires fields from multiple entities. If two or more entities are \
equally plausible matches for the data the question asks about (e.g. similarly \
named entities, or entities with overlapping schemas) and the question does \
not make clear which one to use, do NOT guess and do NOT silently pick one — \
instead of calling ``execute_sql``, reply with a brief clarifying question \
that names the candidate entities and asks the user which one to use.
2. JOIN PLANNING — If multiple entities are needed, identify the foreign-key \
columns that connect them. Do NOT add a JOIN unless a column from the joined \
entity is used in SELECT, WHERE, GROUP BY, or ORDER BY. An anti-join (a JOIN \
Expand Down Expand Up @@ -88,6 +93,12 @@
- "average" / "mean" -> AVG
If no aggregation word appears, do NOT aggregate.
{aggregation_hints}
If query needs COUNT(*) - remember that COUNT(*) is not supported. Handle COUNT(*) as follows:
- If the entity schema contains the literal Id field (an exact, case-sensitive field-name match) - COUNT(*) can be replaced with COUNT(Id) since the Id field is UNIQUEIDENTIFIER.
- If there is no Id field, but the schema marks a field as primary key, then that field can be used instead of COUNT(*).
- If neither Id nor a Primary Key field exists, do not arbitrarily replace COUNT(*) with another column since that may produce an incorrect result. \
First, determine whether an alternative set of queries and computation can produce the required result without COUNT(*). If no reliable alternative exists, \
explain the limitation to the user and ask them to provide a column that is guaranteed to be non-NULL and suitable for counting, explaining why that column is required.
7. DISTINCT DETECTION — Does the question ask for a deduplicated list?
- "list the distinct / different / unique X" -> SELECT DISTINCT X
- "list all X" when X can repeat across rows and the question implies \
Expand Down Expand Up @@ -116,6 +127,8 @@
- Do NOT add LIMIT to queries that already naturally return a bounded \
set: an equality filter on a unique key, an aggregation that returns one row, \
or a question asking for "all X meeting Y".
- If a query containing a LIMIT clause returns a number of rows equal to its LIMIT, do not assume that this represents the complete result set. \
The LIMIT bounds the number of rows returned, so additional matching rows may exist.
10. Write the SQL query and call ``execute_sql``.
Do NOT terminate the SQL query with a semicolon.

Expand Down Expand Up @@ -196,6 +209,8 @@
short explanation.
4. Do NOT silently add LIKE or LOWER() wrappers to make an EMPTY_RESULT go \
away — first verify the stored value via the entity metadata.
5. If, even after trying different approaches, you cannot confidently arrive at the result due to query limitations or insufficient information,\
do not answer from general knowledge. Clearly explain the limitation to the user and ask for clarification or additional information.

OUTPUT:
Once ``execute_sql`` returns a successful result, return a concise \
Expand Down
15 changes: 15 additions & 0 deletions tests/agent/tools/test_datafabric_prompt_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ def test_build_includes_domain_guidance_in_rendered_prompt():
assert "Use business-friendly ticket language." in prompt


def test_build_includes_entity_disambiguation_rule():
"""Similar entities must trigger a clarifying question, not a silent guess.

Locks the disambiguation rule and its no-tool directive into the rendered
v1 prompt so a future template/rendering edit can't silently drop or join
it while the suite still passes (PR #1084). Applies to both the entity-set
and ontology paths, since both render through the default v1 strategy.
"""
prompt = build([_fake_entity(_fake_field())], resource_description="")

assert "do NOT guess and do NOT silently pick one" in prompt
assert "reply with a brief clarifying question" in prompt
assert "instead of calling ``execute_sql``" in prompt


def test_relationship_field_renders_join_when_target_entity_present():
order = _fake_entity(
_fake_field(),
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading