Skip to content

ci(test/alloydbainl): use explicit SQL alias prompts to stabilize AI - #3877

Merged
Yuan325 merged 1 commit into
googleapis:mainfrom
emagda97:fix/ai-nl-test-flake
Aug 26, 2026
Merged

Yuan325 merged 1 commit into
googleapis:mainfrom
emagda97:fix/ai-nl-test-flake

Conversation

@emagda97

Copy link
Copy Markdown
Collaborator

Description

The prompt return the number 1 is naturally flaky. It was sometimes returning errors like this:

alloydb_ai_nl_mcp_test.go:234: unexpected value: got "{\"execute_nl_query\":{\"result\":1}}", want "{\"execute_nl_query\":{\"number_one\":1}}".

Swapped this for a more deterministic SQL style prompt, so the response format is far less likely to change from run to run.

  • Make sure you reviewed
    CONTRIBUTING.md
  • Make sure to open an issue as a
    bug/issue
    before writing your code! That way we can discuss the change, evaluate
    designs, and agree on the general idea
  • Ensure you have manually reviewed the entire diff before requesting a
    review
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involve a breaking change

🛠️ Fixes #<issue_number_goes_here>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the integration tests in tests/alloydbainl/alloydb_ai_nl_mcp_test.go by modifying the query arguments in several test cases. The natural language question is changed from 'return the number 1' to a more explicit instruction: 'SELECT the integer 1 and explicitly alias the output column as 'number_one''. This ensures the test queries align with the expected output schema. There are no review comments to evaluate, and we have no additional feedback to provide.

@emagda97
emagda97 force-pushed the fix/ai-nl-test-flake branch from d997b03 to 65ccb58 Compare August 26, 2026 19:00
@emagda97
emagda97 marked this pull request as ready for review August 26, 2026 19:12
@emagda97
emagda97 requested review from a team as code owners August 26, 2026 19:12
@Yuan325
Yuan325 enabled auto-merge (squash) August 26, 2026 19:46
@Yuan325 Yuan325 assigned Yuan325 and unassigned duwenxin99 Aug 26, 2026
@Yuan325 Yuan325 added the release candidate Use label to signal PR should be included in the next release. label Aug 26, 2026
@Yuan325 Yuan325 changed the title fix(test/alloydbainl): use explicit SQL alias prompts to stabilize AI… ci(test/alloydbainl): use explicit SQL alias prompts to stabilize AI Aug 26, 2026
@Yuan325
Yuan325 merged commit 50e45ed into googleapis:main Aug 26, 2026
17 checks passed
Yuan325 added a commit that referenced this pull request Aug 27, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.10.0](v1.9.0...v1.10.0)
(2026-08-27)


### Features

* **falkordb:** Add FalkorDB source and tools
([#3692](#3692))
([a94702c](a94702c))
* **firestore-mongodb:** Add firestore-execute-mql and firestore-get-…
([#3826](#3826))
([4a85d75](4a85d75))
* **mcp:** Add Secure Parameters support as Toolbox experimental
extension
([#3394](#3394))
([9750d2d](9750d2d))
* **server/mcp:** Support com.google.cloud/toolbox.v1 extension in
v20260728
([#3801](#3801))
([f4f7da6](f4f7da6))
* **skill:** Add fix-failing-tests skill for mcp-toolbox
([#3821](#3821))
([168e69c](168e69c))
* **sources:** Support native read-only mode and dynamic tool
annotations
([#3872](#3872))
([c257022](c257022)),
refs [#3615](#3615)
[#3816](#3816)
[#3618](#3618)
[#3851](#3851)
[#3619](#3619)
[#3617](#3617)
* **tool/mongodb:** Allow collection to be specified at runtime
([#3715](#3715))
([7626eaf](7626eaf))


### Bug Fixes

* **cloud-storage:** Resolve symlinks when enforcing local path
boundaries
([#3810](#3810))
([c2ada64](c2ada64))
* **config:** Compare env var offsets in rune space when skipping
comments
([#3856](#3856))
([2e76934](2e76934))
* Merge prebuilt tools when reloading custom config
([#3864](#3864))
([5a6d865](5a6d865))
* Normalize postgres UUIDs to strings
([#3806](#3806))
([3b02f1d](3b02f1d))
* **postgres:** Filter background processes in
postgres-list-active-queries
([#3885](#3885))
([3d9e62a](3d9e62a))
* **test/alloydbainl:** Use explicit SQL alias prompts to stabilize AI…
([#3877](#3877))
([50e45ed](50e45ed))
* **tests:** Prevent resource leaks by using context.WithoutCancel
([#3849](#3849))
([f97a4f9](f97a4f9))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Yuan Teoh <[email protected]>
github-actions Bot pushed a commit that referenced this pull request Aug 27, 2026
🤖 I have created a release *beep* *boop*
---

##
[1.10.0](v1.9.0...v1.10.0)
(2026-08-27)

### Features

* **falkordb:** Add FalkorDB source and tools
([#3692](#3692))
([a94702c](a94702c))
* **firestore-mongodb:** Add firestore-execute-mql and firestore-get-…
([#3826](#3826))
([4a85d75](4a85d75))
* **mcp:** Add Secure Parameters support as Toolbox experimental
extension
([#3394](#3394))
([9750d2d](9750d2d))
* **server/mcp:** Support com.google.cloud/toolbox.v1 extension in
v20260728
([#3801](#3801))
([f4f7da6](f4f7da6))
* **skill:** Add fix-failing-tests skill for mcp-toolbox
([#3821](#3821))
([168e69c](168e69c))
* **sources:** Support native read-only mode and dynamic tool
annotations
([#3872](#3872))
([c257022](c257022)),
refs [#3615](#3615)
[#3816](#3816)
[#3618](#3618)
[#3851](#3851)
[#3619](#3619)
[#3617](#3617)
* **tool/mongodb:** Allow collection to be specified at runtime
([#3715](#3715))
([7626eaf](7626eaf))

### Bug Fixes

* **cloud-storage:** Resolve symlinks when enforcing local path
boundaries
([#3810](#3810))
([c2ada64](c2ada64))
* **config:** Compare env var offsets in rune space when skipping
comments
([#3856](#3856))
([2e76934](2e76934))
* Merge prebuilt tools when reloading custom config
([#3864](#3864))
([5a6d865](5a6d865))
* Normalize postgres UUIDs to strings
([#3806](#3806))
([3b02f1d](3b02f1d))
* **postgres:** Filter background processes in
postgres-list-active-queries
([#3885](#3885))
([3d9e62a](3d9e62a))
* **test/alloydbainl:** Use explicit SQL alias prompts to stabilize AI…
([#3877](#3877))
([50e45ed](50e45ed))
* **tests:** Prevent resource leaks by using context.WithoutCancel
([#3849](#3849))
([f97a4f9](f97a4f9))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Yuan Teoh <[email protected]>
wangauone added a commit that referenced this pull request Aug 31, 2026
…est (#3916)

#3877 made the AI NL test prompts explicit about the column alias, but
only updated `alloydb_ai_nl_mcp_test.go`.
`alloydb_ai_nl_integration_test.go` kept the vague `"return the number
1"` prompt while still expecting the `number_one` column name that #3339
introduced.

With no alias requested, the service generates plain `SELECT 1` and
Postgres falls back to its default `?column?` label, so the assertion
can never pass:

```
got  "[{"execute_nl_query":{"?column?":1}}]"
want "[{"execute_nl_query":{"number_one":1}}]"
```

This applies the same prompt wording #3877 used, to the seven remaining
occurrences in the integration test file.

The `alloydb-ai-nl` build step currently fails on every PR for this
reason. All three subtests in `TestAlloyDBAINLToolEndpoints` that
actually execute a query fail; the rest only pass because they are auth
or validation error cases that never reach the database.
`TestAlloyDBAINLCallTool`, in the file #3877 did fix, passes.
wangauone added a commit that referenced this pull request Sep 24, 2026
The AI-NL tests asserted the full response string, which embeds the SQL
column alias chosen by the model. The model does not reliably honour the
requested alias and sometimes returns `result` instead of `number_one`,
failing the test even though the query returned the correct value.

#3877 and #3916 tried to stabilise this by rewriting the prompt. Nothing
in the tool contract binds the alias, so a prompt can only lower the
failure rate.

Match the affected responses with a regex that accepts any single column
set to 1. The row and column counts are still pinned, so the assertion
can still catch a genuine regression.
Yuan325 added a commit that referenced this pull request Sep 28, 2026
#4125)

## Description

These tests asserted the full response string, which includes the SQL
column alias chosen by the model. The model sometimes returns `result`
instead of `number_one`, so the test failed even though the query
returned the correct value.

#3877 and #3916 tried to fix this by rewriting the prompt. Nothing in
the tool contract binds the alias, so a prompt can only lower the
failure rate.

This matches the affected responses with a regex that accepts any single
column set to 1. Row and column counts are still pinned so the assertion
can still catch a real regression. Cases that assert error messages are
unchanged.

Integration tests need live AlloyDB credentials and were not run
locally. `go vet` and `gofmt` are clean. The patterns were checked
against the response shapes from both endpoints, including the exact
string in the failure report.

## PR Checklist

- [x] Make sure you reviewed

[CONTRIBUTING.md](https://github.com/googleapis/mcp-toolbox/blob/main/CONTRIBUTING.md)
- [x] Make sure to open an issue as a

[bug/issue](https://github.com/googleapis/mcp-toolbox/issues/new/choose)
  before writing your code! That way we can discuss the change, evaluate
  designs, and agree on the general idea
- [x] Ensure you have manually reviewed the entire diff before
requesting a
  review
- [x] Ensure the tests and linter pass
- [x] Code coverage does not decrease (if any source code was changed)
- [x] Appropriate docs were updated (if necessary)
- [ ] Make sure to add `!` if this involve a breaking change

🛠️ Fixes #3874

Co-authored-by: Yuan Teoh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release candidate Use label to signal PR should be included in the next release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants