Repository navigation
feat(memory): take the memory block render off the turn's critical path - #708
Merged
Merged
Conversation
Read beliefs and learnings concurrently, log elapsed_ms for each render, bound a generation start's wait with [memory] memory_block_deadline_ms (deferred renders land in a process-wide store taken by the next generation start), and add OpenHumanSessionHost::prewarm_memory_block and embed Agent::prewarm_memory_block plus MemoryBinding::memory_block_deadline. Co-authored-by: Medulla <medulla@tinyhumans.ai>
This was referenced Nov 7, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #707
Part of tinyhumansai/chottu-core#712
What changed
engine::resolveis already cached per config fingerprint and does no I/O for Chottu's bound (host or registered) engine, so it is not the cost. What is left is two sequential network round trips to the hosted engine,beliefsthenlist, each seconds long. They are now read concurrently (memory/lifecycle/memory_block.rs), which pays the latency once. A per-step breakdown is logged at debug as[memory_block] read resolve_ms beliefs_ms list_ms, and[memory_block] rendered|empty|errornow carryelapsed_ms. The remaining latency is the engine's own (the same slowness behind[memory:prefetch] automatic refresh timed out); that belongs in tinymemory/CortexDB and is not filed from here.[memory] memory_block_deadline_ms(default unset, behaviour unchanged). A generation start waits that long for the render. When it lapses the turn keeps the recorded block (a cold thread sends none), logs[memory_block] deferred, and the render finishes in the background (under the session's core context) into a process-wide store (runtime_session/memory_block_ready.rs, keyed by workspace, memory identity and token budget; taken once, 1 h max age, 256 entries). The next generation start takes it ([memory_block] ready), so the current generation's prefix is never changed mid-turn.OpenHumanSessionHost::prewarm_memory_block() -> MemoryBlockPrewarmand, for embedders,Agent::prewarm_memory_block(thread_id).MemoryBinding::memory_block_deadline(Duration)maps onto the config key.TurnObservationlives in tinyagents, so it needs a separate leaf.Gates (inside vendor/openhuman; the package is
openhuman,openhuman-coreis the binary in openhuman-cli)cargo fmt --all -- --check: passcargo test -p openhuman --lib memory_block: 37 passed (existingmemory_block_tests.rsunchanged and passing; new:memory_block_render_respects_deadline,deferred_memory_block_is_used_next_generation,prewarmed_memory_block_skips_render_on_turn, concurrency, store tests)cargo test -p openhuman --lib config::schema::memory: 19 passed;cargo test -p openhuman-embed --lib spec: 11 passedcargo clippy -p openhuman-embed --all-targets -- -D warnings: passcargo clippy -p openhuman --all-targets -- -D warnings: fails on 23 pre-existing lints in unrelated files (e.g.scheduler_host_agent_tests.rs,security/egress/privacy.rs); none in changed filescargo test -p openhuman-embed --test memory_blockand--test runtime_agents: fail identically with and without this change (the runtime does not build in this environment), so the one added assertion inruntime_agents.rs(deadline reachesconfig().memory) was not run.