Skip to content

fix(cindy): recall with the end of a long prompt - #2780

Merged
hidb4ai merged 1 commit into
oceanbase:masterfrom
Fengzdadi:fix/cindy-recall-query-tail
Nov 25, 2026
Merged

hidb4ai merged 1 commit into
oceanbase:masterfrom
Fengzdadi:fix/cindy-recall-query-tail

Conversation

@Fengzdadi

Copy link
Copy Markdown
Collaborator

Which issue or RFC does this PR close?

Part of #2250.

Rationale for this change

Cindy's will-user-message hook skipped recall for any prompt longer than 8,192 UTF-16 units, so a common turn such as pasted logs followed by a question got no context at all. The other hosts that recall automatically (DSH, OpenCode, Pi, Bub, Hermes, LangChain, LangGraph, Pydantic AI, and the hook-based hosts) bound a long prompt with the shared rule in tests/fixtures/recall_query_bound.json and recall with its end. OpenClaw moves to the rule in #2779. Cindy landed in #1564 a day before #2252 moved hosts to that rule, and was never switched.

What changes are included in this PR?

  • integrations/cindy/src/worker.ts: the hook sends query: boundedRecallQuery(input.text), reusing DSH's existing boundedRecallQuery export from prepared-context.ts, which the worker already imports validatePreparedContext from. The query_too_long outcome is removed. It appeared in no docs, tests or UI. The sensitive-content skip, the capture limits (source_too_long), the prepared-context marker check and the hook timing are unchanged. Capture still stores the original prompt, not the recall query.
  • integrations/cindy/plugins/powercontext-hooks/node/worker.cjs: rebuilt with the Cindy tsdown config. The diff is the bundled boundedRecallQuery and the changed call.
  • integrations/cindy/tests/hooks.test.cjs: two tests. One drives the hook with about 20,000 characters of pasted log lines followed by a question and asserts that recall is ready and that the prepare query ends with the question and fits 8,192 characters and 8,192 UTF-8 bytes. The other runs every case in tests/fixtures/recall_query_bound.json through runHook and asserts the query sent to /v1/context/prepare.
  • Docs: docs/en/docs/integrations/cindy.md and docs/zh/docs/integrations/cindy.md state how a prompt over the bounds is recalled. The comparison table in integrations/cindy/README.md lists the shared recall-query bound.

No CI path change is needed. tests/fixtures/** already selects every suite.

Are there any user-facing changes?

Yes. In Cindy, a prompt longer than 8,192 characters or 8,192 UTF-8 bytes now recalls with its end. Before this change, a prompt longer than 8,192 UTF-16 units got no recall, and a shorter prompt over 8,192 UTF-8 bytes was sent whole. For prompts within the bounds, the recall query is now trimmed of surrounding whitespace, matching the shared rule. Capture behavior is unchanged. There are no API or persisted-format changes.

How was this change tested?

  • node --test integrations/cindy/tests/hooks.test.cjs before the source change: 24 tests, 22 passed, 2 failed. Both failures were the new tests: the long-prompt test got prepare: 'query_too_long' instead of 'ready', and the fixture test got no prepare request.
  • The steps of make cindy-test, run one by one:
    • tsdown --config ../../../cindy/tsdown.config.ts from integrations/dsh/plugins/powercontext: build complete.
    • git diff --exit-code -- integrations/cindy/plugins/powercontext-hooks/node/worker.cjs after the commit: clean, so the committed bundle is fresh.
    • node --test integrations/cindy/tests/*.test.cjs: 26 tests, 26 passed, 0 failed.
    • uv run python integrations/cindy/scripts/package.py: wrote dist/powercontext-cindy-hooks-0.1.0.cindy.
  • prek run --files <the six changed files>: all hooks applicable to those files passed, including ty check.

make cindy-test was not run as a single target. Its dependency install could not complete offline, so tsdown was run directly from the same directory with the same config, against DSH dependencies installed from the same pnpm-lock.yaml. The real-Cindy chain tests (tests/e2e/test_cindy_hooks_chain.py, tests/e2e/test_cindy_mcp_chain.py) need a Cindy source checkout and were not run locally. CI runs them in cindy-package.

AI usage statement

Claude Code (Claude Opus 5.5) wrote the source change, the tests and the doc updates, rebuilt the bundle, ran the commands above, and drafted this description. A second Claude Code session reviewed the change, rebuilt the bundle in a clean checkout and found it identical to the committed one, reran the Cindy tests (26 passed) and the packaging step, and confirmed that both new tests fail against the previous bundle.

Cindy's will-user-message hook skipped recall for any prompt over 8,192
UTF-16 units, so pasted logs followed by a question got no context. Send
the shared recall-query bound (tests/fixtures/recall_query_bound.json)
through DSH's existing boundedRecallQuery export, as the other automatic
recall hosts do: trim, keep the longest trailing text within 8,192
characters and 8,192 UTF-8 bytes without splitting a character, trim.

Part of oceanbase#2250.
PsiACE
PsiACE previously approved these changes Nov 23, 2026

@PsiACE PsiACE left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@PsiACE
PsiACE dismissed their stale review November 23, 2026 14:45

duplicate approval

@AlexStocks AlexStocks added the 1.6.1 v1.6.1 release tracking label Nov 24, 2026

@hireview001 hireview001 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed a7d850b. No blocking findings. Reusing the existing bounded recall query fixes skipped recall for long prompts and enforces the shared UTF-8 bound while preserving original-prompt capture and the existing privacy checks. No new database tables or interfaces. The Cindy tests pass locally; CI also verifies the rebuilt bundle and the pinned Cindy source chain. Merge score: 90/100.

@NeverENG NeverENG left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed a7d850b. Reviewed tail bounding and full-prompt privacy checks; bundled Cindy hook tests pass. No blocking findings.

@hidb4ai
hidb4ai merged commit 5c743ce into oceanbase:master Nov 25, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.6.1 v1.6.1 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants