#6461 [Engine] A tool parameter named `function` is dropped even when the tool declares it (Playwright MCP `browser_evaluate`), patch included
open · @ThatsR4d · 0 comentários · No GitHub
Server & APINVIDIA / CUDAModels & quantsLinux
Descrição
### Area
[Engine] (speed, kernels, models, the server and API)
### Desktop app, Terminal or source?
Terminal (the `strata` command)
### What happened
A tool that declares a parameter literally named `function` never receives it. Playwright MCP's `browser_evaluate` has a required parameter `function` (the JavaScript to run); through Strata its argument always arrives empty (`{}` streamed, `{"function": ""}` non-streamed), so the tool fails. 0 of 29 `browser_evaluate` calls worked in our Claude Code + Playwright MCP sessions.
Cause: `serve/frontend.py` `param_name()` returns None for every name in `NOT_PARAMS = ("function", "think", "parameter")` (the #6032 guard against the call format's own tag names), even when the tool declares that parameter. Still the same on `main` (3142b66b9).
Fix: keep a name the tool declares. The patch below threads the declared parameter names into the `param_name` call sites; an undeclared `function` is still dropped as before. With it, the live Claude Code + Playwright session receives the argument and `browser_evaluate` works; the existing parser/tool tests behave the same before and after.
<details><summary>patch against main (applies to 0.1.63 and 3142b66b9)</summary>
```diff
--- a/terminal/serve/frontend.py
+++ b/terminal/serve/frontend.py
@@ -1104,12 +1104,14 @@
NOT_PARAMS = ("function", "think", "parameter")
-def param_name(opener: str) -> str | None:
+def param_name(opener: str, declared=None) -> str | None:
"""#6032 R1: the parameter a `<parameter=` opener names (`opener`: what follows `=` up to the `>` found): the name
cut at its first whitespace, `<` or `>` (the model ran a closer or `</think>` into it, or put a space before the
`>`); None - the value is read and dropped - when that leaves nothing, a placeholder (null / none) or one of the
call format's own tag names."""
name = re.split(r"[\s<>]", opener.lstrip(), 1)[0]
+ if declared and name in declared: # a tool may declare a parameter called `function` (Playwright's browser_evaluate)
+ return name
if not name or name in NOT_PARAMS or name.lower() in ("null", "none"):
return None
return name
@@ -1163,7 +1165,7 @@
line = s.split("\n", 1)[0]
gt = line.find(">")
if gt >= 0:
- return param_name(s[len(PARAM_START):gt]), gt + 1, None
+ return param_name(s[len(PARAM_START):gt], names), gt + 1, None
m = _COLON_OPENER.match(s)
if m:
value = m.group(2).strip()
@@ -1173,14 +1175,14 @@
tail = re.match(r"\s*" + re.escape(PARAM_END), s[m.end():])
if tail is None and not final and PARAM_END.startswith(s[m.end():].lstrip()):
return "pending"
- return param_name(m.group(1)), m.end() + (tail.end() if tail else 0), value
+ return param_name(m.group(1), names), m.end() + (tail.end() if tail else 0), value
if "\n" not in s:
# the `>` still arriving, or a long name: held, except that the call's own scan reads it as before when
# the line ends (a `<parameter=` line with neither `>` nor a colon form is no opener)
if s.find(">") < 0 and not final:
return "pending"
gt = s.find(">")
- return (param_name(s[len(PARAM_START):gt]), gt + 1, None) if gt >= 0 else None
+ return (param_name(s[len(PARAM_START):gt], names), gt + 1, None) if gt >= 0 else None
return None, len(line), None # #6032 R5: an opener cut before its `>` (its line ends first): dropped
if names:
m = _NAMED_OPENER.match(s)
@@ -1228,7 +1230,7 @@
gt = text.find(">", pos)
if gt < 0:
return -1
- pname = param_name(text[pos:gt].split("=", 1)[1])
+ pname = param_name(text[pos:gt].split("=", 1)[1], names)
end = param_end(text[gt + 1:], final, pname, hold, allow_reopen=True,
names=(set(names) - seen - {pname}) if names else None)
if end < 0:
@@ -1646,7 +1648,7 @@
if recover:
got = opener_at(rest, unset, final=True)
if got is None: # the old reading (a `<parameter=` with no `>` raises)
- got = (param_name(rest[len(PARAM_START):rest.index(">")]), rest.index(">") + 1, None)
+ got = (param_name(rest[len(PARAM_START):rest.index(">")], props), rest.index(">") + 1, None)
s = rest
pname, length, inline = got
openers += 1
@@ -2241,7 +2243,7 @@
b = stripped.find(">")
if b < 0:
return out
- got = (param_name(stripped[11:b]), b + 1, None) # #6032 R1: as parse_tool_call names it
+ got = (param_name(stripped[11:b], self.sdeclared), b + 1, None) # #6032 R1: as parse_tool_call names it
pname, length, inline = got
self.sp += length
self.sraw_pname = pname
```
</details>
### Smallest steps or command that reproduce it
With the Control's own Python, from `terminal/`:
```python
from serve import frontend as F
body = '<function=browser_evaluate>\n<parameter=function>\n() => document.title\n</parameter>\n</function>'
schema = {'name': 'browser_evaluate', 'parameters': {'type': 'object',
'properties': {'function': {'type': 'string'}, 'element': {'type': 'string'}}, 'required': ['function']}}
print(F.parse_tool_call(body, schema))
```
0.1.63 as released: `ToolCall(name='browser_evaluate', arguments={}, ...)`
With the patch: `ToolCall(name='browser_evaluate', arguments={'function': '() => document.title'}, ...)`
### Reproduction status
Reproduced locally
### Strata version
Strata 0.2.16 / Control 0.1.62 and 0.2.17 / Control 0.1.63
### Graphics card, memory and system
RTX 4090 24 GB, i9-14900K, 128 GB DDR5, Ubuntu 26.04 (Linux 7.0)
### Model, size and settings
Qwen3.8-Flash-Next IQ3_S; Claude Code 2.1.328 with Playwright MCP 0.0.86
No site
Links install, modelos, releases.