fix: disable phantom tool injection when proxying for opencode
opencode validates tool calls against its own registry and rejects unknown tools like memory_query. The opencode plugin provides mnemosyne_query/mnemosyne_status as registered MCP tools instead. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
7c6a3dbe4a
commit
6b9b3df64d
1 changed files with 19 additions and 15 deletions
|
|
@ -1610,21 +1610,25 @@ def create_app(
|
||||||
# 4. Build ephemeral outbound view — never mutate the physical store
|
# 4. Build ephemeral outbound view — never mutate the physical store
|
||||||
payload["messages"] = copy.deepcopy(ms.messages)
|
payload["messages"] = copy.deepcopy(ms.messages)
|
||||||
|
|
||||||
# 4a. Inject phantom tool definitions and resolve pending calls
|
# 4a. Phantom tool injection — DISABLED when proxying for opencode.
|
||||||
from mnemosyne.phantom import inject_tools, inject_phantom_results, extract_phantom_calls
|
# opencode validates tool calls against its own registry and rejects
|
||||||
|
# unknown tools like memory_query. Phantom tools require SSE stream
|
||||||
observe_only = inject_tools(payload)
|
# interception + auto-continue which the gateway doesn't implement
|
||||||
# Check for pending phantom calls from the previous assistant turn
|
# for the pass-through streaming path. The opencode plugin provides
|
||||||
pending_calls = extract_phantom_calls(payload.get("messages", []))
|
# mnemosyne_query/mnemosyne_status as registered MCP tools instead.
|
||||||
if pending_calls:
|
#
|
||||||
inject_phantom_results(
|
# from mnemosyne.phantom import inject_tools, inject_phantom_results, extract_phantom_calls
|
||||||
payload["messages"],
|
# observe_only = inject_tools(payload)
|
||||||
pending_calls,
|
# pending_calls = extract_phantom_calls(payload.get("messages", []))
|
||||||
ps,
|
# if pending_calls:
|
||||||
observe_only,
|
# inject_phantom_results(
|
||||||
context_assembler=session.context_assembler,
|
# payload["messages"],
|
||||||
session_id=session.id,
|
# pending_calls,
|
||||||
)
|
# ps,
|
||||||
|
# observe_only,
|
||||||
|
# context_assembler=session.context_assembler,
|
||||||
|
# session_id=session.id,
|
||||||
|
# )
|
||||||
|
|
||||||
# 4b. Apply fidelity-based content replacement
|
# 4b. Apply fidelity-based content replacement
|
||||||
_apply_fidelity(payload, session)
|
_apply_fidelity(payload, session)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue