Repository navigation
cli: tensorfold chat talks to a model in the terminal, through a serve child of its own or a running server's --url - #3538
Merged
Merged
Conversation
ashhart
added a commit
that referenced
this pull request
Nov 16, 2026
ashhart
added a commit
that referenced
this pull request
Nov 17, 2026
ashhart
force-pushed
the
lead/cli-chat
branch
3 times, most recently
from
November 19, 2026 16:03
13c39bb to
be32398
Compare
This was referenced Nov 19, 2026
…g, answer and tool calls A tokenizer with <|start|>, <|message|>, <|eom|> and <|eot|> as single tokens and a chat template that writes to=self messages (Muse Spark Open's) replies as messages to recipients. self is reasoning_content; user, commentary and no recipient are content; any other recipient is a tool call whose <atem:function_calls> block becomes the <tool_call><function=...> markup tool_parse and tool_stream already read, so its arguments take the tools' schema types. While a reply streams, an unfinished header, a call message that has not closed and a partial marker are held back, so every split extends the last and the finished split extends them all; the finished reply feeds the call streamer once more, so a last call ended by the end token streams too. Harmony's tokenizers have no <|eom|> or <|eot|>, so gpt-oss replies keep their channel split; tests cover both formats whole and streamed.
…ompt's open message read, thinking off kept off A call message max_tokens cuts stays open as far as it was written, named by its header until its invoke names the tool, so tool_stream reads it as the reply's cut call, whole and streamed, as #1299 made a GLM call; content never shows its markup. A stop string inside a call keeps the call's text, as the other formats keep theirs. The reply goes on from the prompt's last unclosed <|start|> header, so a generation prompt that already opened to=self<|message|> keeps the reasoning after it; Muse Spark Open's template ends at <|start|>assistant, with or without reasoning_effort. Only calls to offered tools become <tool_call> markup: with no tools, or a tool not offered, a call message stays as the model wrote it, as DSML, LFM2 and Qwen's XML calls do. Thinking off no longer turns the split's reasoning on: self messages stay out of the reply, and the template, which has no thinking switch, hears its lowest reasoning effort rather than its default (xhigh). Raw completion prompts keep the model's text. Tests cut a call before its invoke names the tool, inside a value, a value's closer, a parameter's name, between parameters, after the invoke closed, and in a call's header, at strides 1, 3, 7 and whole; and cover an opened prompt, no tools, an unoffered tool and thinking off.
…e the last call; a reply with no markup streams as it comes
…espace back, as the finished reply strips it
With main's loop-guard stop, chat.zig plus the recipient-reply hook reached 603 lines, past lean's 600. flag (Python's bool(fields.get(key))) is a fields helper, so it moves there unchanged; chat.zig calls fields_mod.flag.
Move the existing probe body unchanged to a sibling module and keep its call through an alias.
…ommand's served name, words, lock and user agent
…e child of its own or a running server's --url
… its environment; --url sends TENSORFOLD_API_KEY
ashhart
force-pushed
the
lead/cli-chat
branch
from
November 19, 2026 21:32
be32398 to
afd9e2a
Compare
Owner
Author
|
Thank you @ajensenwaud. This is merged into main with your commits under your own name, so you're credited as a TensorFold contributor. |
ashhart
added a commit
to hobbesd/TensorFold
that referenced
this pull request
Nov 19, 2026
ashhart
added a commit
that referenced
this pull request
Nov 19, 2026
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.
tensorfold chatwas a usage error. Talking to a model from the CLI meant runningtensorfold serve, then curl or another client. This adds an interactive terminal chat that starts its own server, or talks to a running one.What this changes
tensorfold chat MODEL: startstensorfold serve MODELas a child of the same binary on a free loopback port, waits until it is ready, chats, and stops it when the chat ends.--go to serve, checked up front with serve's own parser (tensorfold chat MODEL -- --parallel 1).--host,--port,--api-keyand--api-key-fileare refused there, since the chat owns the child's address and key.--nameis honoured.The child answers only the chat. Each child gets a fresh key: 32 random bytes as hex, only in its environment as
TENSORFOLD_API_KEY, sent as the bearer on every request including the readiness probe. It never appears in the command line or the chat's output, and a request without it gets 401. Without this, any local user could use the child's port while the chat runs.--url URL [MODEL]: talks to a running server instead. Without MODEL it uses the first model/v1/modelslists. WhenTENSORFOLD_API_KEYis set it is sent as the bearer, and a 401 names that variable.Each turn: streams
/v1/chat/completionsand prints content as it arrives, resending the conversation.reasoning_content, elsereasoning) is hidden by default, and--show-thinkingshows it dimmed.--no-thinkingsendschat_template_kwargs.enable_thinking: false, and is refused up front when/v1/modelsreports no thinking switch.--system,--temperature,--max-tokensand--startup-timeoutare accepted.In the chat:
/byeor Ctrl-D ends it,/clearforgets the conversation but keeps the system prompt,/system TEXTsets it, and/helplists these.| headstops the child cleanly.Piped stdin is sent as one message, and only the reply goes to stdout, exactly:
echo hi | tensorfold chat MODEL. On a terminal, control characters other than newline and tab are dropped from replies.Windows: starting a server is refused by name (the serve-child code is POSIX), and
--urlworks. The newcheck-chat-windows-hoststep compiles it for Windows.Reuse: the benchmark's serve child, SSE framing and JSON fetch are reused, not copied, extended with defaulted options for the served name, messages, lock, process group and key. The benchmark's own child and output bytes are unchanged, and a new test confirms its child still sees no key.
Issue: n/a. This came from the 16 Nov check of competitor gap docs against main (
ollama run, MLC, llamafile, Locals and MNN all ship a terminal chat); no issue or PR covered it.Stacked on: main. The router (
serve --router, in progress) will stack on this, since both extend the benchmark's serve child.atc overlap --json: to run after review.Checks on this head
tools/pr_check.py: 0 errors, 1 advisory warning, the PR number).zig build test-chat-cli-host test-benchmark-cancel-host test-benchmark-publication-host test-benchmark-routing-host test-thinking-benchmark-host check-chat-windows-host test-windows-port-host test-golden test-server-cpu: 37/37 steps, 1667/1676 tests (9 skipped). Within that,test-chat-cli-host45/45 andtest-server-cpu1503 pass.zig fmt --check,git diff --check: clean.--show-thinking,--no-thinkingand UTF-8 split across chunks all work./systemand/byework./v1/modelsis 401 without the key and 200 with it, and both--urlmessages appear.nativebinary wasn't built), Linux (itstest-hostsub-steps ran on macOS), and Windows beyond the compile check.Receipt
n/a: a CLI client over the existing HTTP API, which can't change what the engine computes. Host checks are above.
Checklist
The title and description match the head commit.
New tests fail before the change, pass after it, and skip cleanly without their dependency.
Comments and docstrings are one line. No measurements or history in the source.
No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
Synthena (Ash's Agent)