Skip to content

fix(memory): complete provider cancellation#1977

Merged
yyhhyyyyyy merged 2 commits into
devfrom
fix/memory-provider-cancellation
Jul 15, 2026
Merged

fix(memory): complete provider cancellation#1977
yyhhyyyyyy merged 2 commits into
devfrom
fix/memory-provider-cancellation

Conversation

@yyhhyyyyyy

@yyhhyyyyyy yyhhyyyyyy commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator
  • serialize ACP standalone requests per reused session
  • retain capacity until cancelled prompts settle
  • forward abort signals through provider transports
  • preserve AI SDK system prompt compatibility

Summary by CodeRabbit

  • New Features

    • End-to-end request cancellation now propagates across text generation, streaming, speech, images, video, and device-flow token retrieval.
    • Memory provider requests forward cancellation signals through the in-process layer.
  • Bug Fixes

    • Cancellation and request timeouts are combined reliably, preserving abort reasons.
    • Capacity is no longer released until in-flight cancelled calls fully settle; improved cleanup for timers/listeners and permission/prompt cancellation paths.
  • Tests

    • Expanded cancellation/timeout/cleanup coverage across providers and runtime components.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f9b71f00-c375-4284-ac1f-b6c03758a129

📥 Commits

Reviewing files that changed from the base of the PR and between 031a1f3 and a02e23f.

📒 Files selected for processing (2)
  • test/main/presenter/memoryProviderBindings.test.ts
  • test/memory-test-scope.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/main/presenter/memoryProviderBindings.test.ts

📝 Walkthrough

Walkthrough

Changes

Caller abort signals are added to text-generation contracts and forwarded through memory bindings, presenter APIs, provider implementations, AI SDK transports, ACP prompt flows, Copilot device flow, TTS, image, and video requests. Tests cover propagation, timeout composition, cleanup, prompt settlement, and memory capacity release.

Cancellation propagation

Layer / File(s) Summary
Contracts and memory wiring
src/shared/types/presenters/*, src/main/presenter/memoryProviderBindings.ts, src/main/presenter/llmProviderPresenter/{baseProvider.ts,index.ts}, src/main/presenter/agentRuntimePresenter/compactionService.ts
Generation APIs accept optional abort options, memory bindings forward signals, and compaction passes its signal into generateText.
Unified runtime cancellation
src/main/presenter/llmProviderPresenter/aiSdk/runtime.ts, test/main/presenter/llmProviderPresenter/aiSdkRuntime.test.ts
Caller signals are combined with model timeouts and forwarded through text, streaming, image, TTS, and video transports with listener and timer cleanup.
ACP prompt and request lifecycle
src/main/presenter/llmProviderPresenter/providers/acpProvider.ts, test/main/presenter/acpProvider.test.ts
ACP prompts, permissions, standalone queues, and session cleanup respond to caller cancellation while preserving prompt settlement behavior.
Provider adapter propagation
src/main/presenter/llmProviderPresenter/providers/*, src/main/presenter/githubCopilotDeviceFlow.ts, test/main/presenter/llmProviderPresenter/*, test/main/presenter/githubCopilotDeviceFlow.test.ts
AI SDK, Copilot, Ollama, and VoiceAI provider paths forward abort signals and preserve system-prompt and device-flow behavior.
Memory capacity settlement validation
test/main/presenter/memoryProviderGateway.test.ts, test/main/presenter/memoryProviderBindings.test.ts, test/memory-test-scope.json, docs/issues/memory-provider-text-cancellation/spec.md
Bindings and gateway tests verify signal forwarding and capacity retention until aborted provider promises settle; the specification records the cancellation requirements.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MemoryProviderGateway
  participant MemoryProviderBindings
  participant LLMProviderPresenter
  participant Provider
  participant Transport
  MemoryProviderGateway->>MemoryProviderBindings: pass AbortSignal
  MemoryProviderBindings->>LLMProviderPresenter: generateText(options.signal)
  LLMProviderPresenter->>Provider: forward provider options
  Provider->>Transport: use combined or relayed abort signal
  Transport-->>Provider: settle with cancellation reason
  Provider-->>MemoryProviderGateway: settle provider promise
Loading

Possibly related PRs

Suggested reviewers: zerob13

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: completing cancellation propagation across provider paths, especially memory-related flows.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/memory-provider-cancellation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/main/presenter/acpProvider.test.ts (1)

4-4: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Move this suite to the mirrored provider test path.

The source is src/main/presenter/llmProviderPresenter/providers/acpProvider.ts, so this suite should live at test/main/presenter/llmProviderPresenter/providers/acpProvider.test.ts.

As per path instructions, “Place main-process Vitest suites under test/main/ and mirror the source layout there.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/main/presenter/acpProvider.test.ts` at line 4, Move the
AcpPromptController test suite from its current location to the mirrored path
under test/main/presenter/llmProviderPresenter/providers, matching the source
location of acpProvider.ts while preserving the suite contents.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/main/presenter/acpProvider.test.ts`:
- Line 4: Move the AcpPromptController test suite from its current location to
the mirrored path under test/main/presenter/llmProviderPresenter/providers,
matching the source location of acpProvider.ts while preserving the suite
contents.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 915b5b5e-6e91-43dc-a55a-ef358ca64b51

📥 Commits

Reviewing files that changed from the base of the PR and between c822e7c and 031a1f3.

📒 Files selected for processing (27)
  • docs/issues/memory-provider-text-cancellation/spec.md
  • src/main/presenter/agentRuntimePresenter/compactionService.ts
  • src/main/presenter/githubCopilotDeviceFlow.ts
  • src/main/presenter/index.ts
  • src/main/presenter/llmProviderPresenter/aiSdk/runtime.ts
  • src/main/presenter/llmProviderPresenter/baseProvider.ts
  • src/main/presenter/llmProviderPresenter/index.ts
  • src/main/presenter/llmProviderPresenter/providers/acpProvider.ts
  • src/main/presenter/llmProviderPresenter/providers/aiSdkProvider.ts
  • src/main/presenter/llmProviderPresenter/providers/githubCopilotProvider.ts
  • src/main/presenter/llmProviderPresenter/providers/ollamaProvider.ts
  • src/main/presenter/llmProviderPresenter/providers/voiceAIProvider.ts
  • src/main/presenter/memoryProviderBindings.ts
  • src/shared/types/presenters/core.presenter.d.ts
  • src/shared/types/presenters/llmprovider.presenter.d.ts
  • test/main/presenter/acpProvider.test.ts
  • test/main/presenter/agentRuntimePresenter/compactionService.test.ts
  • test/main/presenter/githubCopilotDeviceFlow.test.ts
  • test/main/presenter/llmProviderPresenter.test.ts
  • test/main/presenter/llmProviderPresenter/aiSdkRuntime.test.ts
  • test/main/presenter/llmProviderPresenter/anthropicProvider.test.ts
  • test/main/presenter/llmProviderPresenter/baseProvider.test.ts
  • test/main/presenter/llmProviderPresenter/githubCopilotProvider.test.ts
  • test/main/presenter/llmProviderPresenter/ollamaProviderCancellation.test.ts
  • test/main/presenter/llmProviderPresenter/voiceAIProvider.test.ts
  • test/main/presenter/memoryProviderBindings.test.ts
  • test/main/presenter/memoryProviderGateway.test.ts

@yyhhyyyyyy yyhhyyyyyy merged commit 8b5a6d3 into dev Jul 15, 2026
4 checks passed
@yyhhyyyyyy yyhhyyyyyy deleted the fix/memory-provider-cancellation branch July 15, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant