Files
magpie/docs
yetone 7ea8aeaba7 gateway: DSML written with a run of pipes (<||DSML||invoke) is made the call too, not left as text (#2623, OKURBITO)
DeepSeek wrote its tool call as <||DSML||invoke name="get_weather">…
(two full-width pipes each side) and the reply reached the Responses
client as that markup: textCallAt only knew the one-pipe marks, so
nothing was held and parseTextCalls, whose regexes already read a run
of pipes, never ran. dsmlMark now finds a DSML tag's mark as the parse
regexes (dsmlTag) read one, with no list of spellings: <, spaces, / and
spaces for a close, a pipe, a run of pipes and spaces, DSML, and
another run that may be empty. A pipe is ASCII | or full-width |, in
any number and any mix of widths. textCallAt uses it to find a call
and to hold a mark still being written (down to a full-width pipe's
first bytes); cutMark uses it to trim a tag cut short at the end, once
the tag has begun its pipes, so a value ending "a < " keeps its "<".
Every route goes through these: textCallSee (translations),
textCallTidy (relayed Chat streams) and wholeTextCalls (whole Chat
replies). OKURBITO pointed out on the issue that a spelling table
leaves |||, ||, || and the like as text; this reads the class.

Tests (textcalls_pipes_test.go). Which cases were seen and which were
made up, as OKURBITO set out on the issue: one reply was written by a
model on its own in real use (deepseek-flash offered web_search:
<||DSML|| calls> … <||DSML|| invoke name="web_search"> …), kept
byte for byte as observedPipes; the issue's get_weather reply came from
asking the model to echo the markup; every other spelling (three pipes,
ASCII, widths that disagree, spaces after <, no pipes after DSML) is
constructed and has not been seen.
- TestTextWrittenDSMLDoublePipe: the observed reply, relayed Chat
  streamed and whole, is a web_search call with its query and no DSML
  left; the issue's reply through /v1/responses, streamed and whole, and
  a whole Chat reply, is a get_weather call with {"city":"Beijing"} and
  no message item.
- TestTextWrittenDSMLAnyPipes: | | || || || || ||| ||| "| |", each reply
  sent one character per chunk: the call, wrapped with text before, a
  space before invoke (the live <||DSML|| invoke), no parameters, cut
  short, tags only with the last cut short, a tool not offered, a mark's
  start at the end, pipes without DSML; each ends as the one-pipe reply.
- TestTextWrittenDSMLDoublePipeEveryCut: the reply split at every byte
  boundary JSON allows is the same call; textCallAt holds each prefix of
  the mark, a full-width pipe's first bytes too.
- TestTextWrittenDSMLMarkAsParsed: widths that disagree within a tag
  and between its open and close, spaces after < and around /, no pipes
  after DSML are each the call; a cut-short <parameter> value ending in
  "a < " keeps it; "x < y and a <" stays text.

Fails without the change: with b7d9616d0's textcalls.go all four
FAIL, the observed reply among them ("text \"<||DSML||invoke …\" calls
map[] finish \"stop\"", "a message item beside the call"; MarkAsParsed's
widths that disagree, spaces after <, no pipes after DSML); the one-pipe
rows pass there. With an earlier draft of dsmlMark (a run of pipes,
none after <, one required after DSML) MarkAsParsed FAILs its
spaces-after-< and no-pipes-after-DSML rows; with cutMark's
has-begun-its-pipes guard taken out it FAILs the cut-short value ("a "
for "a < ").

Not tried against a real DeepSeek upstream: the fixtures are the
bytes OKURBITO posted. In the observed event the request offered only
a hosted web_search ({"type":"web_search"}), not a function; a call to
a tool the request didn't offer by name still goes on as text, as
before, and the test offers web_search as a function.

Run with both #2623's and #2625's changes, on b7d9616d0 (macOS, Go
1.26.8, load average 80-270 from other sessions):
- gofmt -l: nothing. go vet -tags nogui ./... with GOOS darwin, linux and
  windows: clean.
- set -o pipefail; go test -timeout 45m ./...: every package ok except
  internal/agent (2702s) and internal/gateway (2721s), which ran past
  45m under the load (#2544, #2108; no test hung, each was seconds into
  its run). Rerun with -timeout 90m: internal/agent ok (2816s);
  internal/gateway's only red is TestDesktopSubagentUnsetDoesNotDecode,
  "allocated 1 times" (10/10 green alone, filed as #2699). The textcalls
  tests passed in that run.
2026-10-17 18:41:43 +08:00
..