Repository navigation
SDK model tools support scoped code lookup - #908
Merged
Merged
Conversation
Applications can bind indexed code evidence through AgentTools instead of writing a provider-specific dispatcher. An explicit code namespace keeps memory scope separate and leaves the default tool bundle unchanged. The result cap preserves valid JSON, whole evidence and explicit client omissions alongside the SDK request ID and server uncertainty. Signed-off-by: zlareb1 <[email protected]>
Keep the constructor in the form produced by the Markdown code formatter so the SDK example passes the repository format gate. Signed-off-by: zlareb1 <[email protected]>
8 of 9 tasks
zlareb1
added a commit
that referenced
this pull request
Nov 18, 2026
Related: #908 ### Changelog category (leave one): - Bug Fix (user-visible misbehavior in a release) ### Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes): SDK memory tools preserve persistence receipts, conflicts, recall abstention and source trust metadata. Python memory writes accept explicit file references for code-linked facts. ### Why A merged fact can return an existing memory ID while writing no row at the requested key. The model tool reported `stored: true` and dropped the canonical key and no-op fields. Recall dropped code freshness, row status, provenance and attestation fields, leaving the model unable to distinguish a changed or unverified claim from a current one. The tools retain the server's evidence and keep memory results valid JSON under the result budget. Governed-definition authority and term-leg status remain visible alongside retrieval scores that apply only to ordinary hits. A result that cannot carry its metadata says so instead of returning a partial receipt. ### Scope and risk Python and TypeScript memory-tool result projections, their descriptions, the Python `MemoryClient.set` file-reference argument, documentation and focused tests. Tool names and input schemas are unchanged. File and repository association use the direct SDK path; enabling code lookup does not select a repository for memory writes. Consumers parsing exact result objects receive additional receipt and trust fields. A memory too large to fit is omitted whole, including the first result. An unreportable memory-result budget fails before sending the request. ### Compatibility, rollout and rollback - Wire: no operation, wire field or server default changes. `MemoryClient.set(files=...)` exposes the existing wire field; `[]` clears prior references. The public Python API snapshot is regenerated. - Operator steps: none. Code linking remains asynchronous and uses the configured code namespace or an explicit matching repository tag. - Rollback: reverting restores SDK projections and the Python method signature. No stored data or schema changes require reversal. ### Tests - Fourteen Python and twelve TypeScript regression cases fail before the fix. They cover persisted writes, canonical no-op merges, duplicate rows, conflicts, stale code, unverified sources, abstention, oversized results and explicit file references. Two additional budget controls per SDK confirm refusal before a request. - Governed-definition controls fail in both SDKs before the field fix. Mixed governed and weak ordinary hits retain their separate authority, scores and original abstention verdict; an ordinary-only neighbor retains abstention. - The current selected Python gate passes 33 cases: eighteen receipt/trust cases, fourteen existing session/tools cases and the public API snapshot. README link and source-copy checks passed on the first head; CI rechecks the final head. - The selected TypeScript tool files pass 23 cases using a cached test runner one patch below the SDK lock. This is a diagnostic result; exact-lock tests and packaging remain CI requirements. The matching compiler passes the changed module and tests, with cached type declarations one patch above the lock. - Framework-adapter fixtures use persisted write receipts and exact bounded JSON omission checks. Their optional dependencies are absent locally, so those modules remain unrun locally and must pass CI. - Strict Python typing, changed-file Ruff, function-length ratchets, exact-version TypeScript formatting, Markdown formatting and whitespace checks pass. - The 17 sender-provenance census checks pass after reviewing explicit file references on the existing memory write path and renewing only its source fingerprint. - Full format, lint, type, package and unit checks run in CI. No provider evaluation is part of this change. ### AI assistance in the code (leave one; writing this description with AI is fine): - AI-generated: Codex wrote the change and checked wire models, both SDK implementations, focused regressions and result budgets. - [x] I can explain every line of this diff and how it interacts with the rest of Loom. ### Checklist - [ ] `make format-check`, `make lint`, `make typecheck` and `make test-unit` pass; the integration suite passes if server behaviour changed. - [x] The Python public API snapshot is regenerated. Wire, setting, schema and plugin generators are unaffected. - [x] No migrations. - [x] No plugin files or versions change. - [x] No frontend changes. - [x] Documentation describes current SDK behavior and names operator and wire changes. - [x] Repository text carries no private deployment details. - [x] Commits are signed off. Signed-off-by: zlareb1 <[email protected]>
Combine scoped code lookup with the current SDK receipt and file-reference behavior. Keep current account and transport changes. Signed-off-by: zlareb1 <[email protected]>
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.
Related: #911
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
Python and TypeScript model tools can opt in to scoped code lookup for definitions, conceptual search, callers and prospective impact. Code results preserve request IDs and valid JSON within the application's character budget, with explicit evidence omissions.
Why
Applications using
AgentToolsneed indexed code evidence alongside memory without writing their own schemas, scope binding and dispatcher. One read-only tool reuses the provider formats and the SDK metadata transport. An explicit code namespace keeps code and memory scope distinct; the model cannot supply tenant fields, wire operations or budgets.Keeping code lookup opt-in preserves the default memory tools and their order. Offering separate provider-specific bindings would duplicate scope and argument checks. Runtime routing or forced calls would spend on unrelated requests and replace the model's tool choice.
Scope and risk
Adds
code_namespace/codeNamespacetoAgentToolsand oneloom_code_lookupdefinition withkind,targetand optional boundeddepth. Code lookup leads the enabled bundle; explicitly selecting it without a namespace fails during construction. Named requests accept compact qualified references orpath:line; conceptual prose uses search.Requests use existing read-only operations and application-owned scope. Authorization errors propagate without changing namespaces. Symbol bodies retain the canonical 2500-token request budget; search and graph requests have fixed result bounds. Oversized responses elide whole bodies and rows while preserving uncertainty and citations. If metadata cannot fit, the result explicitly reports client-budget insufficiency instead of partial JSON or an exactness claim.
Includes matching SDK examples, a usage guide, scope and budget tests, and the intended API snapshot change. No server behavior, memory-tool result behavior or stored data changes. Model adoption, task success, time and token savings remain unmeasured for this helper.
Compatibility, rollout and rollback
Tests
The focused results below apply to the code-tool source before this forward composition. This head combines it with the existing memory receipt, trust metadata and file-reference behavior. The code dispatch returns before the memory-result formatter; remember and recall retain their refusal before dispatch when the result budget cannot report omissions.
python -m pytest tests/unit/test_sdk_code_tools.py tests/unit/test_sdk_session_tools.py -q: 36 passed, including default-tool behavior, fixed scope, rejected model injection, actual mocked SDK metadata calls, authorization refusal and whole-evidence budgets.npm --prefix sdk/typescript test -- src/code-tools.test.ts src/tools.test.ts --typecheck.enabled false: 29 passed.code_namespacekeyword.--help, formatting, prose, documentation generation and the function-length gate passed.Full CI passes on this composed head: 43 successful checks, two conditional publication skips and all four workflows successful, including exact-lock TypeScript tests, type checks and packaging. The selected local composition checks have not run. The earlier unit-part-6 cost assertion remains a recorded failure with an unresolved cause; a new pass qualifies this composition without explaining that failure.
AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Codex. Checked the scope boundaries, wire request shapes, error propagation, default-tool behavior, result budgets and focused validation listed above.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
docs/describe the system as it now is, and this description names operator steps and wire changes.git commit -s), as CONTRIBUTING.md asks.