Skip to content

fix(memory): reject non-finite external_prefetch_timeout - #131448

Open
RaviTharuma wants to merge 5 commits into
NousResearch:mainfrom
RaviTharuma:fix/memory-reject-nonfinite-prefetch-timeout
Open

RaviTharuma wants to merge 5 commits into
NousResearch:mainfrom
RaviTharuma:fix/memory-reject-nonfinite-prefetch-timeout

Conversation

@RaviTharuma

Copy link
Copy Markdown

What does this PR do?

Follow-up to #131357 addressing @JoaoMarcos44 P2: non-finite memory.external_prefetch_timeout values (.nan / .inf / string nan/inf) bypassed value <= 0 and later crashed threading.Thread.join.

This branch is based on #131357 tip fd164da238 plus one additional commit that requires math.isfinite(value) and value > 0 in resolve_external_prefetch_timeout (soft fallback) and MemoryManager.__init__ (strict). If #131357 is preferred as the landing vehicle, please cherry-pick commit 281808ae84 onto that branch and this PR can be closed as redundant.

Related Issue

Fixes #131446
Follow-up to #131357 (addresses #131357 (comment))
Salvage lineage: #130788 / #104405

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • agent/memory_manager.py — import math; resolve_external_prefetch_timeout rejects non-finite/non-positive values; MemoryManager.__init__ requires a finite positive timeout.
  • tests/agent/test_memory_provider.py — regressions for .nan/.inf/-.inf/nan/inf/None/0/negative/junk → default; finite 2.5 still overrides; memory_manager_from_config({nan}) never stores a non-finite join timeout.

How to Test

  1. python -m pytest tests/agent/test_memory_provider.py -q — Observed: 65 passed.
  2. Spot-check: resolve_external_prefetch_timeout({"external_prefetch_timeout": float("nan")}) == _EXTERNAL_PREFETCH_TIMEOUT_S.

Checklist

Code

Documentation & Housekeeping

  • Docstring updated on the resolver — N/A for README/cli-config (no new keys)
  • cli-config.yaml.example — N/A
  • CONTRIBUTING.md / AGENTS.md — N/A
  • Cross-platform impact considered — N/A (pure-Python float validation)
  • Tool schemas — N/A

liuhao1024 and others added 2 commits October 2, 2026 16:41
Salvage rebase of NousResearch#130788 (itself a recovery of NousResearch#104562) onto current
main. The original branch conflicted on agent/agent_init.py and the
surrounding memory manager has since evolved (recall dedupe, provider
telemetry, spill config); all main-side behavior is preserved here.

- memory.external_prefetch_timeout (config.yaml, default 8s) bounds an
  external provider's synchronous prefetch; resolved through
  memory_manager_from_config at agent init
- a timed-out prefetch's late result is cached bound to its originating
  session and query, generation-invalidated on turn start, session
  rotation, rewind and compression, and reused on the next turn instead
  of the provider being parked for the session
- late values are spill-capped before they are stored or returned

Fixes NousResearch#104405
Copilot AI balanced review requested due to automatic review settings October 2, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers area/config Config system, migrations, profiles area/memory Memory subsystem: store, providers, sync, background reviews sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Oct 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles area/memory Memory subsystem: store, providers, sync, background reviews comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Non-finite memory.external_prefetch_timeout bypasses validation and crashes Thread.join

4 participants