You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b9b20d8
Browse filesBrowse the repository at this point in the historyBrowse files
fix(tool_calling): land the GLM sibling-drop fix, and make the module usable by a host
Two halves, both discovered by actually wiring OpenHuman onto this module.
1. The GLM sibling drop (re-lands #104 against main)
#104 merged into #102's branch, but #102 had already merged to main - so the
fix never reached main. `main` today carries `tool_calling` with the
`#[ignore]`d test and no fix.
`parse_tool_calls_with_pformat` walks `<tool_call>`-family tags. Once ANY
tag yields a p-format call the walk never falls back to the canonical
parse, so every remaining tag has only the JSON path. A GLM body
(`shell/command>ls -la`) is not JSON, so the call was silently dropped.
The fallback runs ONLY when the JSON path found nothing: GLM's
`name/key>value` shape can occur inside a JSON string value
(`{"command": "cat a/b>c"}`), and an unconditional fallback would count
that body twice, making the agent run the same tool twice. Routing through
`parse_tool_calls` instead is also wrong - it forbids the argument-key
aliases for a bare top-level object, but a `<tool_call>` tag IS an explicit
marker where they apply, so that would trade one silent drop for another.
Both pinned by tests.
2. Host-consumability fixes
The first real consumer could not compile against this module:
- `extract_json_values` was unreachable, and it is not a test helper:
pulling the first JSON object out of model prose is how a host checks a
required-output contract, which has nothing to do with tool calls. Now
exported, along with `parse_arguments_value`,
`parse_glm_style_tool_calls`, `parse_tool_call_value` and
`parse_tool_calls_from_json_value`, all of which host tests exercise
directly.
- `parse_tool_call_value` was `#[cfg(test)]`, inherited from a host where
it was test-only. It is a reasonable primitive - parse one JSON value as
a tool call - so it is un-gated and documented rather than duplicated
host-side.
- `build_registry` took `&Value`. A host tool trait that RETURNS a schema
by value - the common shape - then has to collect into a temporary just
to hand out references. It takes `Borrow<Value>` now, so both forms work.
Without these a host either shadows the code it just stopped owning, or
loses the tests that covered it. OpenHuman keeps all 62 of its parser
tests working against the crate.
1823 lib tests pass, no ignores. Clippy and fmt clean.
Co-authored-by: Medulla <medulla@tinyhumans.ai>
0 commit comments