Skip to content

Panic trying using gemini models #35

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

Closed
shreyassanthu77 opened this issue Apr 21, 2025 · 10 comments
Closed

Panic trying using gemini models #35

shreyassanthu77 opened this issue Apr 21, 2025 · 10 comments

Comments

@shreyassanthu77
Copy link
Contributor

I have no idea what is going on haven't checked the code (yet) but it seems to be an out of bounds exception? (probably a different thing going on under the hood)

panic: runtime error: slice bounds out of range [98:95]                                 No diagnostics  Gemini 2.5 Pro 

                                                       goroutine 227 [running]:
                                                                               github.com/kujtimiihoxha/opencode/internal/llm/provider.(*geminiClient).stream.func1()
                                                /home/shreyas/code/gh/opencode/opencode/internal/llm/provider/gemini.go:335 +0xedc
           created by github.com/kujtimiihoxha/opencode/internal/llm/provider.(*geminiClient).stream in goroutine 119
                                                                                                                      /home/shreyas/code/gh/opencode/opencode/internal/llm/provider/gemini.go:274 +0x2bf

here's my config

{
  "$schema": "...main/opencode-schema.json",
  "data": {
    "directory": ".opencode"
  },
  "providers": {
    "gemini": {
      "disabled": false
    }
  },
  "agents": {
    "title": {
      "model": "gemini-2.0-flash",
      "maxTokens": 100
    },
    "task": {
      "model": "gemini-2.5-flash"
    },
    "coder": {
      "model": "gemini-2.5"
    }
  },
  "lsp": {
    "zig": {
      "disabled": false,
      "command": "zls",
      "args": []
    }
  }
}

sidenote: should also handle panics gracefully, exit raw mode / alternate screen (or deinit charm stuff if you're using those ig) and then print the error message.

@shreyassanthu77
Copy link
Contributor Author

shreyassanthu77 commented Apr 21, 2025

update: setting max tokens to 50000 fixed the problem

edit: it infact did not work, it's still crashing

@shreyassanthu77
Copy link
Contributor Author

another update: model gemini-2.5 doesn't seem to support tool calling, when I try to use it I get tool XYZ not found errors in the logs

but flash does seem to work 🤷‍♂️

didn't really look at the gemini docs to confirm this, too late for me rn will check this after i wake up

@shreyassanthu77
Copy link
Contributor Author

even more another update: gemini 2.5 flash doesn't seem to work with tool calling either

@jorgeavaldez
Copy link

i'm experiencing the same issue

@kujtimiihoxha
Copy link
Collaborator

Yeah have not tested the gemini provider enough I will need to do a thorough review of it and fix this

@mmkal
Copy link

mmkal commented Apr 25, 2025

I got something similar with openai (gpt 4.1)

Caught panic:

runtime error: slice bounds out of range [4:3]

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
        /home/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/debug/stack.go:26 +0x64
runtime/debug.PrintStack()
        /home/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/debug/stack.go:18 +0x1c
github.com/charmbracelet/bubbletea.(*Program).recoverFromPanic(0x14002738b40)
        /home/runner/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:758 +0x80
panic({0x106228980?, 0x1400292cca8?})
        /home/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:792 +0x124
github.com/charmbracelet/bubbles/viewport.Model.visibleLines(...)
        /home/runner/go/pkg/mod/github.com/charmbracelet/[email protected]/viewport/viewport.go:123
github.com/charmbracelet/bubbles/viewport.(*Model).GotoBottom(0x14001633000?)
        /home/runner/go/pkg/mod/github.com/charmbracelet/[email protected]/viewport/viewport.go:237 +0x15c
github.com/charmbracelet/bubbles/viewport.(*Model).SetContent(0x140034e8a98, {0x14001633000?, 0x0?})
        /home/runner/go/pkg/mod/github.com/charmbracelet/[email protected]/viewport/viewport.go:107 +0xa8
github.com/opencode-ai/opencode/internal/tui/components/dialog.(*permissionDialogCmp).renderBashContent(0x140034e8a08)
        /home/runner/work/opencode/opencode/internal/tui/components/dialog/permission.go:254 +0x188
github.com/opencode-ai/opencode/internal/tui/components/dialog.(*permissionDialogCmp).render(0x140034e8a08)
        /home/runner/work/opencode/opencode/internal/tui/components/dialog/permission.go:365 +0x2a8
github.com/opencode-ai/opencode/internal/tui/components/dialog.(*permissionDialogCmp).View(0x0?)
        /home/runner/work/opencode/opencode/internal/tui/components/dialog/permission.go:401 +0x1c
github.com/opencode-ai/opencode/internal/tui.appModel.View({0x84, 0x1c, {0x10581df30, 0x4}, {0x0, 0x0}, 0x14000ac9e00, 0x14000ac9d10, {0x12ec28f38, 0x14000c080a0}, ...})
        /home/runner/work/opencode/opencode/internal/tui/tui.go:461 +0xe4
github.com/charmbracelet/bubbletea.(*Program).eventLoop(0x14002738b40, {0x1063572a8?, 0x14003182f08?}, 0x140005a02a0)
        /home/runner/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:510 +0x680
github.com/charmbracelet/bubbletea.(*Program).Run(0x14002738b40)
        /home/runner/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:647 +0x8ec
github.com/opencode-ai/opencode/cmd.init.func1(0x107144640, {0x10581db2c?, 0x4?, 0x10581db30?})
        /home/runner/work/opencode/opencode/cmd/root.go:136 +0x388
github.com/spf13/cobra.(*Command).execute(0x107144640, {0x14000122110, 0x1, 0x1})
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1015 +0x828
github.com/spf13/cobra.(*Command).ExecuteC(0x107144640)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1148 +0x350
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1071
github.com/opencode-ai/opencode/cmd.Execute()
        /home/runner/work/opencode/opencode/cmd/root.go:247 +0x24
main.main()
        /home/runner/work/opencode/opencode/main.go:13 +0x4c

@shreyassanthu77
Copy link
Contributor Author

That looks like it's a different issue. still out of bounds error but the stack trace feels weird

@jbutlerdev
Copy link

Also running into similar issues using gemini-2.5

@isaac-scarrott
Copy link
Contributor

Have tried adding an OpenRouter provider which will allow calls to Gemini (with tools) #92

Not working consistently on larger repo's (maybe due to a greater tokens being used? need to see if it's inconsistent for other providers/models), but got some good results with it in the OpenCode repo

@kujtimiihoxha
Copy link
Collaborator

Gemini should be fixed here #96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants