Skip to content

feat: System Message tools #6723

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

feat: System Message tools #6723

wants to merge 11 commits into from

Conversation

RomneyDa
Copy link
Collaborator

@RomneyDa RomneyDa commented Jul 20, 2025

A remake of #5809 and #6395

Adds support for tools in the form of system message instructions and response content parsing + tests
Tools are parsed as they come in, converted to ToolCalls, and on the way out converted back to text. Switching between native and non-native tools is interchangeable with this approach.
For now, this applies only to models that are NOT known to support native tools
Adds a warning to the Agent mode dropdown that shows for any models not known to be great with tools (including models that support native tools)
All models can now be used in Agent mode


Summary by cubic

Added support for using tools via system message instructions and response parsing for models that do not natively support tools. All models can now use Agent mode, with a warning shown for models not recommended for tool use.

  • New Features
    • Tools are now parsed from and converted to system message text for non-native tool models.
    • Added an experimental setting to force system message tool usage.
    • Agent mode is available for all models, with a warning in the UI for models not recommended for tools.
    • Tests and utility functions for system message tool parsing and formatting.

@RomneyDa RomneyDa requested a review from a team as a code owner July 20, 2025 08:53
@RomneyDa RomneyDa requested review from tomasz-stefaniak and removed request for a team July 20, 2025 08:53
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jul 20, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic analysis

2 issues found across 24 files • Review in cubic

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

@RomneyDa RomneyDa requested review from sestinj and removed request for tomasz-stefaniak July 20, 2025 09:59
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jul 20, 2025
@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Jul 22, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 22, 2025
@sestinj
Copy link
Contributor

sestinj commented Jul 22, 2025

This was the output in the continue Console, but chat window didn't seem to parse the whole thing. This is with Claude Sonnet 4, and it reproduces seemingly every time with "remove the comments from test.js"

Screenshot 2025-07-22 at 1 30 48 PM
Now I'll remove all the comments from the test.js file, including JSDoc comments, inline comments, and TODO comments.

```tool
TOOL_NAME: search_and_replace_in_file
BEGIN_ARG: filepath
test.js
END_ARG
BEGIN_ARG: diff
[
"------- SEARCH
/**
 * A calculator class that supports method chaining for basic arithmetic operations.
 * Maintains an internal result state that can be modified through various operations.
 */
class Calculator {
  /**
   * Initialize the calculator with a result value of 0.
   */
  constructor() {
    this.result = 0;
  }

  /**
   * Add a number to the current result.
   * @param {number} number - The number to add
   * @returns {Calculator} Returns this instance for method chaining
   */
  add(number) {
    this.result += number;
    return this;
  }

  /**
   * Subtract a number from the current result.
   * Note: This method appears to be incomplete - it doesn't perform the subtraction.
   * @param {number} number - The number to subtract
   * @returns {Calculator} Returns this instance for method chaining
   */
  subtract(number) {
    // TODO: Implement subtraction logic
    // this.result -= number;
    return this;
  }

  /**
   * Multiply the current result by a number.
   * @param {number} number - The number to multiply by
   * @returns {Calculator} Returns this instance for method chaining
   */
  multiply(number) {
    this.result *= number;
    return this;
  }

  /**
   * Divide the current result by a number.
   * @param {number} number - The number to divide by
   * @returns {Calculator} Returns this instance for method chaining
   * @throws {Error} Throws an error if attempting to divide by zero
   */
  divide(number) {
    // Prevent division by zero
    if (number === 0) {
      throw new Error("Cannot divide by zero");
    }
    this.result /= number;
    return this;
  }

  /**
   * Get the current result value.
   * @
assistant
returns {number} The current result
   */
  getResult() {
    return this.result;
  }

  /**
   * Reset the calculator result back to 0.
   * @returns {Calculator} Returns this instance for method chaining
   */
  reset() {
    this.result = 0;
    return this;
  }
}
=======
class Calculator {
  constructor() {
    this.result = 0;
  }

  add(number) {
    this.result += number;
    return this;
  }

  subtract(number) {
    return this;
  }

  multiply(number) {
    this.result *= number;
    return this;
  }

  divide(number) {
    if (number === 0) {
      throw new Error("Cannot divide by zero");
    }
    this.result /= number;
    return this;
  }

  getResult() {
    return this.result;
  }

  reset() {
    this.result = 0;
    return this;
  }
}
+++++++ REPLACE"
]
END_ARG
```

Same happened with Qwen 2.5-Coder 32B, here was the output:

assistant
To remove the comments from `test.js`, I will use the `search_and_replace_in_file` tool to target and remove the comment lines. Here is the
assistant
 tool call:

```tool
TOOL_NAME: search_and_replace_in_file
BEGIN_ARG: filepath
test.js
END_ARG
BEGIN_ARG: diff
assistant
[
"------- SEARCH
// TODO: Implement subtraction logic
=======
+++++++ REPLACE",
"------- SEARCH
// Prevent division by zero
=======
+++++++ REPLACE"
assistant
]
END_ARG
```

This will remove the specific comment lines found in the `grep_search` output. If there are more comments to remove, I will
assistant
 need to identify them and add more SEARCH/REPLACE blocks accordingly.

It really feels like it's working, maybe just a small parsing issue? Other than this and making the thing experimental I am 100% behind this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants