Skip to content

BigQuery function call succeeds locally but fails silently on Vertex AI #1493

Open
@KSonPham

Description

@KSonPham

Hi,

I’m building an agent that queries a BigQuery table using the following function:

def run_bigquery_sql(sql_query: str) -> str:
    client = bigquery.Client()
    query_job = client.query(sql_query)
    results = query_job.result()
    return json.dumps(results, indent=2, default=str)

This works fine locally. However, when deployed to Vertex AI, the function appears to run (i.e., no errors), but no data is returned. The model’s response confirms the function is invoked, but there’s no result.


Example call

User prompt:

Show me the type of partners and their count?

Model function call:

{
  "function_call": {
    "name": "run_bigquery_sql",
    "args": {
      "sql_query": "SELECT partner_type__c, COUNT(*) FROM `modified-talon-451917-8.ff_df_sf_partner.Partner_c_mini` GROUP BY partner_type__c"
    }
  }
}

Suspected Cause

Likely an authentication issue with the BigQuery client when running in Vertex AI (possibly missing service account permissions or not properly configured auth context).


Question

What is the correct way to authenticate a BigQuery client in a Vertex AI function/tool call so that it returns data as expected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions