Skip to content

cli-17: Fix special character escaping in tool descriptions#512

Merged
dwash96 merged 6 commits into
cecli-dev:v0.99.12from
szmania:cli-17-fix-special-character-escaping
May 13, 2026
Merged

cli-17: Fix special character escaping in tool descriptions#512
dwash96 merged 6 commits into
cecli-dev:v0.99.12from
szmania:cli-17-fix-special-character-escaping

Conversation

@szmania
Copy link
Copy Markdown

@szmania szmania commented May 12, 2026

Summary

This PR fixes special character escaping issues in tool descriptions across multiple files:

  • Fixed improper line breaks and spacing in tool description strings
  • Added proper JSON escaping for special characters in tool descriptions (particularly in models.py)
  • Improved consistency in multi-line string formatting

Changes

The changes primarily focus on:

  1. models.py: Added JSON escaping for tool descriptions to handle special characters like quotes, backslashes, and newlines properly. This prevents JSON parsing errors when these descriptions are passed to LLM APIs.

  2. agent_coder.py, io.py, context_manager.py, read_range.py: Fixed inconsistent line breaks and spacing in multi-line strings to improve readability and maintain consistency.

  3. tests/basic/test_models.py: Added a test case to verify that tool descriptions with special characters are properly escaped before being sent to the LLM API.

Why This Matters

These changes ensure that:

  • Tool descriptions with special characters (quotes, backslashes, newlines) are properly escaped when sent to LLM APIs
  • The codebase maintains consistent formatting for multi-line strings
  • We prevent potential JSON parsing errors that could occur when tool descriptions contain special characters

The test case verifies that the escaping mechanism works correctly with complex strings containing various special characters.

Testing

The changes have been tested with the new test case in test_models.py that verifies the escaping of special characters in tool descriptions.

Fixes: cli-17

Your Name added 5 commits April 29, 2026 19:24
Co-authored-by: cecli (openai/gemini_cli_local/gemini-2.5-pro)
Co-authored-by: cecli (openai/gemini_cli_local/gemini-2.5-pro)
@dwash96 dwash96 changed the base branch from main to v0.99.12 May 13, 2026 01:00
@dwash96 dwash96 merged commit 818d33f into cecli-dev:v0.99.12 May 13, 2026
1 check passed
@dwash96 dwash96 mentioned this pull request May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants