Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpt-4o works with custom mcp, but sonnet fails #1079

Open
dailydaniel opened this issue Feb 5, 2025 · 3 comments · May be fixed by #1097 or #1101
Open

gpt-4o works with custom mcp, but sonnet fails #1079

dailydaniel opened this issue Feb 5, 2025 · 3 comments · May be fixed by #1097 or #1101
Assignees
Labels
help wanted Extra attention is needed

Comments

@dailydaniel
Copy link

I use custom mcp server for logseq logseq mcp repo

gpt-4o responce:

starting session | provider: openai model: gpt-4o
    logging to /Users/daniel/.config/goose/sessions/21065VxD.jsonl


Goose is running! Enter your instructions, or try asking what goose can do.


( O)> hi, what is current logseq page?

─── logseq_get_current_page | logseq ──────────────────────────



The current Logseq page is titled "logseq mcp server," and it has no blocks yet.

sonnet openrouter responce:

starting session | provider: openrouter model: anthropic/claude-3.5-sonnet
    logging to /Users/daniel/.config/goose/sessions/8Y9dvJsR.jsonl


Goose is running! Enter your instructions, or try asking what goose can do.


( O)> hi, what is current logseq page?
I'll help you check the currently active page in Logseq using the `logseq_get_cu
rrent_page` function.
Invalid parameters: Could not interpret tool use parameters for id toolu_01H18N3
yVLZyh85EA93JZ37Z: EOF while parsing a value at line 1 column 0


◐  Inspiring innovations...                                                       2025-02-05T07:06:30.790155Z  WARN goose::providers::openrouter: Failed to get usage data: No usage data in response
    at crates/goose/src/providers/openrouter.rs:211
@dailydaniel
Copy link
Author

dailydaniel commented Feb 5, 2025

logs from sonnet:

output: {
  "choices": [
    {
      "finish_reason": "tool_calls",
      "index": 0,
      "logprobs": null,
      "message": {
        "content": "I'll help you check the currently active page in Logseq using the `logseq_get_current_page` function.",
        "refusal": null,
        "role": "assistant",
        "tool_calls": [
          {
            "function": {
              "arguments": "",
              "name": "logseq__logseq_get_current_page"
            },
            "id": "toolu_01H18N3yVLZyh85EA93JZ37Z",
            "index": 0,
            "type": "function"
          }
        ]
      },
      "native_finish_reason": "tool_calls"
    }

...

input: {
  "messages": [
    {
      "content": [
        {
          "cache_control": {
            "type": "ephemeral"
          },
          "text": "...",
          "type": "text"
        }
      ],
      "role": "system"
    },
    {
      "content": [
        {
          "cache_control": {
            "type": "ephemeral"
          },
          "text": "hi, what is current logseq page?",
          "type": "text"
        }
      ],
      "role": "user"
    },
    {
      "content": "I'll help you check the currently active page in Logseq using the `logseq_get_current_page` function.",
      "role": "assistant"
    },
    {
      "content": "Error: Invalid parameters: Could not interpret tool use parameters for id toolu_01H18N3yVLZyh85EA93JZ37Z: EOF while parsing a value at line 1 column 0",
      "role": "tool",
      "tool_call_id": "toolu_01H18N3yVLZyh85EA93JZ37Z"
    }
  ],

logs from gpt-4o:

output: {
  "choices": [
    {
      "finish_reason": "tool_calls",
      "index": 0,
      "logprobs": null,
      "message": {
        "content": null,
        "refusal": null,
        "role": "assistant",
        "tool_calls": [
          {
            "function": {
              "arguments": "{}",
              "name": "logseq__logseq_get_current_page"
            },
            "id": "call_P3MaeJp5bYDhGQjiaZPDyYIS",
            "type": "function"
          }
        ]
      }
    }
  ],

...

input: {
  "messages": [
    {
      "content": "...",
      "role": "system"
    },
    {
      "content": "hi, what is current logseq page?",
      "role": "user"
    },
    {
      "role": "assistant",
      "tool_calls": [
        {
          "function": {
            "arguments": "{}",
            "name": "logseq__logseq_get_current_page"
          },
          "id": "call_P3MaeJp5bYDhGQjiaZPDyYIS",
          "type": "function"
        }
      ]
    },
    {
      "content": "Created page: logseq mcp server\nUUID: 67a12cfa-54bf-42aa-96a0-687552970718\nJournal: False\nBlocks: 0",
      "role": "tool",
      "tool_call_id": "call_P3MaeJp5bYDhGQjiaZPDyYIS"
    }
  ],

@salman1993 salman1993 added the help wanted Extra attention is needed label Feb 5, 2025
@salman1993
Copy link
Collaborator

yeah there's some variation between the model providers and you have to experiment which one works best for you. Goose typically works best if you include instructions field in your MCP server. I would suggest trying to add in the instructions field in your server here: https://github.com/dailydaniel/logseq-mcp/blob/f0d507dcdd18c34c16cc04f213c84a3ee4cb09fd/src/mcp_server_logseq/server.py#L180

this recently got added to the MCP python and typescript sdk:
modelcontextprotocol/python-sdk#150

Goose will extract the MCP's instructions and add it to the model's system prompt: https://github.com/block/goose/blob/main/crates/goose/src/prompts/system.md?plain=1

@salman1993 salman1993 self-assigned this Feb 5, 2025
jasonkneen added a commit to jasonkneen/goose that referenced this issue Feb 5, 2025
Fixes block#1079

Update `response_to_message` and `create_request_based_on_model` functions to handle empty arguments for tool calls.

* **`crates/goose/src/providers/formats/openai.rs`**:
  - Update the `response_to_message` function to handle empty arguments for tool calls.
  - Add a check for empty arguments and set them to an empty JSON object if they are empty.

* **`crates/goose/src/providers/openrouter.rs`**:
  - Update the `create_request_based_on_model` function to ensure tool call arguments are properly formatted.
  - Add a check to format tool call arguments as an empty JSON object if they are empty.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/block/goose/issues/1079?shareId=XXXX-XXXX-XXXX-XXXX).
@dailydaniel
Copy link
Author

@salman1993

Thank you very much! I will definitely add instructions

jasonkneen added a commit to jasonkneen/goose that referenced this issue Feb 5, 2025
Fixes block#1079

Update `response_to_message` and `create_request_based_on_model` functions to handle empty arguments for tool calls.

* **`crates/goose/src/providers/formats/openai.rs`**:
  - Update the `response_to_message` function to handle empty arguments for tool calls.
  - Add a check for empty arguments and set them to an empty JSON object if they are empty.

* **`crates/goose/src/providers/openrouter.rs`**:
  - Update the `create_request_based_on_model` function to ensure tool call arguments are properly formatted.
  - Add a check to format tool call arguments as an empty JSON object if they are empty.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/block/goose/issues/1079?shareId=XXXX-XXXX-XXXX-XXXX).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
2 participants