Skip to content

SDK 1.0.4 default session persistence can fail with SQLite "database is locked" in one-shot hosted sessions #1814

Description

@hahahahahaiyiwen

Summary

After upgrading from GitHub.Copilot.SDK 0.3.0 to 1.0.4, our hosted one-shot runtime intermittently failed during Copilot agent execution with a SQLite lock error from the bundled Copilot CLI.

Disabling infinite sessions and session store avoided the issue.

Environment

  • SDK package: GitHub.Copilot.SDK 1.0.4
  • Bundled Copilot CLI: 1.0.65
  • Runtime OS: Linux container on AKS
  • Runtime mode: one request per container/sandbox
  • Container env:
    • HOME=/workspace
    • XDG_CACHE_HOME=/workspace/.cache

SDK usage

await using var client = new CopilotClient(new CopilotClientOptions
{
    WorkingDirectory = workspacePath
});

await client.StartAsync(cancellationToken);

await using var session = await client.CreateSessionAsync(
    new SessionConfig
    {
        Model = model,
        OnPermissionRequest = PermissionHandler.ApproveAll,
        Streaming = streamEvents,
        SkillDirectories = skillDirectories
    });

await session.SendAsync(new MessageOptions { Prompt = prompt });

Error

Execution failed: Error: database is locked

Stack trace from the Copilot CLI:

Error: database is locked
    at zde (file:///workspace/.cache/copilot/pkg/linux-x64/1.0.65/app.js:108:22936)
    at XNe (file:///workspace/.cache/copilot/pkg/linux-x64/1.0.65/app.js:112:2212)
    at Qde.executeByType (file:///workspace/.cache/copilot/pkg/linux-x64/1.0.65/app.js:112:3036)
    at Qde.sqlite (file:///workspace/.cache/copilot/pkg/linux-x64/1.0.65/app.js:112:2544)
    at async _J.ensureInitialized (file:///workspace/.cache/copilot/pkg/linux-x64/1.0.65/app.js:112:4942)
    at async _J.execute (file:///workspace/.cache/copilot/pkg/linux-x64/1.0.65/app.js:112:3677)
    at async jye.doLoad (file:///workspace/.cache/copilot/pkg/linux-x64/1.0.65/app.js:823:2329)
    at async jye.getUnreadUnnotifiedEntries (file:///workspace/.cache/copilot/pkg/linux-x64/1.0.65/app.js:823:1500)
    at async QTe.flushPendingNotifications (file:///workspace/.cache/copilot/pkg/linux-x64/1.0.65/app.js:3314:280)
    at async t.runAgenticLoop (file:///workspace/.cache/copilot/pkg/linux-x64/1.0.65/app.js:3346:5502)

Observed behavior

A newly provisioned Linux container starts a Copilot SDK session and sends a single prompt. During agent execution, the  CLI attempts to flush pending inbox notifications and reads  inbox_entries  from a SQLite-backed session database. That  query sometimes fails with  database is locked , causing the session to fail.

The relevant stack path appears to be:

Qde.sqlite
_J.ensureInitialized
_J.execute
jye.doLoad
jye.getUnreadUnnotifiedEntries
QTe.flushPendingNotifications
runAgenticLoop

Expected behavior

A default SDK session should not fail because internal CLI session persistence is temporarily locked. At minimum, SQLite  access should use an appropriate busy timeout/retry strategy, or sidekick/inbox/session-store persistence should not be  enabled by default for SDK-created one-shot sessions.

Workaround

We avoided the failure by explicitly disabling persisted session features:

await using var session = await client.CreateSessionAsync(
    new SessionConfig
    {
        Model = model,
        EnableSessionStore = false,
        InfiniteSessions = new InfiniteSessionConfig { Enabled = false },
        OnPermissionRequest = PermissionHandler.ApproveAll,
        Streaming = streamEvents,
        SkillDirectories = skillDirectories
    });

Our runtime is one-shot and does not need persistent Copilot session workspace, shared session store, or background  compaction, so this workaround is acceptable.

Questions

1. Is  InfiniteSessions  expected to be enabled by default for SDK-created sessions?
2. Is sidekick/inbox persistence expected to run for non-interactive SDK sessions?
3. Should SDK-hosted one-shot sessions have an easier preset for disabling persistent session DB features?
4. Should the CLI SQLite layer use a busy timeout/retry to avoid failing the whole session on transient locks?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions