Skip to content

Coding grep excerpts offer an edit-context lookup - #1507

Merged
zlareb1 merged 3 commits into
mainfrom
fix/grep-edit-context-continuation
Nov 26, 2026
Merged

zlareb1 merged 3 commits into
mainfrom
fix/grep-edit-context-continuation

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Changelog category

  • Improvement

Changelog entry

Coding grep results with short excerpts of Python function declarations can suggest one edit-context lookup for the matching definitions and relevant tests.

Why

A coding caller that requests brief grep context often needs the surrounding implementations before editing. Edit context reads named source and test examples together. The grep description directs editing calls to the default enclosing bodies.

Scope and risk

The suggestion uses the same source locations and scope as the grep result. It checks the matched Python function name against the indexed scope and validates the complete named batch. Each eligible response also supplies the exact ranges to read when a symbol is missing. Both suggestions honor the caller’s lesson options and the resolved tool catalog.

Compatibility, rollout and rollback

  • The reply carries exact ranges in next and the optional native context call in edit_context_next.
  • The change takes effect with the server update. Rolling back restores the previous suggestion. Operator steps are unnecessary.

Tests

  • Replayed two recorded literal queries. The coding suggestions use the exact four or six declaration locations and preserve the result evidence. Both replies preserve the exact-range arguments.
  • Executed the four-location suggestion against a private index. All four source bodies matched the pinned checkout, and the response included relevant public nested registration tests.
  • Checked the coding catalog at 9,092 estimated tokens for standard and 6,052 for compact, within the listing bound.
  • make format-check lint typecheck passed. Added cases for inherited and combined tool catalogs, Python declaration lines, decorators, complete batches, lesson options and the advertised defaults.

AI assistance in the code

  • AI-generated with Codex. Verified the actual replay, catalog bounds and diff.
  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused replay pass.
  • Generated files pass their checks.
  • Commits are signed off.

Note

Low Risk
Additive MCP response fields with strict eligibility checks; no auth or persistence changes.

Overview
Extends lean code.grep excerpts (include_body: false) so coding toolsets can suggest a follow-up edit_context_next step (native loom_code_edit_context with path:line names) when every unmatched hit is a validated Python def/async def declaration on its scope span, the batch fits EDIT_CONTEXT_MAX_NAMES, and that tool is listed for the toolset. The existing next loom_code_read batch is unchanged and still carries org/namespace plus lesson options.

lean_code now takes a followups set; lean_results populates it from loom_code_read and loom_code_edit_context intersected with the resolved MCP catalog. Non-declaration hits (e.g. decorators), oversized batches, or toolsets without edit context keep read-only suggestions.

MCP code.grep descriptions are reworded to emphasize default bodies for edits and excerpts via include_body: false.

Reviewed by Cursor Bugbot for commit 65f11fc. Bugbot is set up for automated code reviews on this repo. Configure here.

A known declaration location can return retained code and test examples in one lookup. Paths outside the edit-context location grammar keep the exact range suggestion.

Signed-off-by: Lareb Zafar <[email protected]>
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Nov 26, 2026 12:44am UTC
loom-telemetry Ready Ready Preview Nov 26, 2026 12:44am UTC

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6edef4b. Configure here.

Comment thread server/transport/lean_results.py Resolved
Use the resolved tool catalog and keep exact ranges when the named batch would change the source coverage.

Signed-off-by: Lareb Zafar <[email protected]>
An indexed grep span can survive a missing symbol row. Offer the exact source read with the same lesson options.

Signed-off-by: Lareb Zafar <[email protected]>
@zlareb1
zlareb1 merged commit a77fe7d into main Nov 26, 2026
75 of 76 checks passed
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.

1 participant