any resulting updates to agents.md should go under the section "## Rules to follow" When you see a convincing argument from me on how to solve or do something. add a summary for this in agents.md. so you learn what I want over time. If I say any of the following point, you do this: add the context to agents.md, and associate this with a specific type of task. if I say "never do x" in some way. if I say "always do x" in some way. if I say "the process is x" in some way. If I tell you to remember something, you do the same, update
For any code modification task: run dotnet build before applying changes to capture the current error count. After the changes, run dotnet build again and only commit if the error count stays the same or decreases; revert if it increases.
This repository tracks MLX as a submodule (extern/mlx) and publishes a native
bridge plus .NET bindings. Use the checklist below whenever upstream MLX moves
forward.
- Run the Sync MLX GitHub workflow or update manually:
git submodule update --remote extern/mlx
- Record the new upstream tag/commit in the PR description. Every automated
run opens a branch
mlx-sync/<version>with a tracking issue for follow-up.
- Compare tags:
https://github.com/ml-explore/mlx/compare/<old>...<new>. - Pay special attention to headers in
extern/mlx/mlx/and the public C++ API. - Enumerate interface changes that affect our C ABI and managed wrappers.
- Edit
native/include/mlxsharp/api.hto reflect new structs/functions. - Implement the bridge in
native/src/mlxsharp.cppusing real MLX calls—no stubs. Keep error handling and lifetime management consistent. - Regenerate build files if needed and ensure macOS/Linux settings remain in
native/CMakeLists.txt. - Build the native library on each platform:
cmake -S native -B native/build/<os> -DCMAKE_BUILD_TYPE=Release cmake --build native/build/<os> --target mlxsharp --config Release
- Extend enums/handles in
src/MLXSharp/Core/*.csto cover new constructs. - Add P/Invoke signatures in
src/MLXSharp/Native/MlxNativeMethods.csand new safe handles or helper classes as needed. - Update higher-level APIs that rely on the bridge; keep Microsoft.Extensions integration disabled until parity is re-implemented on top of the new core.
- Build the .NET project:
dotnet build src/MLXSharp/MLXSharp.csproj. - Ensure native binaries land under
src/MLXSharp/runtimes/...using the provided MSBuild targets. - Run the smoke tests (they skip automatically if the native library is
missing):
dotnet test src/MLXSharp.Tests/MLXSharp.Tests.csproj. - Add targeted tests for new functionality before merging.
- Update
docs/native-roadmap.mdif module coverage or sequencing changes. - Mention notable binding changes in PR descriptions and release notes.
- Confirm the automated PR + tracking issue produced by the sync workflow look
correct (issue assigned to
copoit). - Resolve the tracking issue only after code, tests, and docs are updated.
Following this playbook keeps the native interop layer aligned with upstream MLX and ensures future automation has a single source of truth for maintenance steps.