Skip to content

feat: add coded agent Data Fabric tool - #1034

Open
UIPath-Harshit wants to merge 1 commit into
mainfrom
agent/datafabric-coded-agent-tool
Open

feat: add coded agent Data Fabric tool#1034
UIPath-Harshit wants to merge 1 commit into
mainfrom
agent/datafabric-coded-agent-tool

Conversation

@UIPath-Harshit

@UIPath-Harshit UIPath-Harshit commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a public create_datafabric_tool(...) factory for coded agents that accepts direct DataFabricEntityItem references and the outer system prompt
  • retain create_datafabric_query_tool(...) as the low-code AgentContextResourceConfig adapter used by context_tool
  • share only the internal Data Fabric tool builder and lazy query handler between the two interfaces
  • keep the existing low-code context behavior and outer tool text unchanged
  • add a minimal LangGraph sample using the coded-agent interface

Why

Low-code and coded agents have different configuration lifecycles. Low-code receives an AgentContextResourceConfig from Agent Builder, while coded agents declare the tool and entity references directly in Python. The public interfaces reflect that boundary instead of requiring coded agents to manufacture a low-code resource model.

Interfaces

Coded agent

system_prompt = "Answer using only the configured Data Fabric entities."

datafabric_tool = create_datafabric_tool(
    llm=llm,
    name="query_agent_test",
    description="Query the agentTest entity.",
    entities=[DataFabricEntityItem(...)],
    base_system_prompt=system_prompt,
)

graph = create_agent(
    llm,
    tools=[datafabric_tool],
    system_prompt=system_prompt,
)

The coded caller explicitly passes the same outer system prompt to the Data Fabric factory. The factory forwards it to the inner SQL-generation graph as ## Agent Instructions.

Low-code context adapter

create_datafabric_query_tool(resource, llm, tool_name, agent_config)

The low-code adapter remains consumed internally by create_context_tool and forwards the configured outer system prompt into the inner graph.

Impact

Both paths build the same Data Fabric query implementation and resolve entity schemas lazily on first invocation. The current coded-agent binding scanner still does not discover entity bindings declared through the coded factory; uip codedagent init emits an empty resource list. Default entity resolution is verified, while generated binding overrides remain a follow-up integration boundary.

Tracking

  • DS-9166 — aggregate queries incorrectly required LIMIT; fixed here
  • DS-9167 — coded-agent scanner does not discover Data Fabric entity bindings; follow-up

Validation

  • 109 focused Data Fabric/context-tool tests passed
  • mypy passed for both interfaces and the coded-agent sample
  • Ruff passed
  • coded-factory test verifies base_system_prompt reaches the lazy Data Fabric handler
  • live uip codedagent run agent on alpha resolved entity 1312e893-8295-f111-9b33-0022482a9eea, generated SELECT name FROM agentTest LIMIT 100, received HTTP 200 with zero rows, and returned There are no names available in the data.
  • the live run caught and removed an invalid sample-only entity_key="agentTest"; resolver now correctly uses the entity GUID

@UIPath-Harshit
UIPath-Harshit force-pushed the agent/datafabric-coded-agent-tool branch from 837aace to f8d81df Compare August 11, 2026 19:46

UIPath-Harshit commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Jira tracking for the two Data Fabric issues covered/discovered during this change:

  • DS-9166 — Data Fabric agent prompt incorrectly requires LIMIT for scalar aggregate queries. Fixed by this PR.
  • DS-9167 — Coded-agent binding scanner does not discover Data Fabric entity references. Follow-up gap; not implemented by this PR.

Both bugs are assigned to Harshit and added to DataFabric S201.

@UIPath-Harshit
UIPath-Harshit force-pushed the agent/datafabric-coded-agent-tool branch from f8d81df to 147ae0f Compare August 11, 2026 19:52
@UIPath-Harshit
UIPath-Harshit marked this pull request as ready for review August 11, 2026 19:53
Copilot AI lite review requested due to automatic review settings August 11, 2026 19:53

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.

Pull request overview

Adds a supported public construction path for the Data Fabric query tool in coded agents by reusing the same core implementation as low-code context tools, while keeping Data Fabric prompt guidance and adding a minimal coded-agent sample.

Changes:

  • Refactors Data Fabric tool creation around a shared, framework-neutral config builder and entity normalization.
  • Updates the Data Fabric SQL prompt rule around LIMIT to exempt scalar aggregate queries.
  • Adds/extends tests and introduces a minimal coded-agent sample wiring create_datafabric_query_tool into create_agent.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/agent/tools/test_datafabric_tool.py Adds coverage for the new public factory behavior, low-code factory reuse, and lazy entity resolution.
tests/agent/tools/test_datafabric_prompt_builder.py Verifies the updated prompt guidance for scalar aggregate queries (no required LIMIT).
src/uipath_langchain/agent/tools/datafabric_tool/datafabric_tool.py Introduces shared tool config + entity normalization and centralizes tool construction.
src/uipath_langchain/agent/tools/datafabric_tool/datafabric_prompts.py Adjusts the “LIMIT” rule wording to avoid forcing LIMIT for scalar aggregates.
src/uipath_langchain/agent/tools/datafabric_tool/init.py Simplifies exports for the Data Fabric tool module.
src/uipath_langchain/agent/tools/init.py Re-exports create_datafabric_query_tool at the top-level tools package.
samples/README.md Adds a pointer to the new Data Fabric coded-agent sample.
samples/datafabric-coded-agent/uipath.json Adds minimal coded-agent sample config file.
samples/datafabric-coded-agent/README.md Documents how to run the coded-agent sample.
samples/datafabric-coded-agent/pyproject.toml Defines a minimal sample project depending on uipath-langchain.
samples/datafabric-coded-agent/langgraph.json Declares the sample graph entrypoint and environment file.
samples/datafabric-coded-agent/graph.py Demonstrates constructing and passing the Data Fabric query tool directly to create_agent.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/agent/tools/test_datafabric_tool.py Outdated
Comment thread src/uipath_langchain/agent/tools/__init__.py Outdated
@UIPath-Harshit
UIPath-Harshit force-pushed the agent/datafabric-coded-agent-tool branch from 147ae0f to 3edbd98 Compare August 12, 2026 04:48
@UIPath-Harshit
UIPath-Harshit marked this pull request as draft August 12, 2026 04:48
@UIPath-Harshit
UIPath-Harshit force-pushed the agent/datafabric-coded-agent-tool branch from 3edbd98 to bd846b4 Compare August 12, 2026 05:09

Copy link
Copy Markdown
Contributor Author

Correction after revisiting the lifecycle boundary: the PR now intentionally exposes two interfaces. Coded agents use create_datafabric_tool(..., entities=[DataFabricEntityItem(...)]) and do not construct AgentContextResourceConfig. Low-code contexts retain create_datafabric_query_tool(resource, llm, tool_name, agent_config) behind create_context_tool. Both adapters share only the internal builder and lazy handler.

@UIPath-Harshit
UIPath-Harshit force-pushed the agent/datafabric-coded-agent-tool branch 2 times, most recently from dc2ead6 to 008f4b1 Compare August 12, 2026 05:19
@UIPath-Harshit
UIPath-Harshit force-pushed the agent/datafabric-coded-agent-tool branch from 008f4b1 to a68afb3 Compare August 12, 2026 05:24
@UIPath-Harshit
UIPath-Harshit marked this pull request as ready for review August 12, 2026 05:29
@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants