-
Notifications
You must be signed in to change notification settings - Fork 4
feat(parse): add contains_call_markup #44
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8a6ec5f
fix(parse): handle empty input in parser
senamakel e7032dd
fix(agent): handle empty markup in parse tests
senamakel 9bd731e
feat(parse): expose contains_call_markup and add its test module
senamakel 03a21f4
fix(parse): backtick-quote model and benchmark names in doc comments
senamakel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| //! `contains_call_markup`: telling text that is really a tool call apart from | ||
| //! an answer. | ||
|
|
||
| use crate::parse::contains_call_markup; | ||
|
|
||
| /// What `DeepSeek` V4 returned in place of a summary when its request declared | ||
| /// no tools (captured from the `OpenHuman` harness benchmark). | ||
| const DSML: &str = "<||DSML|| calls>\n<||DSML|| invoke name=\"shell\">\n\ | ||
| <||DSML|| parameter name=\"command\" string=\"true\">cd /app && cat src/lib.rs</||DSML|| parameter>\n\ | ||
| </||DSML|| invoke>\n</||DSML|| calls>"; | ||
|
|
||
| #[test] | ||
| fn a_dsml_call_is_markup() { | ||
| assert!(contains_call_markup(DSML)); | ||
| assert!(contains_call_markup(&format!( | ||
| "Let me check first.\n\n{DSML}" | ||
| ))); | ||
| } | ||
|
|
||
| #[test] | ||
| fn tagged_and_invoke_calls_are_markup() { | ||
| assert!(contains_call_markup( | ||
| "<tool_call>{\"name\":\"shell\",\"arguments\":{\"command\":\"ls\"}}</tool_call>" | ||
| )); | ||
| assert!(contains_call_markup( | ||
| "<invoke name=\"read\"><parameter name=\"path\">a.rs</parameter></invoke>" | ||
| )); | ||
| } | ||
|
|
||
| #[test] | ||
| fn a_block_that_does_not_decode_still_counts() { | ||
| // Opened and never closed: truncated mid-call. | ||
| assert!(contains_call_markup( | ||
| "<||DSML|| calls>\n<||DSML|| invoke name=\"shell\">\n<||DSML|| parameter name=\"command\"" | ||
| )); | ||
| } | ||
|
|
||
| #[test] | ||
| fn prose_a_bare_json_answer_and_a_quoted_example_are_not_markup() { | ||
| assert!(!contains_call_markup( | ||
| "## Goal\nShip the parser.\n\n## Active State\nConfig is {\"retries\": 3}." | ||
| )); | ||
| assert!(!contains_call_markup( | ||
| "{\"name\": \"shell\", \"arguments\": {\"command\": \"ls\"}}" | ||
| )); | ||
| assert!(!contains_call_markup( | ||
| "The format is:\n```xml\n<invoke name=\"shell\"><parameter name=\"command\">ls</parameter></invoke>\n```" | ||
| )); | ||
| assert!(!contains_call_markup("")); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: tinyhumansai/tinytools
Length of output: 26339
🏁 Script executed:
Repository: tinyhumansai/tinytools
Length of output: 19913
🏁 Script executed:
Repository: tinyhumansai/tinytools
Length of output: 14005
🏁 Script executed:
Repository: tinyhumansai/tinytools
Length of output: 6371
🏁 Script executed:
sed -n '90,112p' crates/tinytools-agent/src/parse/grammar/mod.rsRepository: tinyhumansai/tinytools
Length of output: 809
Exclude protected fences from GLM detection.
scanretains protected fence text as narrative, butparse_textalso passes it to the GLM fallback. The fallback parsesshell/command>lsin atextfence as a call, socontains_call_markupreturnstruefor a quoted example and can cause a caller to reject a valid answer. Restrict GLM detection to unprotected text, preserve fence contents in the narrative, and add a regression test.Regression test
@@ assert!(!contains_call_markup( "The format is:\n```xml\n<invoke name=\"shell\"><parameter name=\"command\">ls</parameter></invoke>\n```" )); + assert!(!contains_call_markup( + "```text\nshell/command>ls\n```" + ));🤖 Prompt for AI Agents