Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/utils/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"\n\n### SYSTEM: TOOL CALLING PROTOCOL (MANDATORY) ###\n"
"If tool execution is required, you MUST adhere to this EXACT protocol. No exceptions.\n\n"
"1. OUTPUT RESTRICTION: Your response MUST contain ONLY the [ToolCalls] block. Conversational filler, preambles, or concluding remarks are STRICTLY PROHIBITED.\n"
"2. WRAPPING LOGIC: Every parameter value MUST be enclosed in a markdown code block. Use 3 backticks (```) by default. If the value contains backticks, the outer fence MUST be longer than any sequence inside (e.g., ````).\n"
"2. WRAPPING LOGIC: Every parameter value MUST be enclosed in a markdown code block. Use 3 backticks (```) by default. If the value contains backticks, the outer fence MUST be longer than any sequence inside (e.g., ````). String typed values MUST be quoted (\")\n"
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

The protocol text says "String typed values"; this is grammatically awkward/ambiguous. Consider changing to "String-typed values" (or "Values of type string") and add a terminating period for clarity since this string is shown to the model verbatim.

Suggested change
"2. WRAPPING LOGIC: Every parameter value MUST be enclosed in a markdown code block. Use 3 backticks (```) by default. If the value contains backticks, the outer fence MUST be longer than any sequence inside (e.g., ````). String typed values MUST be quoted (\")\n"
"2. WRAPPING LOGIC: Every parameter value MUST be enclosed in a markdown code block. Use 3 backticks (```) by default. If the value contains backticks, the outer fence MUST be longer than any sequence inside (e.g., ````). String-typed values MUST be quoted (\").\n"

Copilot uses AI. Check for mistakes.
"3. TAG SYMMETRY: All tags MUST be balanced and closed in the exact reverse order of opening. Incomplete or unclosed blocks are strictly prohibited.\n\n"
"REQUIRED SYNTAX:\n"
"[ToolCalls]\n"
Expand Down Expand Up @@ -277,6 +277,12 @@ def strip_system_hints(text: str) -> str:

return cleaned

Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

PEP 8 expects two blank lines between top-level function definitions; currently there is only one blank line before def parse_arg_value(...) after strip_system_hints. Please insert an extra blank line to match the rest of this module’s formatting.

Suggested change

Copilot uses AI. Check for mistakes.
def parse_arg_value(val):
result = _strip_param_fences(val)
try:
return orjson.loads(result)
except orjson.JSONDecodeError:
return result
Comment on lines +280 to +285
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

parse_arg_value is the only top-level helper in this module without type hints and a docstring, which makes its intended input/output (and JSON-coercion behavior) less clear. Please add at least a val: str parameter annotation and an appropriate return type (e.g., object/Any), plus a short docstring describing the JSON-parsing fallback behavior.

Copilot uses AI. Check for mistakes.

Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

PEP 8 expects two blank lines between top-level function definitions; there is only one blank line between parse_arg_value and _process_tools_internal. Please add the extra blank line for consistent formatting.

Suggested change

Copilot uses AI. Check for mistakes.
def _process_tools_internal(text: str, extract: bool = True) -> tuple[str, list[ToolCall]]:
"""
Expand All @@ -301,7 +307,7 @@ def _create_tool_call(name: str, raw_args: str) -> None:
arg_matches = TAGGED_ARG_RE.findall(raw_args)
if arg_matches:
args_dict = {
arg_name.strip(): _strip_param_fences(arg_value)
arg_name.strip(): parse_arg_value(arg_value)
for arg_name, arg_value in arg_matches
}
arguments = orjson.dumps(args_dict).decode("utf-8")
Expand Down