feat(agent-sdk): let agent_knowledge_recall request source chunks - #2995
Open
chethanuk wants to merge 1 commit into
Open
feat(agent-sdk): let agent_knowledge_recall request source chunks#2995chethanuk wants to merge 1 commit into
chethanuk wants to merge 1 commit into
Conversation
The recall API already supports `include: {chunks}`, and the TypeScript
client already exposes it as `includeChunks`/`maxChunkTokens`, but the
agent tool forwarded only `{maxTokens, types}` — so an agent had no way
to reach the raw source text a fact was extracted from, which is exactly
what "what did we actually say" questions need.
Add optional `include_chunks` / `max_chunk_tokens` parameters and pass
them through. Both are additive and off by default, so recall responses
are unchanged unless an agent asks for chunks.
Fixes vectorize-io#2949
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.
Problem
agent_knowledge_recallforwards only{maxTokens, types}toclient.recall, soinclude.chunksnever reaches the API from an agent context. Agents can read extracted fact units but never the raw source text a fact came from, which is what "what did we actually say" and exact-number questions need.The plumbing below this already exists. The TypeScript client declares
includeChunks/maxChunkTokensand maps them toinclude.chunks = { max_tokens: … ?? 8192 }. Only the tool schema and the one call site were missing.Fixes #2949
Fix
Two optional parameters on
agent_knowledge_recall:include_chunks(boolean, default false): also return the raw source text the memories were extracted from.max_chunk_tokens(number, default 8192): token budget for those chunks.include_chunksis gated on=== true, matching howagent_knowledge_reflectgatesinclude_facts.max_chunk_tokensmirrorsparseRecallMaxTokens, except it returnsundefinedon absent or unusable input so the client's own 8192 default applies instead of a second copy of that number living here.Both are additive and off by default, so recall responses are unchanged unless an agent asks for chunks. Also one sentence in the openclaw integration docs, with its generated
skills/mirror refreshed via./scripts/generate-docs-skill.sh.Open question
The issue offered two shapes and left the pick to you: an
include_chunksflag on the existing tool, or a dedicatedagent_knowledge_recall_sourcetool. This is the first, which is the smaller change and keeps one recall path. The argument for the second is real though. A separate tool makes the "I need verbatim" intent explicit to the model and keeps ordinary lookups lean. Happy to rework it that way if you prefer.Test evidence
npm test(hindsight-agent-sdk)npx tsc --noEmit./scripts/hooks/lint.shThree new cases, each asserting the outgoing request body rather than the intent:
recall omits source chunks unless include_chunks is exactly true: omitted,false, the string"false", and a baremax_chunk_tokensall leave chunks off.recall include_chunks requests source chunks and returns them to the agentrecall falls back to the client's chunk budget on unusable max_chunk_tokens: 2048, 0, -5, non-numeric.