gptscript-ai / gptscript

Build AI assistants that interact with your systems
https://gptscript.ai
Apache License 2.0
2.8k stars 246 forks source link

"Address already in use" error seen during tool call resulting in "failed to find tool id for tool call in tool_call result" error. #257

Open sangee2004 opened 3 months ago

sangee2004 commented 3 months ago

gptscript version v0.0.0-dev-bc620f0e-dirty

Steps to reproduce the problem

  1. Execute the following script (example/bob.gpt using model gemini-1.0-pro from github.com/gptscript-ai/gemini-vertexai-provider) multiple times.
tools: bob
model: gemini-1.0-pro from github.com/gptscript-ai/gemini-vertexai-provider

Ask Bob how he is doing and let me know exactly what he said.

---
name: bob
model: gemini-1.0-pro from github.com/gptscript-ai/gemini-vertexai-provider
description: I'm Bob, a friendly guy.
args: question: The question to ask Bob.

When asked how I am doing, respond with "Thanks for asking "${question}", I'm doing great fellow friendly AI tool!"
  1. gptscript execution succeeds few times. But it also fails many times with failed to find tool id for tool call in tool_call result errors.

Debug calls show errors relating to

INFO:     Will watch for changes in these directories: ['/Users/sangeethahariharan/gptscript']
ERROR:    [Errno 48] Address already in use
FATA[0000] failed running daemon: exit status 1          logger=/Users/sangeethahariharan/gptscript/main.go
{
  "level": "error",
  "logger": "/pkg/engine",
  "msg": "daemon exited tool [gemini vertexai provider] [gptscript sys.daemon /usr/bin/env python3 /Users/sangeethahariharan/Library/Caches/gptscript/repos/37ea5a9ae4e8cdb2f666c352323dedb42d39e200/python3.12/main.py]: exit status 1",

Full debug logs when this issue was encountered:

gptscript --disable-cache --debug  bob-gemini.gpt
{
  "level": "debug",
  "logger": "/pkg/loader",
  "msg": "opened bob-gemini.gpt",
  "time": "2024-04-16T17:11:10-07:00"
}
{
  "input": "",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "Run started",
  "program": {
    "name": "bob-gemini.gpt",
    "entryToolId": "bob-gemini.gpt:1",
    "toolSet": {
      "bob-gemini.gpt:1": {
        "modelName": "gemini-1.0-pro from github.com/gptscript-ai/gemini-vertexai-provider",
        "internalPrompt": null,
        "tools": [
          "bob"
        ],
        "instructions": "Ask Bob how he is doing and let me know exactly what he said.",
        "id": "bob-gemini.gpt:1",
        "toolMapping": {
          "bob": "bob-gemini.gpt:7"
        },
        "localTools": {
          "": "bob-gemini.gpt:1",
          "bob": "bob-gemini.gpt:7"
        },
        "source": {
          "location": "bob-gemini.gpt",
          "lineNo": 1
        },
        "workingDir": "."
      },
      "bob-gemini.gpt:7": {
        "name": "bob",
        "description": "I'm Bob, a friendly guy.",
        "modelName": "gemini-1.0-pro from github.com/gptscript-ai/gemini-vertexai-provider",
        "internalPrompt": null,
        "arguments": {
          "properties": {
            "question": {
              "description": "The question to ask Bob.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "instructions": "When asked how I am doing, respond with \"Thanks for asking \"${question}\", I'm doing great fellow friendly AI tool!\"",
        "id": "bob-gemini.gpt:7",
        "localTools": {
          "": "bob-gemini.gpt:1",
          "bob": "bob-gemini.gpt:7"
        },
        "source": {
          "location": "bob-gemini.gpt",
          "lineNo": 7
        },
        "workingDir": "."
      }
    }
  },
  "runID": "1",
  "time": "2024-04-16T17:11:10-07:00"
}
{
  "id": "1",
  "input": "",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "started  [main]",
  "parentID": "",
  "time": "2024-04-16T17:11:10-07:00",
  "toolID": "bob-gemini.gpt:1"
}
{
  "level": "debug",
  "logger": "/pkg/loader",
  "msg": "opened https://raw.githubusercontent.com/gptscript-ai/gemini-vertexai-provider/37ea5a9ae4e8cdb2f666c352323dedb42d39e200/tool.gpt",
  "time": "2024-04-16T17:11:11-07:00"
}
{
  "input": "",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "Run started",
  "program": {
    "name": "github.com/gptscript-ai/gemini-vertexai-provider",
    "entryToolId": "https://raw.githubusercontent.com/gptscript-ai/gemini-vertexai-provider/37ea5a9ae4e8cdb2f666c352323dedb42d39e200/tool.gpt:1",
    "toolSet": {
      "https://raw.githubusercontent.com/gptscript-ai/gemini-vertexai-provider/37ea5a9ae4e8cdb2f666c352323dedb42d39e200/tool.gpt:1": {
        "name": "gemini vertexai provider",
        "description": "Model provider for Google Gemini on VertexAI",
        "modelName": "gpt-4-turbo-preview",
        "modelProvider": true,
        "internalPrompt": null,
        "instructions": "#!sys.daemon /usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py",
        "id": "https://raw.githubusercontent.com/gptscript-ai/gemini-vertexai-provider/37ea5a9ae4e8cdb2f666c352323dedb42d39e200/tool.gpt:1",
        "localTools": {
          "gemini vertexai provider": "https://raw.githubusercontent.com/gptscript-ai/gemini-vertexai-provider/37ea5a9ae4e8cdb2f666c352323dedb42d39e200/tool.gpt:1"
        },
        "source": {
          "location": "https://raw.githubusercontent.com/gptscript-ai/gemini-vertexai-provider/37ea5a9ae4e8cdb2f666c352323dedb42d39e200/tool.gpt",
          "lineNo": 1,
          "repo": {
            "VCS": "git",
            "Root": "https://github.com/gptscript-ai/gemini-vertexai-provider.git",
            "Path": ".",
            "Name": "tool.gpt",
            "Revision": "37ea5a9ae4e8cdb2f666c352323dedb42d39e200"
          }
        },
        "workingDir": "https://raw.githubusercontent.com/gptscript-ai/gemini-vertexai-provider/37ea5a9ae4e8cdb2f666c352323dedb42d39e200"
      }
    }
  },
  "runID": "2",
  "time": "2024-04-16T17:11:11-07:00"
}
{
  "id": "2",
  "input": "",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "started  [main]",
  "parentID": "",
  "time": "2024-04-16T17:11:11-07:00",
  "toolID": "https://raw.githubusercontent.com/gptscript-ai/gemini-vertexai-provider/37ea5a9ae4e8cdb2f666c352323dedb42d39e200/tool.gpt:1"
}
{
  "level": "debug",
  "logger": "/pkg/repos",
  "msg": "Runtime python3.12 supports [/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py]",
  "time": "2024-04-16T17:11:11-07:00"
}
{
  "level": "debug",
  "logger": "/pkg/env",
  "msg": "Looking for /usr/bin/env in /Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/d1f13a58a16195d19baa0f8d4910e8f9b31f07d1ddefb62de7021b1867ff4646/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/usr/local/go/bin:/Users/sangeethahariharan/.cargo/bin",
  "time": "2024-04-16T17:11:11-07:00"
}
{
  "level": "info",
  "logger": "/pkg/engine",
  "msg": "launched [gemini vertexai provider][https://raw.githubusercontent.com/gptscript-ai/gemini-vertexai-provider/37ea5a9ae4e8cdb2f666c352323dedb42d39e200/tool.gpt:1] port [10244] [gptscript sys.daemon /usr/bin/env python3 /Users/sangeethahariharan/Library/Caches/gptscript/repos/37ea5a9ae4e8cdb2f666c352323dedb42d39e200/python3.12/main.py]",
  "time": "2024-04-16T17:11:11-07:00"
}
{
  "id": "2",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "ended    [main]",
  "output": "http://127.0.0.1:10244",
  "parentID": "",
  "time": "2024-04-16T17:11:11-07:00",
  "toolID": "https://raw.githubusercontent.com/gptscript-ai/gemini-vertexai-provider/37ea5a9ae4e8cdb2f666c352323dedb42d39e200/tool.gpt:1"
}
{
  "err": null,
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "Run stopped",
  "output": "http://127.0.0.1:10244",
  "runID": "2",
  "time": "2024-04-16T17:11:11-07:00"
}
{
  "id": "1",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "sent     [main]",
  "parentID": "",
  "time": "2024-04-16T17:11:11-07:00",
  "toolID": "bob-gemini.gpt:1"
}
{
  "completionID": "1",
  "id": "1",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "messages",
  "parentID": "",
  "request": {
    "model": "gemini-1.0-pro",
    "messages": [
      {
        "role": "system",
        "content": "\nYou are task oriented system.\nYou receive input from a user, process the input from the given instructions, and then output the result.\nYour objective is to provide consistent and correct results.\nYou do not need to explain the steps taken, only provide the result to the given instructions.\nYou are referred to as a tool.\nYou don't move to the next step until you have a result.\n"
      },
      {
        "role": "user",
        "content": "Ask Bob how he is doing and let me know exactly what he said."
      }
    ],
    "temperature": 0,
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "bob",
          "description": "I'm Bob, a friendly guy.",
          "parameters": {
            "properties": {
              "question": {
                "description": "The question to ask Bob.",
                "type": "string"
              }
            },
            "type": "object"
          }
        }
      }
    ]
  },
  "time": "2024-04-16T17:11:11-07:00",
  "toolID": "bob-gemini.gpt:1"
}
         content  [1] content | Waiting for model response.../Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/d1f13a58a16195d19baa0f8d4910e8f9b31f07d1ddefb62de7021b1867ff4646/lib/python3.12/site-packages/google/auth/_default.py:76: UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK without a quota project. You might receive a "quota exceeded" or "API not enabled" error. See the following page for troubleshooting: https://cloud.google.com/docs/authentication/adc-troubleshooting/user-creds. 
  warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)
INFO:     Will watch for changes in these directories: ['/Users/sangeethahariharan/gptscript']
ERROR:    [Errno 48] Address already in use
FATA[0000] failed running daemon: exit status 1          logger=/Users/sangeethahariharan/gptscript/main.go
{
  "level": "error",
  "logger": "/pkg/engine",
  "msg": "daemon exited tool [gemini vertexai provider] [gptscript sys.daemon /usr/bin/env python3 /Users/sangeethahariharan/Library/Caches/gptscript/repos/37ea5a9ae4e8cdb2f666c352323dedb42d39e200/python3.12/main.py]: exit status 1",
  "time": "2024-04-16T17:11:11-07:00"
}

         content  [1] content | tool call call -> {"extension": "default_api", "question": "How are you doing?", "function": "bob"}
{
  "cached": false,
  "completionID": "1",
  "id": "1",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "messages",
  "parentID": "",
  "response": {
    "role": "assistant",
    "content": [
      {
        "toolCall": {
          "index": 0,
          "id": "call_0",
          "function": {
            "name": "call",
            "arguments": "{\"extension\": \"default_api\", \"question\": \"How are you doing?\", \"function\": \"bob\"}"
          }
        }
      }
    ]
  },
  "time": "2024-04-16T17:11:12-07:00",
  "toolID": "bob-gemini.gpt:1"
}
{
  "err": "failed to find tool id for tool call in tool_call result",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "Run stopped",
  "output": "",
  "runID": "1",
  "time": "2024-04-16T17:11:12-07:00"
}
{
  "level": "debug",
  "logger": "/pkg/engine",
  "msg": "daemon failed to kill tool [gemini vertexai provider] process: os: process already finished",
  "time": "2024-04-16T17:11:12-07:00"
}
2024/04/16 17:11:12 failed to find tool id for tool call in tool_call result
sangee2004 commented 2 months ago

I see the same "Address already in use" error when testing with Anthropic provider as well. But in this case , the script is able to provide the output as expected and still shows "daemon failed to kill tool [anthropic model provider] process: os: process already finished" error in debug logs:

gptscript --default-model='claude-3-haiku-20240307 from github.com/gptscript-ai/anthropic-provider' examples/bob.gpt

gptscript --default-model='claude-3-haiku-20240307 from github.com/gptscript-ai/anthropic-provider' examples/bob.gpt
{
  "level": "info",
  "logger": "/pkg/cli",
  "msg": "WARNING: Changing the default model can have unknown behavior for existing tools. Use the model field per tool instead.",
  "time": "2024-04-18T14:36:37-07:00"
}
{
  "level": "debug",
  "logger": "/pkg/loader",
  "msg": "opened examples/bob.gpt",
  "time": "2024-04-18T14:36:37-07:00"
}
{
  "input": "",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "Run started",
  "program": {
    "name": "examples/bob.gpt",
    "entryToolId": "examples/bob.gpt:1",
    "toolSet": {
      "examples/bob.gpt:1": {
        "modelName": "claude-3-haiku-20240307 from github.com/gptscript-ai/anthropic-provider",
        "internalPrompt": null,
        "tools": [
          "bob"
        ],
        "instructions": "Ask Bob how he is doing and let me know exactly what he said.",
        "id": "examples/bob.gpt:1",
        "toolMapping": {
          "bob": "examples/bob.gpt:6"
        },
        "localTools": {
          "": "examples/bob.gpt:1",
          "bob": "examples/bob.gpt:6"
        },
        "source": {
          "location": "examples/bob.gpt",
          "lineNo": 1
        },
        "workingDir": "examples"
      },
      "examples/bob.gpt:6": {
        "name": "bob",
        "description": "I'm Bob, a friendly guy",
        "modelName": "claude-3-haiku-20240307 from github.com/gptscript-ai/anthropic-provider",
        "internalPrompt": null,
        "arguments": {
          "properties": {
            "question": {
              "description": "The question to ask Bob.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "instructions": "When asked how I am doing, respond with \"Thanks for asking \"${question}\", I'm doing great fellow friendly AI tool!\"",
        "id": "examples/bob.gpt:6",
        "localTools": {
          "": "examples/bob.gpt:1",
          "bob": "examples/bob.gpt:6"
        },
        "source": {
          "location": "examples/bob.gpt",
          "lineNo": 6
        },
        "workingDir": "examples"
      }
    }
  },
  "runID": "1",
  "time": "2024-04-18T14:36:37-07:00"
}
{
  "id": "1",
  "input": "",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "started  [main]",
  "parentID": "",
  "time": "2024-04-18T14:36:37-07:00",
  "toolID": "examples/bob.gpt:1"
}
{
  "level": "debug",
  "logger": "/pkg/loader",
  "msg": "opened https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/tool.gpt",
  "time": "2024-04-18T14:36:37-07:00"
}
{
  "level": "debug",
  "logger": "/pkg/loader",
  "msg": "opened https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/credential/tool.gpt",
  "time": "2024-04-18T14:36:37-07:00"
}
{
  "input": "",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "Run started",
  "program": {
    "name": "github.com/gptscript-ai/anthropic-provider",
    "entryToolId": "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/tool.gpt:1",
    "toolSet": {
      "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/credential/tool.gpt:1": {
        "name": "anthropic-credential",
        "modelName": "claude-3-haiku-20240307 from github.com/gptscript-ai/anthropic-provider",
        "internalPrompt": null,
        "instructions": "#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/credential.py",
        "id": "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/credential/tool.gpt:1",
        "localTools": {
          "anthropic-credential": "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/credential/tool.gpt:1"
        },
        "source": {
          "location": "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/credential/tool.gpt",
          "lineNo": 1,
          "repo": {
            "VCS": "git",
            "Root": "https://github.com/gptscript-ai/anthropic-provider.git",
            "Path": "credential",
            "Name": "tool.gpt",
            "Revision": "12bffddab9f9bf4d517b960c2b1bce395e2a3251"
          }
        },
        "workingDir": "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/credential"
      },
      "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/tool.gpt:1": {
        "name": "anthropic model provider",
        "description": "Model provider for Anthropic hosted models and Claude3 on AWS",
        "modelName": "claude-3-haiku-20240307 from github.com/gptscript-ai/anthropic-provider",
        "modelProvider": true,
        "internalPrompt": null,
        "credentials": [
          "github.com/gptscript-ai/anthropic-provider/credential"
        ],
        "instructions": "#!sys.daemon /usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py",
        "id": "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/tool.gpt:1",
        "toolMapping": {
          "github.com/gptscript-ai/anthropic-provider/credential": "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/credential/tool.gpt:1"
        },
        "localTools": {
          "anthropic model provider": "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/tool.gpt:1"
        },
        "source": {
          "location": "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/tool.gpt",
          "lineNo": 1,
          "repo": {
            "VCS": "git",
            "Root": "https://github.com/gptscript-ai/anthropic-provider.git",
            "Path": ".",
            "Name": "tool.gpt",
            "Revision": "12bffddab9f9bf4d517b960c2b1bce395e2a3251"
          }
        },
        "workingDir": "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251"
      }
    }
  },
  "runID": "2",
  "time": "2024-04-18T14:36:37-07:00"
}
{
  "id": "2",
  "input": "",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "started  [main]",
  "parentID": "",
  "time": "2024-04-18T14:36:37-07:00",
  "toolID": "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/tool.gpt:1"
}
{
  "level": "debug",
  "logger": "/pkg/repos",
  "msg": "Runtime python3.12 supports [/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py]",
  "time": "2024-04-18T14:36:37-07:00"
}
{
  "level": "debug",
  "logger": "/pkg/env",
  "msg": "Looking for /usr/bin/env in /Users/sangeethahariharan/Library/Caches/gptscript/repos/runtimes/venv/269cbc86444564827b75e9d07d4c546337aac2bc06337eac53319e798eb526d5/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/usr/local/go/bin:/Users/sangeethahariharan/.cargo/bin",
  "time": "2024-04-18T14:36:37-07:00"
}
{
  "level": "info",
  "logger": "/pkg/engine",
  "msg": "launched [anthropic model provider][https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/tool.gpt:1] port [10793] [gptscript sys.daemon /usr/bin/env python3 /Users/sangeethahariharan/Library/Caches/gptscript/repos/12bffddab9f9bf4d517b960c2b1bce395e2a3251/python3.12/main.py]",
  "time": "2024-04-18T14:36:37-07:00"
}
{
  "id": "2",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "ended    [main]",
  "output": "http://127.0.0.1:10793",
  "parentID": "",
  "time": "2024-04-18T14:36:37-07:00",
  "toolID": "https://raw.githubusercontent.com/gptscript-ai/anthropic-provider/12bffddab9f9bf4d517b960c2b1bce395e2a3251/tool.gpt:1"
}
{
  "err": null,
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "Run stopped",
  "output": "http://127.0.0.1:10793",
  "runID": "2",
  "time": "2024-04-18T14:36:37-07:00"
}
{
  "id": "1",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "sent     [main]",
  "parentID": "",
  "time": "2024-04-18T14:36:37-07:00",
  "toolID": "examples/bob.gpt:1"
}
{
  "completionID": "1",
  "id": "1",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "messages",
  "parentID": "",
  "request": {
    "model": "claude-3-haiku-20240307",
    "messages": [
      {
        "role": "system",
        "content": "\nYou are task oriented system.\nYou receive input from a user, process the input from the given instructions, and then output the result.\nYour objective is to provide consistent and correct results.\nYou do not need to explain the steps taken, only provide the result to the given instructions.\nYou are referred to as a tool.\nYou don't move to the next step until you have a result.\n"
      },
      {
        "role": "user",
        "content": "Ask Bob how he is doing and let me know exactly what he said."
      }
    ],
    "temperature": 0,
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "bob",
          "description": "I'm Bob, a friendly guy",
          "parameters": {
            "properties": {
              "question": {
                "description": "The question to ask Bob.",
                "type": "string"
              }
            },
            "type": "object"
          }
        }
      }
    ]
  },
  "time": "2024-04-18T14:36:37-07:00",
  "toolID": "examples/bob.gpt:1"
}
{
  "cached": true,
  "completionID": "1",
  "id": "1",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "messages",
  "parentID": "",
  "response": {
    "role": "assistant",
    "content": [
      {
        "toolCall": {
          "index": 0,
          "id": "bob",
          "function": {
            "name": "bob",
            "arguments": "{\"question\": \"How are you doing?\"}"
          }
        }
      }
    ]
  },
  "time": "2024-04-18T14:36:37-07:00",
  "toolID": "examples/bob.gpt:1"
}
{
  "id": "bob",
  "input": "{\"question\": \"How are you doing?\"}",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "started  [bob(3)]",
  "parentID": "1",
  "time": "2024-04-18T14:36:37-07:00",
  "toolID": "examples/bob.gpt:6"
}
{
  "id": "bob",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "sent     [bob(3)]",
  "parentID": "1",
  "time": "2024-04-18T14:36:38-07:00",
  "toolID": "examples/bob.gpt:6"
}
{
  "completionID": "2",
  "id": "bob",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "messages",
  "parentID": "1",
  "request": {
    "model": "claude-3-haiku-20240307",
    "messages": [
      {
        "role": "system",
        "content": "\nYou are task oriented system.\nYou receive input from a user, process the input from the given instructions, and then output the result.\nYour objective is to provide consistent and correct results.\nYou do not need to explain the steps taken, only provide the result to the given instructions.\nYou are referred to as a tool.\nYou don't move to the next step until you have a result.\n\nWhen asked how I am doing, respond with \"Thanks for asking \"${question}\", I'm doing great fellow friendly AI tool!\""
      },
      {
        "role": "user",
        "content": "{\"question\": \"How are you doing?\"}"
      }
    ],
    "temperature": 0
  },
  "time": "2024-04-18T14:36:38-07:00",
  "toolID": "examples/bob.gpt:6"
}
{
  "cached": true,
  "completionID": "2",
  "id": "bob",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "messages",
  "parentID": "1",
  "response": {
    "content": [
      {
        "text": "Thanks for asking \"How are you doing?\", I'm doing great fellow friendly AI tool!"
      }
    ]
  },
  "time": "2024-04-18T14:36:38-07:00",
  "toolID": "examples/bob.gpt:6"
}
{
  "id": "bob",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "ended    [bob(3)]",
  "output": "Thanks for asking \"How are you doing?\", I'm doing great fellow friendly AI tool!",
  "parentID": "1",
  "time": "2024-04-18T14:36:38-07:00",
  "toolID": "examples/bob.gpt:6"
}
{
  "id": "1",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "continue [main]",
  "parentID": "",
  "time": "2024-04-18T14:36:38-07:00",
  "toolID": "examples/bob.gpt:1",
  "toolResults": 1
}
INFO:     Will watch for changes in these directories: ['/Users/sangeethahariharan/gptscript']
ERROR:    [Errno 48] Address already in use
FATA[0000] failed running daemon: exit status 1          logger=/Users/sangeethahariharan/gptscript/main.go
{
  "level": "error",
  "logger": "/pkg/engine",
  "msg": "daemon exited tool [anthropic model provider] [gptscript sys.daemon /usr/bin/env python3 /Users/sangeethahariharan/Library/Caches/gptscript/repos/12bffddab9f9bf4d517b960c2b1bce395e2a3251/python3.12/main.py]: exit status 1",
  "time": "2024-04-18T14:36:38-07:00"
}
{
  "id": "1",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "sent     [main]",
  "parentID": "",
  "time": "2024-04-18T14:36:38-07:00",
  "toolID": "examples/bob.gpt:1"
}
{
  "completionID": "3",
  "id": "1",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "messages",
  "parentID": "",
  "request": {
    "model": "claude-3-haiku-20240307",
    "messages": [
      {
        "role": "system",
        "content": "\nYou are task oriented system.\nYou receive input from a user, process the input from the given instructions, and then output the result.\nYour objective is to provide consistent and correct results.\nYou do not need to explain the steps taken, only provide the result to the given instructions.\nYou are referred to as a tool.\nYou don't move to the next step until you have a result.\n"
      },
      {
        "role": "user",
        "content": "Ask Bob how he is doing and let me know exactly what he said."
      },
      {
        "role": "assistant",
        "content": "",
        "tool_calls": [
          {
            "id": "bob",
            "type": "function",
            "function": {
              "name": "bob",
              "arguments": "{\"question\": \"How are you doing?\"}"
            }
          }
        ]
      },
      {
        "role": "tool",
        "content": "Thanks for asking \"How are you doing?\", I'm doing great fellow friendly AI tool!",
        "name": "bob",
        "tool_call_id": "bob"
      }
    ],
    "temperature": 0,
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "bob",
          "description": "I'm Bob, a friendly guy",
          "parameters": {
            "properties": {
              "question": {
                "description": "The question to ask Bob.",
                "type": "string"
              }
            },
            "type": "object"
          }
        }
      }
    ]
  },
  "time": "2024-04-18T14:36:38-07:00",
  "toolID": "examples/bob.gpt:1"
}
{
  "cached": true,
  "completionID": "3",
  "id": "1",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "messages",
  "parentID": "",
  "response": {
    "content": [
      {
        "text": "Bob said \"Thanks for asking \"How are you doing?\", I'm doing great fellow friendly AI tool!\""
      }
    ]
  },
  "time": "2024-04-18T14:36:38-07:00",
  "toolID": "examples/bob.gpt:1"
}
{
  "id": "1",
  "level": "info",
  "logger": "/pkg/monitor",
  "msg": "ended    [main]",
  "output": "Bob said \"Thanks for asking \"How are you doing?\", I'm doing great fellow friendly AI tool!\"",
  "parentID": "",
  "time": "2024-04-18T14:36:38-07:00",
  "toolID": "examples/bob.gpt:1"
}
{
  "err": null,
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "Run stopped",
  "output": "Bob said \"Thanks for asking \"How are you doing?\", I'm doing great fellow friendly AI tool!\"",
  "runID": "1",
  "time": "2024-04-18T14:36:38-07:00"
}

OUTPUT:

Bob said "Thanks for asking "How are you doing?", I'm doing great fellow friendly AI tool!"
{
  "level": "debug",
  "logger": "/pkg/engine",
  "msg": "daemon failed to kill tool [anthropic model provider] process: os: process already finished",
  "time": "2024-04-18T14:36:38-07:00"
}
sangee2004 commented 2 months ago

Tested with gptscript version v0.0.0-dev-ec6d147b-dirty

I am still able to reproduce the "Address already in use" error when testing with gemini-vertexai provider. I also see an error about OPEN_API_KEY not set in debug logs

{
  "level": "info",
  "logger": "/pkg/engine",
  "msg": "launched [Gemini VertexAI Provider][https://raw.githubusercontent.com/gptscript-ai/gemini-vertexai-provider/9e194336608df72baf390615c2cd9012010335e0/tool.gpt:Gemini VertexAI Provider] port [10829] [gptscript sys.daemon /usr/bin/env python3 /Users/sangeethahariharan/Library/Caches/gptscript/repos/9e194336608df72baf390615c2cd9012010335e0/python3.12/main.py]",
  "time": "2024-05-17T10:23:48-07:00"
}
INFO:     Will watch for changes in these directories: ['/Users/sangeethahariharan/gptscript']
ERROR:    [Errno 48] Address already in use
{
  "level": "debug",
  "logger": "/Users/sangeethahariharan/gptscript/main.go",
  "msg": "failed running daemon: exit status 1",
  "time": "2024-05-17T10:23:49-07:00"
}
{
  "err": "daemon failed to start: context canceled",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "Run stopped",
  "output": "",
  "runID": "1715966630",
  "time": "2024-05-17T10:23:49-07:00"
}
{
  "err": "OPENAI_API_KEY is not set. Please set the OPENAI_API_KEY environment variable\ndaemon failed to start: context canceled",
  "level": "debug",
  "logger": "/pkg/monitor",
  "msg": "Run stopped",
  "output": "",
  "runID": "1715966628",
  "time": "2024-05-17T10:23:49-07:00"
}
drpebcak commented 1 day ago

This should be resolved now with the latest versions of the providers.