Skip to content

feat(api): add targeted consolidation by observation scopes - #1746

Merged
nicoloboschi merged 3 commits into
mainfrom
feat/1625-targeted-consolidation
May 26, 2026
Merged

feat(api): add targeted consolidation by observation scopes#1746
nicoloboschi merged 3 commits into
mainfrom
feat/1625-targeted-consolidation

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Summary

Closes #1625

  • Add observation_scopes: list[list[str]] parameter to POST /v1/default/banks/{bank_id}/consolidate — when provided, only unconsolidated memories whose tags contain all tags in at least one scope are processed (tags @> scope with OR across scopes)
  • Add enable_auto_consolidation hierarchical config flag (HINDSIGHT_API_ENABLE_AUTO_CONSOLIDATION, default true) — when false, retain/delete/update operations no longer auto-trigger consolidation, letting users run it on-demand via the API
  • Scoped consolidation skips bank-level task deduplication so it doesn't merge into a pending full-bank sweep
  • Round-limit re-queue carries forward the same scope filter

Test plan

  • test_targeted_consolidation_filters_by_scopes — single scope filters correctly, leaves other scopes unconsolidated
  • test_targeted_consolidation_multiple_scopes — OR semantics across multiple scopes
  • test_targeted_consolidation_no_scopes_processes_all — backward compatibility (no scopes = full bank sweep)
  • test_targeted_consolidation_contains_semantics["user:alice"] matches memories tagged ["user:alice", "team:eng"]
  • test_enable_auto_consolidation_flag — retain with flag disabled produces no observations
  • All 68 existing consolidation tests pass
  • Round limit and failure recovery tests pass
  • Lint passes

Add `observation_scopes` parameter to the consolidate endpoint to run
consolidation only on memories matching specific tag scopes, and add
`enable_auto_consolidation` config flag to disable automatic
post-retain consolidation.
Update observations docs with targeted consolidation section,
trigger consolidation endpoint reference, and auto-consolidation
disable flag. Regenerate OpenAPI spec and client SDKs.
@nicoloboschi
nicoloboschi merged commit ac3ab2b into main May 26, 2026
66 of 71 checks passed
nicoloboschi added a commit that referenced this pull request May 26, 2026
PR #1746 added enable_auto_consolidation to _CONFIGURABLE_FIELDS and
introduced a ConsolidationRequest body on the /consolidate endpoint, but
didn't update test_hierarchical_fields_categorization (still expects 35
fields) or the CLI's trigger_consolidation wrapper (still calls the
generated client with 2 args), so CI on this branch breaks on test-api,
test-rust-cli, test-embed-windows, and test-doc-examples (cli).

Bump the expected count to 36, add enable_auto_consolidation to the
explicit assertions, and pass a default ConsolidationRequest to the
generated client so the no-scope CLI invocation keeps consolidating all
unconsolidated memories.
nicoloboschi added a commit that referenced this pull request May 26, 2026
… (#1757)

PR #1746 added enable_auto_consolidation to _CONFIGURABLE_FIELDS and
introduced a ConsolidationRequest body on the /consolidate endpoint, but
didn't update test_hierarchical_fields_categorization (still expects 35
fields) or the CLI's trigger_consolidation wrapper (still calls the
generated client with 2 args), so CI on this branch breaks on test-api,
test-rust-cli, test-embed-windows, and test-doc-examples (cli).

Bump the expected count to 36, add enable_auto_consolidation to the
explicit assertions, and pass a default ConsolidationRequest to the
generated client so the no-scope CLI invocation keeps consolidating all
unconsolidated memories.
nicoloboschi added a commit that referenced this pull request May 26, 2026
PR #1746 (targeted consolidation by observation scopes) added a request body
to the POST /v1/default/banks/{bank_id}/consolidate endpoint, but the rust
CLI caller in hindsight-cli/src/api.rs was not updated, so the rust client
test was broken on main (just not surfaced — test-rust-cli only runs when
core/cli/ci files change in a PR, and the PR that introduced the body
didn't trigger it).

CLI always wants the "consolidate everything" behavior, so we pass an
empty ConsolidationRequest (observation_scopes: None). Surfaced when this
PR's hindsight-api-slim changes triggered test-rust-cli.
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.

Targeted consolidation API: trigger consolidation for specific observation scopes only

1 participant