-
Notifications
You must be signed in to change notification settings - Fork 43
feat: Enhance tool descriptions #350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
ba809b6
ab28138
840e07f
b9c3b91
0ac88e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### feat: Enhance tool descriptions - @DaleSeo PR #350 | ||
|
||
This PR enhances the descriptions of the introspect and search tools to offer clearer guidance for AI models on efficient GraphQL schema exploration patterns. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,7 @@ impl Search { | |
tool: Tool::new( | ||
SEARCH_TOOL_NAME, | ||
format!( | ||
"Search a GraphQL schema{}", | ||
"Search a GraphQL schema for types matching the provided search terms. Returns complete type definitions including all related types needed to construct GraphQL operations. Instructions: If the introspect tool is also available, you can discover type names by using the introspect tool starting from the root Query or Mutation types. Avoid reusing previously searched terms for more efficient exploration.{}", | ||
if minify { | ||
" - T=type,I=input,E=enum,U=union,F=interface;s=String,i=Int,f=Float,b=Boolean,d=ID;!=required,[]=list,<>=implements" | ||
} else { | ||
|
@@ -246,4 +246,37 @@ mod tests { | |
"Expected to find the createUser mutation in search results" | ||
); | ||
} | ||
|
||
#[rstest] | ||
#[tokio::test] | ||
async fn test_search_tool_description_is_not_minified(schema: Valid<Schema>) { | ||
let schema = Arc::new(Mutex::new(schema)); | ||
let search = Search::new(schema.clone(), false, 1, 15_000_000, false) | ||
.expect("Failed to create search tool"); | ||
|
||
let description = search.tool.description.unwrap(); | ||
|
||
assert!( | ||
description | ||
.contains("Search a GraphQL schema for types matching the provided search terms") | ||
); | ||
assert!(description.contains("Instructions: If the introspect tool is also available")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: these two asserts aren't related to minified stuff. You could split these two into a separate test like |
||
assert!(description.contains("Avoid reusing previously searched terms")); | ||
// Should not contain minification legend | ||
assert!(!description.contains("T=type,I=input")); | ||
} | ||
|
||
#[rstest] | ||
#[tokio::test] | ||
async fn test_tool_description_minified(schema: Valid<Schema>) { | ||
let schema = Arc::new(Mutex::new(schema)); | ||
let search = Search::new(schema.clone(), false, 1, 15_000_000, true) | ||
.expect("Failed to create search tool"); | ||
|
||
let description = search.tool.description.unwrap(); | ||
|
||
// Should contain minification legend | ||
assert!(description.contains("T=type,I=input,E=enum,U=union,F=interface")); | ||
assert!(description.contains("s=String,i=Int,f=Float,b=Boolean,d=ID")); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you could argue that this last condition is testing something else entirely and not related to the minification stuff. You could technically split this in a separate test called like
instrospect_description_mentions_search_tool_usage
. I find it helpful to have small very directed unit tests. It helps quickly determining what is broken in tests in the future.