oracle / oracle/oci-python-sdk

ADK - RAG Tool Not Invoked When Function Calling Tools Are Present

Open
#819 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Generative AI Agent SDK
Dominant language
Python
Stars
474
Forks
321
Avg merge
23m
Merged PRs (30d)
4

Description

When both Function Calling Tools and RAG Tools are associated with an agent, the RAG Tool is not invoked via ADK, even when explicitly instructed.
However, the same agent configuration works correctly when accessed via the Generative AI Agents Service Web UI console.

Current behavior:

  1. RAG Tools alone: Work correctly and return citations
  2. RAG Tools + Function Calling Tools which is defined on local: RAG Tools are not invoked
  3. Web UI with same configuration(After local tools were sync and regisitered: RAG Tools work correctly even with Function Calling Tools present

Reproduction Steps

  1. Create a RAG Tool on the Agents Service console
  2. Create an Agent with both a Function Calling Tool and the RAG Tool:
from oci.addons.adk import Agent, AgentClient, tool
from typing import Dict

@tool
def get_weather(location: str) -> Dict[str, str]:
    """Get the weather for a given location."""
    return {"location": location, "temperature": 72, "unit": "F"}

client = AgentClient(
    auth_type="security_token",
    profile="DEFAULT",
    region="us-phoenix-1",
)

agent = Agent(
    client=client,
    agent_endpoint_id="ocid1.genaiagentendpoint.oc1....",
    instructions="You MUST use the RAG tool to search the Knowledge Base for EVERY question.",
    tools=[get_weather]  # Function Calling Tool present
)
agent.setup()

input = "What is Generative AI Agent Service. Please search it in the knowledge base."
response = agent.run(input)

response.pretty_print()

Cause of this Issue

The _sync_function_tools_to_remote() method in agent.setup() appears to be the cause of this issue.

The following test results demonstrate the issue:

  1. Without agent.setup(): RAG tool invoked successfully
  2. With _sync_agent_to_remote() only: RAG tool invoked successfully
  3. With _sync_agent_to_remote() + _sync_rag_tools_to_remote() (skipping _sync_function_tools_to_remote()): RAG tool invoked successfully
  4. With _sync_function_tools_to_remote() called (even with tools=[]): RAG tool NOT invoked
  5. With full agent.setup(): RAG tool NOT invoked

Even when tools=[] (no local Function Calling Tools), calling _sync_function_tools_to_remote() prevents RAG tool invocation.
This suggests the method execution itself, not tool addition/deletion, is the problem.

The _sync_function_tools_to_remote() method calls _sync_local_and_remote_tools(), which synchronizes Function Calling Tools. Even when no tools are added or deleted, the execution of this method appears to trigger a state change in the Agents Service that affects tool selection logic, causing RAG Tools to be deprioritized or ignored.

Code Reference: oci/addons/adk/agent.py:567-586 - _sync_function_tools_to_remote() method

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in oci/addons/adk/agent.py:567-586 with _sync_function_tools_to_remote(), then trace its call to _sync_local_and_remote_tools(). Reproduce the four setup variants described in the issue, especially calling the method with tools=[], and verify that RAG Tools are invoked and citations returned when local Function Calling Tools are present.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.