Skip to content

fix: tool-arg schema coercion + mlx agent session fixes - #330

Merged
Brooooooklyn merged 42 commits into
mainfrom
fix/tool-arg-schema-coercion
Nov 3, 2026
Merged

Brooooooklyn merged 42 commits into
mainfrom
fix/tool-arg-schema-coercion

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What

Tool-call arguments are now converted to the types in the request's tool schema before they reach JS. With schema {limit: {type: integer}}, a Qwen3.5/3.8 chatml <parameter=limit>900</parameter> now arrives as the number 900, not the string "900".

Why

Bare-text tool formats (Qwen chatml <parameter=…>, K2 xml, Muse-Glimmer <atem:parameter>) look the same whether the model meant 900 or "900", so the chatml parser turned every scalar into a JSON string. Strict clients then fail. grok-build's serde, for example, reports invalid type: string "900", expected usize.

How

model text --> parser (doesn't read schema) --> ToolCallResult { arguments, raw_argument_text }
                                                  |
   ChatConfig.tools --> ToolArgSchemas ---------> coerce at the NAPI exit
                                                  |  sync:   send_chat_and_await
                                                  |  call:   ChatSessionCall.result()
                                                  |  stream: pump coerces the final chunk
                                                  v
                                        JS gets {"limit": 900}
  • tools::coerce is a port of vLLM's _fix_arg_types / coerce_to_schema_type. It reads type, enum, anyOf/oneOf/allOf and type-name aliases, and goes into nested properties and items.
  • Parsers store each argument's original text, so a string-typed parameter keeps exactly what the model wrote.
  • K2: if the model gave an arg_type, that type is kept and the schema doesn't change it.
  • Muse-Glimmer: when the model wrote a JSON string literal, coercion works on its decoded text.
  • Integers are never produced above Number.MAX_SAFE_INTEGER, because NAPI would turn them into BigInt and JSON.stringify would throw.
  • Covers every chat NAPI exit: the chat_napi_surface macro and qianfan_ocr.
  • Requests with no tool schema behave exactly as before.

Verified

  • cargo test -p mlx-core --lib -- tools:: muse_glimmer:: k2_horizon::finalize engine:: with --test-threads=1: 847 passed. 23 of them are new coercion tests.
  • Red check: turning off coerce_calls makes the chatml live-repro test fail ("300000" instead of 300000).
  • cargo clippy -p mlx-core --all-targets -D warnings, cargo fmt --check, yarn build:native and yarn typecheck all pass. No .d.cts change.
  • Known issue already on main: some GPU-scheduler tests fail when run in parallel (--test-threads=8). They fail the same way on base 038c45d24 and pass when run serially.

Also fixes (from the live mlx agent log)

Source: a live mlx agent session (Qwen3.8-27B GGUF + DFlash2, 1 main + 1 planner + 4 research subagents). Impact numbers are measured from inference.log, traces and client logs.

  • Cancelled DFlash2 prefill keeps the session (qwen3_5 dense, plus the identical Qwen3.5 MoE DFlash2, Muse-Glimmer DFlash and Gemma4 assistant flat-draft turns): the cancel is checked before the cache reset and before the first prefill chunk. Before this, a cancel always ran the first 2048-token chunk and wiped the flat cache. In the log, 55.8 s of prefill was thrown away and about 7-8 s of GPU ran after ctrl_c.
  • Streaming requests whose client left while queued are no longer dispatched (/v1/messages, /v1/responses). 2 turns started 4-8 s after the client cancelled. Each one is a 10-40k-token cache-miss prefill (16-72 s) that nobody receives, and it resets the flat cache.
  • A forced tool_choice renders with thinking off (named tool, required, Anthropic any). grok's session_title side call (max_tokens 100) spent all 100 tokens on reasoning in 4 of 5 calls and fell back to placeholder titles: 17.5 s wasted (20.4 s for all 5 title calls).
  • mlx agent turns off grok's web_search and xAI media tools against local mlx serve (--disable-web-search, GROK_IMAGE_GEN/IMAGE_EDIT/VIDEO_GEN=0; a value the user already exported wins). 2 turns where every call failed: 32.9 s TTFT, 41.0 s server time, 20,518 tokens re-prefilled. One researcher used 3 of its 4 turns before falling back to local files.
  • mlx serve --preload <name>; mlx agent preloads its -m model so the load overlaps grok startup. The first token arrived 73.6 s after the first prompt, and serve had been idle for 27.2 s before that prompt arrived.
  • The agent trace log keeps warn/error from all of mlx_core and mlx_paged_attn (info stays limited to inference/decode). Before this, memory and wired-limit warnings, cancel reasons and fallback warnings were filtered out of the agent log. No runtime cost; it only makes problems visible in the log.
  • The installed-agent eval (evals/agent-installed) now launches the agent the way mlx agent does (same flags, env and preload).
  • DeepSeek V4.1 DSML after the rebase: its parameters are typed per value (string="true"|"false"). A new test checks that values the schema admits stay as they are and that the rest are coerced.

Companion grok-build fix (PR #1): the built-in deep-research workflow is no longer listed with a CI-only CARGO_MANIFEST_DIR path, and its listing shows the launch shape (source {"type":"name",...}, args {"query": ...}). In the log this cost about 3 extra main turns (24-44 s of server time) while the model read a missing file and put query inside source.

Decisions made in this PR:

  • A named or required tool_choice renders with thinking off. No grammar-constrained decoding.
  • The 6b cancel fix also covers the same bug in qwen3_5_moe DFlash2, Muse-Glimmer DFlash and the Gemma4 assistant flat draft.

Companion client PR: mlx-node/grok-build#1.

DFlash2: one cache state per agent session

Before, Qwen3.5/3.8 DFlash2 kept one flat cache for the whole model. Each turn from a different agent session missed and prefilled its full prompt again. In the logged session this cost ~515 s of 1002 s server time.

before:  main ─┐                          after:  main ──► state A (parked, keyed by content)
         sub1 ─┼─► 1 flat cache (thrash)          sub1 ──► state B
         sub2 ─┘                                  sub2 ──► state C   (evicted by memory budget)
  • 0b8d90f7f golden-trace harness (bitwise traces on tiny fixtures).
  • 4c0176f36 turn trace, replay point, and one shared dense/MoE DFlash2 turn (qwen3_5/dflash2_turn.rs).
  • 31a9c7285 content-keyed multi-slot state store: park, restore by move, resume at the end state (E) or at a captured point (C(R)).
  • aaa032b14, 249440314 a user cancel never runs ResetScope::Command. It drops only the live state and parks the resumed anchor; other errors still fail closed.
  • f6eb13517..5e65d262b review fixes: eviction budget, evicted miss reason, CB activation parks the state, the armed capture keeps the unarmed draft append schedule.

Gate results (Qwen3.8-27B GGUF, M5 Max)

check result
goldens (X0, bitwise) 12/12 equal
tiny-fixture suites (gated_delta, dflash2*, MoE dflash2_decode, dflash2_attention) all pass; clippy -D warnings and fmt clean
G1: 4 interleaved sessions prefilled == ideal (86,750 / 86,750); 16/16 outputs equal serial (X1)
T=0 output bytes vs base 6/6 identical
bench acceptance A vs base identical on 3 prompts
G2: replay of today's 6-session agent run prefilled 148,735 tokens vs 439,150 today (-66%); 1.066 × the ideal flat floor; every main turn hits at the previous point
resume TTFT (S1.9) hit 0.2-0.6 s vs cold 56 s (32K) / 145 s (80K) / 414 s (160K)

Gate rows that do not pass, and why I accept them:

  • G2 "≤ 25% of today" and "TTFT ≤ 1/5": these limits came from the 2026-10-29 run (92% waste). Today's run has more needed prefill (new sessions, large tool results), so even a perfect store prefills 31.8%. The branch is at that floor (1.066 ×).
  • S1.9 "A identical to cold": a resumed turn prefills on a different chunk grid, so the target logits are X3 (close, not bitwise). Acceptance differs by a few percent in both directions; mean cycle time is 0.905-1.086 × cold. 12 of 27 cases ran; I stopped the repeat trials because the first trial already decided the result.
  • Bench C +7.4% on one prompt (p1): the other 2 prompts are within ±0.7%, A and output bytes are identical, and an unrelated job held the load average at 15-41 during the run.

Test and release changes

  • __test__/cli/agent-e2e.test.ts: the old sentinel ("hello from mlx agent") sent the 0.8B model into long skill searches, which sometimes ran past the 240 s kill (same rate on main). The test now uses a neutral word, --no-subagents --no-plan, and kills the process group on timeout so mlx serve does not stay alive with the model loaded. 3/3 local runs pass (19-96 s).
  • scripts/dflash2-agent-replay.ts loads only the recorded sessions from the default dir.
  • MLX_AGENT_MIN_RELEASE is now mlx-agent-v0.3.2:
    • v0.3.1 (grok-build#1): lenient int/number/bool tool args, workflow listing fix.
    • v0.3.2 (grok-build#2): the exit hint prints GROK_RESUME_COMMAND. mlx agent sets it to mlx agent, so the hint reads mlx agent --resume <id>, not grok --resume <id> (no grok is on PATH).

Review fixes after the DFlash2 push

  • Scheduled pool grow (Codex, high): with MLX_CONTINUOUS_BATCHING=1, a refused page-pool grow now evicts parked DFlash2 states and retries once (dense + MoE). Before, parked states could cause context_length_exceeded for a request that fits after eviction. The scheduler hook is a no-op for other families.
  • Replay script token (Codex, medium): --auth-token=<tok> as one argument.
  • CI-only test failure: the CI runner's GPU cannot launch the fused GDN kernels, so the forward takes the chain route. capture_keeps_route_bits_and_owns_state now expects the route the host can run. On the chain route, a capture inside a 64-row chunk matches a shorter forward to about one bf16 step (0.5-0.6% of the state range, checked within 1/64); every other route stays bit-exact.

Live check: the original prompt in splash

mlx agent --trace -p "Deepresearch this project, help me understand it" on Qwen3.8-27B GGUF + DFlash2 with this branch (1 main + 4 subagents, 110 requests, stopped after ~40 min):

2026-11-03 03:22 session (main) this branch
prompt tokens from cache ~8% 92% (7.47M of 8.16M)
prefilled beyond the ideal 92% of prompt tokens 0 (prefilled == ideal on every turn)
read_file type errors (invalid type: string "900") yes 0 of 144 calls

TTFT from this run is not reported: other jobs shared the machine during it.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9fad9768-00de-4c8b-9e3e-9376d12c1603

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T14:48:11.896343Z 3e4d36a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ea1bbf252

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/mlx-core/src/tools/coerce.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a73add36e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/mlx-core/src/tools/coerce.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b01a9b39e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/mlx-core/src/tools/coerce.rs Resolved
Brooooooklyn and others added 13 commits November 3, 2026 12:45
Bare-text tool formats (Qwen3.5/3.8 chatml <parameter=...>, K2 xml,
Muse-Glimmer <atem:parameter>) cannot tell 900 from "900", so the chatml
parser emitted every scalar as a JSON string. Strict clients such as
grok-build then fail with `invalid type: string "900", expected usize`.

Port vLLM's _fix_arg_types / coerce_to_schema_type as tools::coerce and
run it once at every chat NAPI exit (sync, ChatSessionCall.result, and
the stream pump's terminal chunk), including qianfan_ocr. Parsers record
each argument's verbatim text so a string-typed schema keeps the value as
written. K2 values typed by arg_type are never re-typed. Coerced
integers stay within Number.MAX_SAFE_INTEGER. Requests without tool
schemas are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Typed scalars (JSON, LFM2, nested JSON) the schema already admits are
returned unchanged; schema-priority interpretation now applies only to
bare text and to typed values the schema does not admit. allOf branches
intersect with each other and the enclosing type (integer within
number); an empty intersection leaves the value as parsed. Both are
documented as deliberate differences from vLLM.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An Option<Enum> schema ({"anyOf":[{"$ref":...},{"type":"null"}]})
resolved to null-only, so valid typed strings like "true" were rewritten.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DeepSeek V4.1 (from main) exposes chat only through chat_napi_surface!, so
all of its exits already carry tool_schemas. DSML marks every parameter
string="true"|"false", so it is a model-typed format like K2 arg_type and
stays off the raw-text path: an admitted value is kept, a value the schema
does not admit is coerced.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ll chunk

A turn cancelled after it started but before prefill reset the flat cache
(prefix miss) or failed closed (prefix hit), destroying the live session,
and the prefill loop skipped the cancel poll for chunk 0, so the first
2048-token chunk always ran. The turn now returns PREFILL_CANCELLED right
after the non-mutating prefix decision, before any reset, and the chunk
loop polls before every chunk.

The same reset-before-cancel-check exists byte for byte in the Qwen3.5 MoE
DFlash2, Muse-Glimmer DFlash and Gemma4 assistant flat-draft turns; they
get the same fix and their own tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The H2 pre-dispatch disconnect check only covered non-streaming requests.
A streaming request whose client left while it was queued still reset the
session and started a native turn (cache reset, first prefill chunk)
before the stream noticed the abort. Both /v1/messages and /v1/responses
now return before dispatch for either mode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Callers that force a tool (grok's session_title side call: one tool,
max_tokens 100) lost the whole budget to reasoning and finished with
length and no call. A named tool, Responses 'required' and Anthropic 'any'
now render with reasoningEffort none, thinking budget 0 and no reasoning
output. auto, none and an absent tool_choice are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
grok's web_search is an xAI server-side tool and image_gen, image_edit,
image_to_video and reference_to_video post to the xAI base URL, which a
served launch points at mlx serve. In the live session each call failed
with a 400 and cost a whole agent turn. Served launches now pass
--disable-web-search (unless the user already did; clap rejects a repeat)
and set GROK_IMAGE_GEN/GROK_IMAGE_EDIT/GROK_VIDEO_GEN=0 unless exported.
Subagents inherit both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
mlx serve loads lazily, so the first agent request waited for the whole
model load (73.6 s before the first token in the live session, 27.2 s of
it with serve idle before the first prompt arrived). mlx serve gains
--preload <name>, which starts InferenceHost.loadModel right after the
listening banner (a failure is logged and the server keeps running), and
mlx agent passes it for the -m model when that model is a discovered
local one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The default agent trace filter named only mlx_core::inference and
mlx_core::decode, and Targets drops any target with no directive, so
every warn/error from the rest of mlx_core (memory, model code) and from
mlx_paged_attn was lost. The default now floors mlx_core and
mlx_paged_attn at warn; the more specific info directives still win.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The eval mirrors mlx agent / mlx delegate, so it now passes
--disable-web-search, sets the media-tool env switches and starts its
mlx serve with --preload for the default model, through shared helpers
that the report's cliInvocation also uses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Brooooooklyn
Brooooooklyn force-pushed the fix/tool-arg-schema-coercion branch from ffb990b to 1a3a2cf Compare November 3, 2026 05:45
@Brooooooklyn Brooooooklyn changed the title fix(tools): coerce tool-call arguments to the request tool schema fix: tool-arg schema coercion + mlx agent session fixes Nov 3, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a3a2cf0de

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/mlx-core/src/tools/coerce.rs Resolved
… schemas into combinators

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cba9a15114

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/mlx-core/src/tools/coerce.rs Resolved
Comment thread crates/mlx-core/src/tools/coerce.rs Resolved
Brooooooklyn and others added 2 commits November 3, 2026 14:28
…container branch ambiguous

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A base64url token starts with '-' about 1 time in 64, and parseArgs then
reads it as a flag, so mlx serve exits before reporting a port and
mlx agent fails to start. Seen in the gated agent e2e smoke.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brooooooklyn and others added 4 commits November 3, 2026 22:15
A user cancel during a DFlash2 prefill failed closed through
ResetScope::Command, which cleared every session's parked state and the
live anchor and purged the paged prefix cache. Agent clients cancel often,
so one cancelled subagent turn threw away every other session's state.

A cancel now drops only the state the turn was building: the live flat
state and the live paged requests, keeping the state store and the paged
prefix cache. A cancel the prefill sees before its first chunk is polled
before the draft context is taken, so the state the resume moved in stays
live and keyed under the turn's salt. Every other error still fails
closed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brooooooklyn and others added 19 commits November 3, 2026 22:15
The turn's KV budget is 9/10 of the live headroom, so a freed parked byte
raises it by only 9/10 of a byte. Eviction credited frees 1:1 and could stop
while parked bytes were left, sending the reserve down the growth path.
Evict against the least headroom whose budget covers the need.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The prefix event always passed evicted_depth 0, so a miss on a lineage
whose parked state was evicted read as cross_session. The store now
remembers the last 64 resume points that eviction removed (block chain
hashes plus the tail tokens) and the turn reports the deepest one on its
prompt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…led verify ran

The eager verify gives the same bits, so a silent fall back passed the
test. Assert the compiled-verify counter for every turn and its forced
cycles, and that the verify was never disabled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts on the calibrated host only

merge_projections claimed only the M = 8 tier differs from the separate
projections; the route probe shows the merged context k|v also differs at
1 row on the Qwen3.8 draft geometry. The probe's width assertion depends on
the GPU's kernel tiers and core count, so it now runs on the calibrated
host only, like the exact partitions; slot and padding invariance still run
everywhere. Also drops plan labels from test docs and messages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ted_segment doc

A capture window of at most 32 rows runs through gated_delta_update_fused
segment by segment, and no test split that entry. Add the split identity
at every row of 17..=32-row windows (max_ulps 0 on rows, final and captured
states). routed_segment mixes entries by segment length; its doc claimed it
was the layer's routing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s the flat caches

A continuous-batching admission installs the owner's history and then
activates the sequence, which replaced the flat caches; a DFlash2 end state
left by an exclusive turn was dropped instead of parked like at the other
paged sites. Dense and MoE now park it in install_owner_state and in
activate_scheduled_recurrent when no scheduled sequence is active.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…apture is armed

Every chat prompt that ends with the generation suffix arms C(R), and moving
keep_from to R - window changed the live draft append widths, which change
draft K/V bits on the tiled quantized kernels. The live context now always
appends as an unarmed prefill; a capture that needs rows that schedule only
records runs its own schedule on a shadow context up to R.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…chor

A cancel after the first prefill chunk of a resumed turn dropped that
session's whole state, so the retry, carrying the same prefix, prefilled
cold. The prefill and decode write only rows past the resume point, so the
live anchor at or below it still resumes exactly: it now parks with the
full-attention caches trimmed to its row before the rest of the live state
is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er turns

Parked states took memory that before them stayed free for the turn's
transients, so the reserve now evicts until the live headroom also covers a
first-order estimate of them (the larger of one prefill chunk and the decode
cycle plus its capped pool). With unreadable limits parked KV has no bound,
so every entry holding KV is evicted. Paged, vision and MTP turns on a
DFlash2 model evict parked states for their own KV and transients before
they start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n timeout

The prompt sentinel 'hello from mlx agent' sent the 0.8B model into long
skill/tool searches; a degenerate decode inside a buffered tool call then
ran past the 240 s kill. Use a neutral word, disable subagents and plan
mode, and kill the whole process group so mlx serve does not stay alive
with the model loaded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
v0.3.1 accepts string-typed integer, number and boolean tool arguments
and carries the workflow listing fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…is declined

A continuous-batching admission bypasses ChatBackend::run_paged_turn's
eviction, and the page-pool grow's headroom probe reads live Metal memory
that parked DFlash2 states hold. With no live turns a declined grow
rejected the request as context_length_exceeded even when evicting those
states would let it fit. The scheduler now asks the backend to release
memory outside the pool after a declined grow and retries the grow once;
the default releases nothing, so other families keep the existing path.
Qwen3.5 dense and MoE evict every parked state that holds bytes, keeping
the live state.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A base64url token starts with '-' about once in 64 launches, and serve's
parseArgs then rejects `--auth-token <token>` as an ambiguous value. The
replay now passes `--auth-token=<token>`, like the mlx agent launcher and
the installed-agent eval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
capture_keeps_route_bits_and_owns_state hard-coded each case's route. On
the GitHub macOS runner the fused prefill pipeline cannot hold one value
head per threadgroup, so the forward falls back to the chain and the
uncaptured-route assertion failed ([Chain] vs [FusedPrefill]). The test now
asserts the intended route only where its kernel launches (the existing
launch probes, plus the prefill-fusion switch), otherwise asserts that the
declined route did not run, and checks the captured forward against the
route the host actually took.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to bf16 rounding

On a GPU where the fused GDN kernels decline (the CI runner), the forward
takes the chain route. A capture inside a 64-row chunk then comes from
other chunk products than the shorter forward: measured 0.5-0.6% of the
state range (about one bf16 step). Check the chain route within 1/64 of
the range; every other route stays bit-exact. A 1/1024 bound fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
grok prints 'grok --resume <id>' on exit, but mlx agent does not put a
grok binary on PATH. Set GROK_RESUME_COMMAND=mlx agent (a user value
wins); the grok-build fork prints it in place of grok.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
v0.3.2 prints GROK_RESUME_COMMAND in its resume hints, so the exit hint
reads 'mlx agent --resume <id>'.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Brooooooklyn
Brooooooklyn force-pushed the fix/tool-arg-schema-coercion branch from b6542c2 to 9e688fc Compare November 3, 2026 14:15

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e688fc6f9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/mlx-core/src/tools/coerce.rs Resolved
For {"enum":["00042",7]} (no type), the ChatML text 00042 was coerced to
42, which is not a member. Keep the raw text when it equals a string
member of the property's enum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e192fe541f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/mlx-core/src/tools/coerce.rs Resolved
{"anyOf":[{"enum":["00042"]},{"type":"integer","enum":[7]}]} admits the
string 00042, but the guard only read a top-level enum, so the bare text
became 42. Search the same branches schema_types reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e4d36af35

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/mlx-core/src/tools/coerce.rs Resolved
…strings

{"type":"integer","enum":["7",7]} allows only the number 7, but the
enum-string guard kept the bare text as "7". Apply the guard only when
schema_types admits a string (or the schema is untyped).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Brooooooklyn
Brooooooklyn merged commit 7a09801 into main Nov 3, 2026
10 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/tool-arg-schema-coercion branch November 3, 2026 15:39
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