Skip to content

test: regression guard for #101 (no prompt-template wrapping; closes #101)#106

Open
jliounis wants to merge 1 commit into
mainfrom
jliounis/fix-reason-citations
Open

test: regression guard for #101 (no prompt-template wrapping; closes #101)#106
jliounis wants to merge 1 commit into
mainfrom
jliounis/fix-reason-citations

Conversation

@jliounis
Copy link
Copy Markdown
Collaborator

Summary

Closes #101.

TL;DR

The bug reported in #101 is not in this repository. It is in the third-party fork DaInfernalCoder/researcher-mcp, published on npm as perplexity-mcp v0.2.3. The reporter (@SangeethsivanSivakumar) confirmed this themselves while debugging:

Debugged the MCP wrapper (perplexity-mcp npm package v0.2.3 from DaInfernalCoder/researcher-mcp).

The official @perplexity-ai/mcp-server (this repo) forwards user messages to api.perplexity.ai verbatim. There is no template wrapping in any of the four tool handlers (perplexity_ask, perplexity_research, perplexity_reason, perplexity_search).

What this PR does

Adds a regression guard so we can never accidentally introduce the third-party fork's bug:

  1. Calls performChatCompletion with a representative user query.
  2. Asserts the outgoing request body's messages field equals the input verbatim.
  3. Defensively asserts that none of the poisoning keywords from the third-party fork's template ("error messages, logs, code snippets", "specific situation", "step-by-step reasoning based on the actual context") appear in the outgoing JSON.

If anyone ever re-introduces wrapper-template logic into this server, this test fails immediately.

Why no version bump

No code change, no behavior change — only a unit test. No 0.9.1 release is needed for this PR. The P0.1 LLM-provenance envelope PR (#105) is the change worth a minor bump; if that lands we can roll the version there.

Test plan

Recommended issue handling

When this PR merges, close #101 with a comment pointing the reporter at DaInfernalCoder/researcher-mcp (where the actual prompt = template + query code lives). Credit to @SangeethsivanSivakumar for the detailed root-cause analysis — their work narrowed this down to the exact npm package and patch.

Issue #101 reports that perplexity_reason returns irrelevant citations
because the tool wraps user queries in a verbose prompt template that
poisons Perplexity's search-term extraction. The reporter
(SangeethsivanSivakumar) debugged the bug themselves and identified the
root cause in the third-party DaInfernalCoder/researcher-mcp fork
(published on npm as perplexity-mcp v0.2.3), NOT in this repository.

Verified the official server: src/server.ts forwards user messages to
api.perplexity.ai verbatim with zero wrapping in all four tool handlers
(perplexity_ask, perplexity_research, perplexity_reason, perplexity_search).

This commit adds a regression test that:

1. Calls performChatCompletion with a representative user query.
2. Asserts the outgoing request body's `messages` field equals the
   input verbatim.
3. Asserts none of the known poisoning keywords from the third-party
   fork's template ("error messages, logs, code snippets",
   "specific situation", "step-by-step reasoning based on the actual
   context") appear in the request body.

If anyone ever re-introduces a wrapper template in this repo, this
test will fail immediately.

Closes #101 (root cause is in third-party fork, not this repo).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sonar Reasoning Pro (reason tool) returns irrelevant search results

2 participants