Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
466992b2
Unverified
Commit
466992b2
authored
Oct 06, 2025
by
Chang Su
Committed by
GitHub
Oct 06, 2025
Browse files
[router][tool call] Clean up redundant `detect_format` and `has_tool_markers` (#11270)
parent
155cbb51
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
21 deletions
+21
-21
sgl-router/tests/tool_parser_llama.rs
sgl-router/tests/tool_parser_llama.rs
+4
-4
sgl-router/tests/tool_parser_mistral.rs
sgl-router/tests/tool_parser_mistral.rs
+4
-4
sgl-router/tests/tool_parser_pythonic.rs
sgl-router/tests/tool_parser_pythonic.rs
+4
-4
sgl-router/tests/tool_parser_qwen.rs
sgl-router/tests/tool_parser_qwen.rs
+4
-4
sgl-router/tests/tool_parser_step3.rs
sgl-router/tests/tool_parser_step3.rs
+5
-5
No files found.
sgl-router/tests/tool_parser_llama.rs
View file @
466992b2
...
...
@@ -116,10 +116,10 @@ async fn test_llama_empty_arguments() {
async
fn
test_llama_format_detection
()
{
let
parser
=
LlamaParser
::
new
();
assert
!
(
parser
.
detect_format
(
r#"<|python_tag|>{"name": "test"}"#
));
assert
!
(
parser
.
detect_format
(
r#"{"name": "test", "parameters": {}}"#
));
assert
!
(
!
parser
.
detect_format
(
"plain text"
));
assert
!
(
!
parser
.
detect_format
(
r#"{"key": "value"}"#
));
// No name field
assert
!
(
parser
.
has_tool_markers
(
r#"<|python_tag|>{"name": "test"}"#
));
assert
!
(
parser
.
has_tool_markers
(
r#"{"name": "test", "parameters": {}}"#
));
assert
!
(
!
parser
.
has_tool_markers
(
"plain text"
));
assert
!
(
!
parser
.
has_tool_markers
(
r#"{"key": "value"}"#
));
// No name field
}
#[tokio::test]
...
...
sgl-router/tests/tool_parser_mistral.rs
View file @
466992b2
...
...
@@ -96,10 +96,10 @@ async fn test_mistral_with_brackets_in_strings() {
async
fn
test_mistral_format_detection
()
{
let
parser
=
MistralParser
::
new
();
assert
!
(
parser
.
detect_format
(
"[TOOL_CALLS] ["
));
assert
!
(
parser
.
detect_format
(
"Some text [TOOL_CALLS] ["
));
assert
!
(
!
parser
.
detect_format
(
"Just plain text"
));
assert
!
(
!
parser
.
detect_format
(
"[{
\"
name
\"
:
\"
test
\"
}]"
));
// JSON array without TOOL_CALLS
assert
!
(
parser
.
has_tool_markers
(
"[TOOL_CALLS] ["
));
assert
!
(
parser
.
has_tool_markers
(
"Some text [TOOL_CALLS] ["
));
assert
!
(
!
parser
.
has_tool_markers
(
"Just plain text"
));
assert
!
(
!
parser
.
has_tool_markers
(
"[{
\"
name
\"
:
\"
test
\"
}]"
));
// JSON array without TOOL_CALLS
}
#[tokio::test]
...
...
sgl-router/tests/tool_parser_pythonic.rs
View file @
466992b2
...
...
@@ -125,10 +125,10 @@ async fn test_pythonic_empty_arguments() {
async
fn
test_pythonic_format_detection
()
{
let
parser
=
PythonicParser
::
new
();
assert
!
(
!
parser
.
detect_format
(
"[function_name("
));
// Incomplete
assert
!
(
parser
.
detect_format
(
"[get_weather(city=
\"
NYC
\"
)]"
));
assert
!
(
!
parser
.
detect_format
(
"Just plain text"
));
assert
!
(
!
parser
.
detect_format
(
"{
\"
name
\"
:
\"
test
\"
}"
));
// JSON
assert
!
(
!
parser
.
has_tool_markers
(
"[function_name("
));
// Incomplete
assert
!
(
parser
.
has_tool_markers
(
"[get_weather(city=
\"
NYC
\"
)]"
));
assert
!
(
!
parser
.
has_tool_markers
(
"Just plain text"
));
assert
!
(
!
parser
.
has_tool_markers
(
"{
\"
name
\"
:
\"
test
\"
}"
));
// JSON
}
#[tokio::test]
...
...
sgl-router/tests/tool_parser_qwen.rs
View file @
466992b2
...
...
@@ -120,10 +120,10 @@ async fn test_qwen_with_newlines_in_strings() {
async
fn
test_qwen_format_detection
()
{
let
parser
=
QwenParser
::
new
();
assert
!
(
parser
.
detect_format
(
"<tool_call>"
));
assert
!
(
parser
.
detect_format
(
"Some text <tool_call>
\n
{"
));
assert
!
(
!
parser
.
detect_format
(
"Just plain text"
));
assert
!
(
!
parser
.
detect_format
(
"{
\"
name
\"
:
\"
test
\"
}"
));
// Plain JSON
assert
!
(
parser
.
has_tool_markers
(
"<tool_call>"
));
assert
!
(
parser
.
has_tool_markers
(
"Some text <tool_call>
\n
{"
));
assert
!
(
!
parser
.
has_tool_markers
(
"Just plain text"
));
assert
!
(
!
parser
.
has_tool_markers
(
"{
\"
name
\"
:
\"
test
\"
}"
));
// Plain JSON
}
#[tokio::test]
...
...
sgl-router/tests/tool_parser_step3.rs
View file @
466992b2
...
...
@@ -111,13 +111,13 @@ fn test_step3_format_detection() {
let
parser
=
Step3Parser
::
new
();
// Should detect Step3 format
assert
!
(
parser
.
detect_format
(
"<|tool_calls_begin|>"
));
assert
!
(
parser
.
detect_format
(
"text with <|tool_calls_begin|> marker"
));
assert
!
(
parser
.
has_tool_markers
(
"<|tool_calls_begin|>"
));
assert
!
(
parser
.
has_tool_markers
(
"text with <|tool_calls_begin|> marker"
));
// Should not detect other formats
assert
!
(
!
parser
.
detect_format
(
"[TOOL_CALLS]"
));
assert
!
(
!
parser
.
detect_format
(
"<tool_call>"
));
assert
!
(
!
parser
.
detect_format
(
"plain text"
));
assert
!
(
!
parser
.
has_tool_markers
(
"[TOOL_CALLS]"
));
assert
!
(
!
parser
.
has_tool_markers
(
"<tool_call>"
));
assert
!
(
!
parser
.
has_tool_markers
(
"plain text"
));
}
#[tokio::test]
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment