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
"Unknown identifier query" in Code Mode with MCP tools #49115
The Code Mode JS executor wraps LLM-generated code in an async function but doesn't declare MCP tool parameters (like query) as JS variables before execution. The LLM generates code referencing query but the variable doesn't exist in scope, causing the "Unknown identifier" error from acorn parser.
This is likely the same class of bug as #48910 — sandbox scope injection for MCP parameters is incomplete.
The Unknown identifier '<name>' error comes from Code Mode's JavaScript interpreter. It's thrown when the program reads a variable that was never declared, the same as a ReferenceError in normal JS. Code Mode doesn't put tool parameters in scope as variables. They're passed as an object argument, for example:
So if the model wrote something like search_nodes({ query }) without declaring query first, this error is expected. If the code passed query correctly and still failed, that would be a real bug in the interpreter. To tell which it is, could you share:
The exact code the model passed to the execute tool when the error happened. You can copy it from the expanded tool call in the TUI or from the session export. Column 30 of line 1 should point at the query in question.
The provider and model you were using.
Whether it still happens on the latest v2 release (2.0.3 is fairly old; v2.2.x is current).
You can reply here with the details or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.
I didn't find an existing report of this exact error. #48910, which you linked, is on the same version but is a different problem: MCP tool results come back as null.
This is the program referencing a variable it never declared: tool inputs are passed as an object, e.g. await tools.graphiti.search_nodes({ query: "..." }), not as variables in scope. The error points at the line that used query, which is the expected behavior, so I'm closing this.
We haven't heard back, so I'm closing this issue for now as not planned.
We were waiting for the exact code the model passed to the execute tool, plus the provider and model. Without them we can't tell whether the model used an undeclared query variable (expected behaviour: tool parameters go in an object argument such as search_nodes({ query: "..." })) or the interpreter mishandled valid code.
If this still happens on a current v2 release, please comment here with that code and we can reopen. Thanks, @lehcode!
Activity
opencodejr commentedon Oct 28, 2026
Thanks for the report, @lehcode!
The
Unknown identifier '<name>'error comes from Code Mode's JavaScript interpreter. It's thrown when the program reads a variable that was never declared, the same as aReferenceErrorin normal JS. Code Mode doesn't put tool parameters in scope as variables. They're passed as an object argument, for example:So if the model wrote something like
search_nodes({ query })without declaringqueryfirst, this error is expected. If the code passedquerycorrectly and still failed, that would be a real bug in the interpreter. To tell which it is, could you share:executetool when the error happened. You can copy it from the expanded tool call in the TUI or from the session export. Column 30 of line 1 should point at thequeryin question.You can reply here with the details or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.
I didn't find an existing report of this exact error. #48910, which you linked, is on the same version but is a different problem: MCP tool results come back as
null.rekram1-node commentedon Oct 29, 2026
This is the program referencing a variable it never declared: tool inputs are passed as an object, e.g.
await tools.graphiti.search_nodes({ query: "..." }), not as variables in scope. The error points at the line that usedquery, which is the expected behavior, so I'm closing this.opencodejr commentedon Oct 31, 2026
We haven't heard back, so I'm closing this issue for now as not planned.
We were waiting for the exact code the model passed to the
executetool, plus the provider and model. Without them we can't tell whether the model used an undeclaredqueryvariable (expected behaviour: tool parameters go in an object argument such assearch_nodes({ query: "..." })) or the interpreter mishandled valid code.If this still happens on a current v2 release, please comment here with that code and we can reopen. Thanks, @lehcode!