Skip to content

feat: c5#119

Merged
daniel-cohere merged 14 commits into
mainfrom
daniel/c5
Jul 8, 2026
Merged

feat: c5#119
daniel-cohere merged 14 commits into
mainfrom
daniel/c5

Conversation

@daniel-cohere

@daniel-cohere daniel-cohere commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

This PR introduces Command 5 (CMD5) support to the Melody parsing and templating library. CMD5 is a new prompt format that uses XML-like, cofl-tagged tool calls instead of the JSON action blocks in CMD4.

  • Parsing:

    • Adds a new FilterCoflAction struct and associated methods to parse cofl-tagged tool calls.
    • The parse_cofl_actions method handles incremental parsing of cofl tool call streams.
    • Supports both raw and processed parameter streaming modes.
    • Includes extensive tests for the cofl parser covering various tool call scenarios.
  • Templating:

    • Adds a new render_cmd5 function that uses the CMD5 jinja template.
    • The RenderCmd5Options type is an alias for RenderCmd4Options since CMD5 reuses the same option schema.
    • Template selection logic prioritizes template_id, then template_jinja, and falls back to the default CMD5 template.
    • Includes tests for the CMD5 renderer with various template configurations.
  • Python Bindings:

    • Adds render_cmd5 to the Python module.
    • Includes tests for the Python CMD5 renderer.
  • Other Changes:

    • Updates the special token map to include CMD5 tokens.
    • Adds CMD5-specific template files and updates the template configuration.
    • Updates documentation and comments to reflect CMD5 support.

Overall, this PR adds comprehensive support for the new CMD5 format while maintaining compatibility with existing CMD3 and CMD4 functionality. The changes are well-tested and follow the existing architecture of the library.


Note

Medium Risk
New streaming tool-call parsing path and format presets affect inference/templating correctness, but behavior is heavily fixture- and unit-tested and cmd3/cmd4 paths are explicitly isolated.

Overview
Introduces Command 5 (CMD5): same prompt options as CMD4, but tool calls use cofl XML (<cofl:tool_calls> / <cofl:tool_param>) instead of JSON <|START_ACTION|> blocks. A new incremental cofl_filter parser drives FilterOptions::cmd5() (with isolation so cmd3/cmd4 JSON actions do not leak into cmd5 and vice versa), plus render_cmd5 and bundled cmd5.jinja (XML-escaped params, shared cmd4 platform/reasoning pieces).

Bindings: Python (PyFilter.cmd5, render_cmd5, stubs), Go (RenderCMD5, Cmd5 / HandleMultiHopCmd5), and FFI (melody_render_cmd5, melody_filter_options_cmd5). cmd4-v1 Jinja now honors reasoning / reasoning_content in thinking macros (aligned with cmd4-v2/cmd5).

Infra: crate version 0.10.0; Python CI installs the local sdist so tests do not pick up a stale PyPI wheel; ty config allows optional vllm / cohere_melody imports; FFI option conversion preserves non-empty template_jinja even when use_jinja is false (needed for cmd5 custom templates).

Reviewed by Cursor Bugbot for commit c2ed9cd. Bugbot is set up for automated code reviews on this repo. Configure here.

daniel-cohere and others added 3 commits July 7, 2026 16:20
Port C5 templating from melody-internal: cmd5 jinja template with cofl
tool call format, cmd4 template refactor into shared macros, render_cmd5
across Rust/Python/Go FFI, and fixture tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Port C5 parsing from melody-internal: cofl XML tool call parser, cmd5
filter options, integration with the existing filter pipeline, and Python
tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Expose cmd5 filter options via Go bindings: FilterOptions.Cmd5(), C header
declarations, and melody_filter_options_cmd5 FFI entry point.

Co-authored-by: Cursor <cursoragent@cursor.com>
@daniel-cohere
daniel-cohere requested a review from a team as a code owner July 7, 2026 20:32
Comment thread src/parsing/options.rs
Split thinking macros so cmd4-v1 keeps pre-reasoning behavior while
cmd4-v2/cmd4-hf use reasoning/reasoning_content via dedicated includes.
Generated cmd4-v1, cmd4-v2, and cmd4-hf templates now match main exactly.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread template_generation/templates/jinja/cmd5/cofl/macros_tools.jinja
daniel-cohere and others added 10 commits July 8, 2026 09:14
Restore monolithic cmd4-v1 and cmd4-v2 templates from main. Use a
standalone cmd5.jinja instead of shared/action/cofl includes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This reverts commit c873e7f.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c2ed9cd. Configure here.

Comment thread tests/templating/jinja/cmd5/dev_instruction/input.json
@daniel-cohere
daniel-cohere merged commit 4f7b432 into main Jul 8, 2026
16 checks passed
@daniel-cohere
daniel-cohere deleted the daniel/c5 branch July 8, 2026 21:07
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.

1 participant