Repository navigation
Compact idle threads, honour summarizer_model, add a memory block and per-turn recall - #8477
Conversation
Update the vendored tinyagents submodule to the latest upstream commit. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the vendored tinyagents submodule to the latest upstream commit. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the vendored tinyagents submodule to the latest upstream commit. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the vendored tinyagents submodule to the latest upstream commit. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the vendored tinyagents submodule to the latest upstream commit. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the vendored tinyagents submodule to the latest upstream commit. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Register the new summarizer test module alongside the existing native tests and bump the vendored tinyagents submodule to the revision those tests depend on. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
TurnModels now carries the model id used by the context-compaction summarizer and exposes it through an accessor, so the summarizer can report the correct model in its logs and summary provenance. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Reset the workspace crate versions from 3.1.3 back to 3.0.0 and lowered the windows-core and windows-sys requirements to match the older release line. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Adds tests for the RecallEachTurn path, verifying that a turn answers from its own message rather than a cached pack, that a recall exceeding its deadline adds no note and no extra latency, that turns without per-turn recall still read only completed packs, and that excluded hits leave the turn without a pack. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Updated the prefetch lifecycle tests to await the now-async pre_turn function and pass the additional argument it expects, keeping the assertions valid against the current signature. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduce a RecallEachTurn option that lets a host suppress recalled hits it already surfaces to the model another way, and make pre_turn async so the per-turn recall can be awaited with a timeout. The new parameter is currently unused, so existing behaviour is unchanged. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
The recall test now drops the runtime rather than awaiting shutdown, avoiding a hang when the test task tears down the agent runtime. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
MemoryBinding gains an optional recall_each_turn timeout and a builder method to set it, so callers can request that memory be recalled for the user's current message on every turn with a bounded wait before the first model call. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the vendored tinyagents submodule to a newer revision. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Updates the vendored tinyagents submodule to its latest commit and removes an unused ChatModel import from the summarizer tests so the test file compiles without warnings. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
The prefetch helper now takes an extra argument and returns a future, so the lifecycle and schema tests pass the additional `None` and await the result to keep their assertions valid. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Wrap the pre_turn call in an async move block and await it so the test closure returns a future, matching the expected signature. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
pre_turn now honours the each_turn option instead of ignoring it, waiting up to its deadline for the pack recalled for the current message and returning None when that pack is late, missing or excluded, while the background work still completes and is cached. Packs whose every cited hit is excluded are now skipped via a new excludes helper, and the cache-hit path is bypassed when each_turn is active. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Summarization requests now honour the `[context] summarizer_model` setting by swapping the model on the route the factory already selected, keeping the same provider, credentials and endpoint. Routes without a model of their own, such as sentinels, are left untouched and continue to take the model from the request pin. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
The per-turn model set now resolves the compaction summarizer from `[context] summarizer_model` when it is set and non-blank, falling back to the turn's own model otherwise, and logs which source was chosen. Injected model sources keep using the injected model since they have no route to call another model on. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
…model Renamed the helper that picks the compaction summarizer model so its name reads as an action rather than a value, avoiding confusion with the field it populates. Behaviour is unchanged. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
The managed turn builder was passing the summarizer model id variable instead of the resolved model, so a configured summarizer model was not pinned on the managed route. It now uses the resolved model, and a test covers the configured summarizer case. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Import SessionStoreProvider into the recall-each-turn integration test and reformat several call sites to satisfy rustfmt, so the test keeps compiling against the updated runtime API. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Adds a `recall_each_turn_ms` memory config option that makes each turn recall memory for the current message and wait up to that long before the first model call, instead of only using a pack prefetched for an earlier turn. Embed agents can set it through a new `MemoryBinding` recall timeout, and turn model registration now uses the summarizer model id for summarization. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
The summarization route was being configured with the summarizer model id instead of the primary model, so the managed route pinned the wrong model. It now passes the primary model, and the summarizer test registers a provider that honours the requested model override. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
The recall-each-turn test now clones the agent handles passed to ask and drops them only after each agent is removed, since removal awaits the MCP close and the runtime needs the handles to shut down cleanly. Removal failures now name the offending agent in the panic message. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
The summarization registration was being given the primary model id instead of the resolved summarizer model id, so summarization could run against the wrong model. It now passes the resolved summarizer model id. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Wrapped several over-long format! and assert_eq! expressions in the context wiring and agent definition tests so they fit the formatter's line width. No test behaviour changed. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Adds compact_history, which runs the existing compression middleware over a stored conversation without a model turn so callers can fold old history between turns. The policy trigger is set just below the caller's threshold so the middleware compacts, and the resulting carry is re-applied to the history the same way the session driver applies a turn's summary. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Documented that the idle fold policy caps the verbatim tail at half of min_tokens, matching how a turn's tail is capped at half its trigger. Also reworked the idle fold test to use a single-message conversation so it actually exercises the nothing-old-enough path rather than relying on a tail that covered everything. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduce compaction support for runtime sessions so long conversations can be condensed before they exceed the model's context window. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Re-export CompactOptions and CompactOutcome from the session host module so callers can configure and inspect transcript compaction without reaching into the runtime session internals. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduce a compact module exposing compact_thread_for and re-export the CompactOptions and CompactOutcome types from the session host, so callers can compact a chat thread through the agent chat API. The turn agent builder is widened to pub(super) so the new module can reuse it. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduce a compact module that exposes CompactOptions and CompactOutcome, re-exported from the agent module and the crate root so callers can configure and inspect conversation compaction. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
The skipped-compaction assertion now prints the underlying error before panicking, so a failure shows why compaction was rejected instead of only the generic expectation message. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Compaction now takes the same model, temperature and route overrides as a turn and applies them to the config before building the session, so the compacted transcript matches the one the next turn would resume. The override logic was extracted into a shared helper used by both paths. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
The `#[allow(clippy::too_many_arguments)]` attribute was removed from `compact_thread_for` since the function no longer trips that lint, keeping the code free of unnecessary suppressions. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Compaction now builds the same ephemeral route, model override, and temperature that a normal turn uses, so compacted threads run against the provider the caller selected instead of the agent's default config. The route construction was pulled out of dispatch into a reusable helper to keep both paths in sync. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Added a temporary debug print of the post-compaction messages so the failing assertion can be inspected. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Replace the debug dump and single-message checks with a helper that collects the leading system messages, so the test compares the full system prompt before and after compaction and locates the summary relative to it. Also simplify the skipped-compaction error handling to a plain expect. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Reformatted long function signatures, error strings, and assertions in the compact session host, the embed re-exports, and the compact thread test to satisfy rustfmt line-width rules. No behaviour changed. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
The compaction test now learns memories into a reference engine and asserts that the static system prompt and tool declarations stay byte-identical across the compaction boundary while the memory block is freshly rendered for the new generation, including memories learned while the user was away. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Compaction now re-renders the memory block for the successor generation instead of carrying the head's block over unchanged, so the folded history starts with up-to-date memory. The prefix length is recomputed after the refresh and the previously dead-code seam is now wired into the compaction path. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Reformatted the compact thread test to satisfy rustfmt, splitting the static prompt filter chain and the system prompt assertion across multiple lines. No test behaviour changed. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
The agent README now covers `Agent::compact_thread`, its options and outcomes, and how a compaction seals the head generation while preserving the system prompt and tool declarations for prefix caching. The turns and sessions page also notes that compaction seals a generation and opens a child instead of erasing history. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
The context README now describes ContextSettings as the whole [context] table, covering the summarizer tool rendering and max output token options alongside the flattened TinyAgents ContextConfig. A new section explains how compact_history and compact_bound_history fold a thread's history outside a model turn and seal the head generation. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Adds the CompactOptions, CompactOutcome and MemoryBlockSpec types to the embed API index and describes host-initiated idle compaction, including its outcomes and locking behaviour, so embedders can fold a thread's history before the next turn. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the vendored tinyagents submodule to the latest upstream commit. Auto-committed-on: macbook Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Tiny Sweeper review
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Summary
Four related changes that let a host keep a long conversation cheap and keep what the agent knows about the user across compactions.
[context] summarizer_modelis honoured. The setting (andOPENHUMAN_CONTEXT_SUMMARIZER_MODEL) was parsed but never read:TurnModels::summarizeralways built a second instance of the turn's own model. It now builds the configured model on the turn's provider route (route_with_model) and logs[context_compression] summarizer model=<id> source=config|turn. If the configured summarizer fails, the existing breaker falls back to a deterministic trim; it does not fall back to the turn model.[context] summarizer_tool_rendering(full|markers) andsummarizer_max_output_tokens, with env overlaysOPENHUMAN_CONTEXT_SUMMARIZER_TOOL_RENDERING/OPENHUMAN_CONTEXT_SUMMARIZER_MAX_OUTPUT_TOKENS. Withmarkers, the summarizer sees the conversation's prose and one[used <tool>: <args>]line per tool call, and no tool output (tinyagents#587).Config.contextis now aContextSettingswrapper that flattens tinyagents'ContextConfig(reachable throughDeref), so existing TOML is unchanged.openhuman_embed::Agent::compact_thread(thread_id, CompactOptions { min_tokens, keep_recent_tokens }) -> CompactOutcome::{Compacted, Skipped, Empty}compacts a thread without a model turn, for hosts that compact while a user is idle.CompactionCarry.begin_generation_from_baseline, so nothing is erased.Session::persistdoes.AgentDefinitionSpec::memory_block(MemoryBlockSpec { max_tokens })appends a<memory>system message holding the identity's top beliefs and learnings after the prompt. It is re-rendered only when a thread starts or is compacted, and left out of the prompt-change comparison, so a memory change alone never busts the prefix cache or addsPROMPT_UPDATE_NOTE. Logs are[memory_block] rendered|kept|empty|error.MemoryBinding::recall_each_turn(Duration)(config[memory] recall_each_turn_ms) recalls for the message being answered, with a deadline, and adds the hits as a tail note that is not persisted. Hits already in the block are dropped. Previouslyprefetch::pre_turnonly returned the pack completed for the previous message, which had usually expired, so recall almost never reached the model. A late recall is logged as[memory:recall] deadline.Public API / behaviour changes
Agent::compact_thread,CompactOptions,CompactOutcome,MemoryBlockSpec,AgentDefinitionSpec::memory_block,MemoryBinding::recall_each_turn.[context] summarizer_tool_rendering,summarizer_max_output_tokens, and[memory] recall_each_turn_ms.summarizer_modelnow takes effect when set. All other defaults are unchanged.Depends on
tinyhumansai/tinyagents#587, merged.
vendor/tinyagentsnow points at its merge commit231d91c59on tinyagentsmain. No tinyagents release has been cut since, soCargo.locklists the tinyagents crates atmain's version, 3.0.0, instead of the 3.1.3 release tag the old pin pointed at. The tag commit only bumped versions, so no code differs.Validation
cargo fmt --all -- --check: clean.node scripts/ci/check-openhuman-rust-layout.mjs: passed.cargo clippy -p openhuman -p openhuman-embed -p openhuman-cli -p openhuman-tinyhumans --all-targets --features <product features> -- -D warnings: clean.cargo nextest run -p openhuman -p openhuman-embed --liboveragent::,memory::,config::,inference::,agent_registryand channel memory: 3175 passed, 6 failed. All 6 fail identically on unmodifiedorigin/main(checked in a separate checkout):a_detached_driver_uses_its_carried_actor_for_lifecycle_commitsresuming_after_owner_cache_loss_registers_live_task_before_launchfailed_driver_resume_marks_paused_session_failed_and_releases_ownerspawn_subagent_with_same_task_key_resumes_paused_job_through_shared_driverheadless_child_at_depth_cap_gets_readable_spawn_refusalnative_host_agent_turn_enforces_the_configured_channel_deadlineopenhuman-embedlib (296), plus the integration testscompact_thread,memory_block,memory_recall_each_turn,session_store,route_headersandharness_embed: pass. The embed lib needs--test-threads=1under plaincargo testbecause of process-global slots; under nextest it passes.turn_models_summarizer_tests.rs(wiremock: the request goes to the configured model id);context_wiring_tests::a_compaction_records_the_summarizer_model_it_called;memory_block_tests.rs(core and session host);prefetch_recall_each_turn_tests.rs;tests/compact_thread.rs: skip below threshold, empty thread, compact above it, a racing turn waits, prompt and tools byte-identical, fresh memory block, sealed generation readable.Known limits
Session::compact_historybesidereset_historyupstream; that is a follow-up.compact_thread's token estimate counts messages, not tool schemas.Summary by CodeRabbit