Skip to content

API Reference parrot.tools.working_memory.tests.test_thread_offload

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.working_memory.tests.test_thread_offload

View source

Tests for the CPU-bound thread-offload optimisation in WorkingMemoryToolkit.

Large DataFrame copy/summary work (copy(deep=True), describe, memory_usage(deep=True)) is offloaded to a worker thread via asyncio.to_thread so it does not block the event loop, while small frames stay inline to avoid the thread-dispatch overhead.

Covers:

  • _is_large_df / _has_large_entry cell-count gating.
  • store / get_stored / import_from_tool / compute_and_store / merge_stored / summarize_stored / list_stored / search_stored route large frames through asyncio.to_thread but produce identical results to the inline path.
  • Small frames never hit asyncio.to_thread.

Alias CatalogEntry

Re-exported from parrot.tools.working_memory.internals.CatalogEntry.

Class TestGating

Method TestGating.test_is_large_df_threshold

test_is_large_df_threshold()

Method TestGating.test_zero_column_frame_is_not_large

test_zero_column_frame_is_not_large()

Method TestGating.test_has_large_entry_ignores_generic_entries

test_has_large_entry_ignores_generic_entries()

Method TestGating.test_default_threshold_applied

test_default_threshold_applied()

Class TestOffloadRouting

Method TestOffloadRouting.test_store_large_frame_offloads

test_store_large_frame_offloads(spy)

Parameter Type Default Description
spy

Method TestOffloadRouting.test_store_small_frame_runs_inline

test_store_small_frame_runs_inline(spy)

Parameter Type Default Description
spy

Method TestOffloadRouting.test_offload_summary_matches_inline_summary

The offloaded summary must be byte-for-byte the same as the inline one.

test_offload_summary_matches_inline_summary()

Method TestOffloadRouting.test_get_stored_large_offloads

test_get_stored_large_offloads(spy)

Parameter Type Default Description
spy

Method TestOffloadRouting.test_import_from_tool_large_offloads_copy_and_summary

test_import_from_tool_large_offloads_copy_and_summary(spy)

Parameter Type Default Description
spy

Method TestOffloadRouting.test_compute_and_store_large_offloads

test_compute_and_store_large_offloads(spy)

Parameter Type Default Description
spy

Method TestOffloadRouting.test_merge_stored_large_offloads

test_merge_stored_large_offloads(spy)

Parameter Type Default Description
spy

Method TestOffloadRouting.test_list_stored_offloads_when_any_entry_large

test_list_stored_offloads_when_any_entry_large(spy)

Parameter Type Default Description
spy

Method TestOffloadRouting.test_list_stored_inline_when_all_small

test_list_stored_inline_when_all_small(spy)

Parameter Type Default Description
spy

Method TestOffloadRouting.test_search_stored_large_offloads_and_matches

test_search_stored_large_offloads_and_matches(spy)

Parameter Type Default Description
spy

Alias WorkingMemoryToolkit

Re-exported from parrot.tools.working_memory.WorkingMemoryToolkit.

Function spy

Patch asyncio.to_thread as seen by the toolkit module with a spy.

spy(monkeypatch) -> _ToThreadSpy

Parameter Type Default Description
monkeypatch

Returns: _ToThreadSpy

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally