spacedriveapp / spacedriveapp/spacebot

Channel LLM call fails with "Already borrowed" when messages arrive during active branch/worker streams

Open
#469 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.4k
Forks
367
PR merge metrics
No merged PRs in 30d

Description

Spacebot had about 5-6 tasks running simultaneously when these errors occured. I had the model stop them and then had the model run a two simultaneously and didn't get the error. I had Claude dig into the errors deeper and this is what Claude formulated.

When a user sends a message to the channel while branches or workers are actively streaming LLM
responses, the channel's own LLM call fails with:

CompletionError: ProviderError: OpenAI-compatible streaming error: Already borrowed

Environment

  • Provider: OpenAI-compatible (Chutes AI, https://llm.chutes.ai)
  • Channel model: Qwen/Qwen3-235B-A22B-Instruct-2507-TEE
  • Worker model: zai-org/GLM-5-Turbo
  • Messaging: Telegram

ERROR handle_message: spacebot::agent::channel: message=channel LLM call failed
channel_id=
error=CompletionError: ProviderError: OpenAI-compatible streaming error: Already borrowed

Notes

The error does not originate in spacebot's own code — it appears to come from a shared mutable reference
(RefCell) in the OpenAI-compatible streaming client path, likely in rig or the HTTP streaming layer.
Concurrent streaming requests seem to share state that should be isolated per-call.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with multiple branch or worker streams active while a channel message arrives. Inspect the channel LLM call and the OpenAI-compatible streaming client path, particularly shared mutable state in the streaming layer. Done means concurrent streams no longer produce an “Already borrowed” error and the behavior is covered by an appropriate regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
ai, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.