feat(agents): add QueryAgentTool (in preview) for the new data modeling query tool type#2569
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the QueryAgentTool, QueryAgentToolConfiguration, and QueryAgentToolUpsert classes to the Agents API, enabling flexible queries against data models. The changes include comprehensive documentation examples and unit tests for the new tool types. A review comment identifies a potential TypeError in the QueryAgentToolConfiguration._load method when handling null values for the dataModels key in API responses and provides a suggestion to improve the robustness of the parsing logic.
5085319 to
dda47b6
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2569 +/- ##
=======================================
Coverage 92.76% 92.76%
=======================================
Files 480 480
Lines 48446 48502 +56
=======================================
+ Hits 44939 44991 +52
- Misses 3507 3511 +4
🚀 New features to boost your workflow:
|
9da3c4d to
6acddf4
Compare
haakonvt
left a comment
There was a problem hiding this comment.
Mostly LGTM. Should we add the query tool to the list of tools of the permanent agent in the integration test?
5cad072 to
b3d722f
Compare
Exercises the new QueryAgentTool end-to-end via the shared integration test agent, following review feedback on #2569.
|
|
||
| >>> from cognite.client.data_classes.agents import ( | ||
| ... AgentUpsert, | ||
| ... QueryAgentToolUpsert, |
There was a problem hiding this comment.
The current code raises due to "runtime version does not support it". I'm hesitant to merge code examples that don't work yet - I think the API change has to come first.
There was a problem hiding this comment.
@ks93 this gives me:
CogniteAPIError: Tool 'explore data' (type: query) requires a runtime version with Query Tool support
(for example 1.1.2-preview) and an experimental runtime. Current runtime version '1.1.3-preview' does
not support this tool. Please upgrade the agent's runtime version to use this tool. | code: 400 |
X-Request-ID: 1874c3ae-adf1-94a8-901c-eff9da9d9e56 | cluster: greenfield | project: forge-sandbox
The sentence Please upgrade the agent's runtime version to use this tool makes no sense 🤣
Tests were branching on isinstance(loaded_tool, ...), which is the object under test. A loader regression returning the wrong subtype could silently skip entire assertion blocks and still pass. Branching on the parametrized expected_type keeps the isinstance check as a real assertion.
Mirrors the pattern already used by test_agent_tool_load_returns_correct_subtype, so a loader regression returning a wrong subtype fails loudly here instead of relying on _type string equality alone.
The cog-ai backend and Fusion frontend already support the "query" tool type, but the Python SDK deserialized it as UnknownAgentTool. This adds first-class support with QueryAgentTool, QueryAgentToolUpsert, and QueryAgentToolConfiguration classes.
Remove maturity label from docstring examples and surface missing dataModels key instead of silently defaulting to empty dict.
Covered automatically by tests/tests_unit/test_base.py.
Covered by automatic load/dump tests in test_base.py. Keep only test_load_without_configuration for the None config edge case.
Local codegen run during the rebase produced a stale hash; regenerated to match CI.
The current default runtime does not support the Query tool, so the example would fail as written. Pin to 1.1.3-preview until the Query tool lands in the default runtime.
56a90b4 to
7a08a59
Compare
33c8067 to
11cb8b0
Compare
Note
Stacked on #2584 (CI test skip), merge that first.
Summary
"query"agent tool type, which was previously deserialized asUnknownAgentToolQueryAgentTool,QueryAgentToolUpsert,QueryAgentToolConfigurationdata_modelslist (reusingDataModelInfo) with transparent API wrapping indump/_loadTest plan
API not yet public, see


providedAtRuntimeis not yet public.