Skip to content

fix(v2): synthesize stable part identity so text references reach the jump pipeline - #524

Merged
sudo-tee merged 4 commits into
sudo-tee:mainfrom
jensenojs:fix/v2-text-part-id
Oct 16, 2026
Merged

sudo-tee merged 4 commits into
sudo-tee:mainfrom
jensenojs:fix/v2-text-part-id

Conversation

@jensenojs

@jensenojs jensenojs commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Files mentioned in assistant text never reach the <CR> jump pipeline; tool-edited files work. Silent on V2. (#523)

Why

V2 carries no part id — events are {assistantMessageID, ordinal, text}, verified on 2.0.28. Consumers required part.id, so text parts were skipped forever. Tool parts carry a real id, which masked the gap.

             V2 (no ids anywhere)              consumers
                                               (no id guards)
  event stream ─┐
                ├─► adapter: assign             reference_facts
  snapshot     ─┘   id = encode({message,   ──      │
                     kind, coordinate})             ▼
                                                 formatter
  text      → (msg, "text", ordinal)                │
  reasoning → (msg, "reasoning", ordinal)           ▼
  tool      → (msg, "tool", rawID)              <CR> jump
  user file → (msg, "file", index)              pipeline

  before: text died at "requires part.id" — tool had an id, masking it

Fix

One owner, one encoding, in the adapter. Snapshot path counts per-kind ordinals so both paths produce identical ids. Consumer id guards deleted.

Verification

Full ./run_tests.sh green; tests cover event/snapshot id equality, cross-path handoff, shared raw tool ids. Adversarially audited (3 rounds, coordinate-collision fuzzing).

@jensenojs

Copy link
Copy Markdown
Collaborator Author

@wzj-zz

V2 events carry no part id, so text parts were silently dropped. Trying that branch would help; covers both file paths and symbols. (I feel that symbol jumping is more commonly used than file jumping though it certainly has a lot of room for optimization)

If symbol jumps still fail (your "only local.scope" case): enable logging (require('opencode').setup({ logging = { enabled = true, level = 'debug' } })) so that agent can figure out what's happening more easily

@jensenojs
jensenojs force-pushed the fix/v2-text-part-id branch from 5f547a6 to c331151 Compare October 15, 2026 08:12
@jensenojs
jensenojs marked this pull request as ready for review October 15, 2026 11:23
Comment thread lua/opencode/protocols/v2/observation/messages.lua Outdated
@jensenojs

Copy link
Copy Markdown
Collaborator Author

One thing I've noticed is that the accuracy of symbol jumping is very low when I'm looking at some Python projects.

So far it's tolerable, but when I have free time, I might want to think about how to improve this search strategy using recipes.

@sudo-tee

Copy link
Copy Markdown
Owner

Thanks for the PR. It works fine for me :)

@sudo-tee
sudo-tee merged commit 61ebec9 into sudo-tee:main Oct 16, 2026
7 checks passed
@jensenojs
jensenojs deleted the fix/v2-text-part-id branch October 18, 2026 14:52
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.

2 participants