Skip to content

feat(agent-sdk): let agent_knowledge_recall request source chunks - #2995

Open
chethanuk wants to merge 1 commit into
vectorize-io:mainfrom
chethanuk:issue-2949-recall-include-chunks
Open

feat(agent-sdk): let agent_knowledge_recall request source chunks#2995
chethanuk wants to merge 1 commit into
vectorize-io:mainfrom
chethanuk:issue-2949-recall-include-chunks

Conversation

@chethanuk

Copy link
Copy Markdown
Contributor

Problem

agent_knowledge_recall forwards only {maxTokens, types} to client.recall, so include.chunks never 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 / maxChunkTokens and maps them to include.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_chunks is gated on === true, matching how agent_knowledge_reflect gates include_facts. max_chunk_tokens mirrors parseRecallMaxTokens, except it returns undefined on 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_chunks flag on the existing tool, or a dedicated agent_knowledge_recall_source tool. 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

Check Result
npm test (hindsight-agent-sdk) 20 passed
npx tsc --noEmit clean
./scripts/hooks/lint.sh clean

Three 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 bare max_chunk_tokens all leave chunks off.
  • recall include_chunks requests source chunks and returns them to the agent
  • recall falls back to the client's chunk budget on unusable max_chunk_tokens: 2048, 0, -5, non-numeric.

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
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.

Expose raw source chunks (include.chunks) to agents via the agent_knowledge_recall SDK tool

1 participant