feat: c5#119
Merged
Merged
Conversation
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>
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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:
FilterCoflActionstruct and associated methods to parse cofl-tagged tool calls.parse_cofl_actionsmethod handles incremental parsing of cofl tool call streams.Templating:
render_cmd5function that uses the CMD5 jinja template.RenderCmd5Optionstype is an alias forRenderCmd4Optionssince CMD5 reuses the same option schema.template_id, thentemplate_jinja, and falls back to the default CMD5 template.Python Bindings:
render_cmd5to the Python module.Other Changes:
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 incrementalcofl_filterparser drivesFilterOptions::cmd5()(with isolation so cmd3/cmd4 JSON actions do not leak into cmd5 and vice versa), plusrender_cmd5and bundledcmd5.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 honorsreasoning/reasoning_contentin 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;
tyconfig allows optionalvllm/cohere_melodyimports; FFI option conversion preserves non-emptytemplate_jinjaeven whenuse_jinjais 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.