Skip to content

Local agent: 'Cannot start a runtime from within a runtime' panic on shutdown/hot-reload #1082

Closed

Description

@malibio

Summary

The app panics on shutdown and hot-reload with a Tokio runtime conflict during inference engine teardown, followed by a Metal/llama.cpp assertion failure.

Observed Error

thread 'main' panicked at packages/desktop-app/src-tauri/src/commands/local_agent.rs:222:12:
Cannot start a runtime from within a runtime.
...
GGML_ASSERT([rsets->data count] == 0) failed

Reproduction

  1. Launch the app with local Ollama agent enabled
  2. Close the app OR trigger a hot-reload (Tauri dev mode)
  3. Panic occurs during inference engine teardown

Root Cause

The panic originates at packages/desktop-app/src-tauri/src/commands/local_agent.rs:222 — the inference engine teardown is attempting to start a new Tokio runtime from within an already-running async context. This triggers the Cannot start a runtime from within a runtime panic.

The secondary GGML_ASSERT([rsets->data count] == 0) failure is a Metal GPU residency set leak from llama.cpp — likely caused by the Tokio panic aborting cleanup before GPU resources are released.

Impact

  • Non-blocking: the app has already closed/reloaded by the time this fires
  • No data loss
  • Pre-existing: not introduced by recent changes

Acceptance Criteria

  • Inference engine teardown does not panic on app close
  • Inference engine teardown does not panic on hot-reload
  • Metal GPU residency set is properly released on teardown
  • No GGML_ASSERT failures in llama.cpp during shutdown

Activity

  1. added
    bug
    on Apr 8, 2026
  2. malibio commented on Apr 11, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 3918 passed (128 test files), 0 failed

  3. self-assigned this
    on Apr 11, 2026
  4. added a commit that references this issue on Apr 11, 2026
    e3cb87a
  5. malibio commented on Apr 11, 2026

    @malibio
    CollaboratorAuthor

    PR created: #1098. All acceptance criteria met. Code review passed clean (APPROVE). Two cosmetic suggestions noted, both non-blocking.

  6. added a commit that references this issue on Apr 11, 2026
    cca90be
  7. malibio commented on Apr 11, 2026

    @malibio
    CollaboratorAuthor

    PR #1098 merged. All acceptance criteria met. Review passed clean.

  8. added 2 commits that reference this issue on Apr 14, 2026
  9. malibio commented on Apr 17, 2026

    @malibio
    CollaboratorAuthor

    Follow-up PR #1103 merged. All retroactive review findings from PR #1098 addressed and review passed clean.

  10. added a commit that references this issue on Apr 17, 2026
  11. added 3 commits that reference this issue on Jun 22, 2026
    7fef4cf
    663dfeb
    33a1b49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-integrationbackendbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions