feat(context): abbreviate UUID observation refs to 8-char in inject panel#2867
feat(context): abbreviate UUID observation refs to 8-char in inject panel#2867alessandropcostabr wants to merge 1 commit into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Greptile SummaryThis PR adds opt-in UUID abbreviation for observation refs in the inject panel: when
Confidence Score: 4/5Safe to merge for standard SQLite setups; server-beta activation carries two unresolved contradictions that should be fixed before enabling the flag in production. The core helper and legend wiring are correct, but renderAgentFooter still tells the model to call get_observations([IDs]) even when the legend has already told it those refs are display-only — a direct in-panel contradiction for any caller that sets fetchByIdSupported: false. Additionally, Observation.id is typed as number while UUID strings will flow through it at runtime in server-beta mode, masking a type error that TypeScript cannot catch. src/services/context/formatters/AgentFormatter.ts (renderAgentFooter not updated) and src/services/context/types.ts (Observation.id still number) Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[renderHeader / table row] --> B{forHuman?}
B -- No --> C[Agent path]
B -- Yes --> D[Human path]
C --> C1[renderAgentLegend\nfetchByIdSupported]
C --> C2[renderAgentTableRow\nobs, time, config]
C --> C3[renderAgentFullObservation\nobs, time, detail, config]
D --> D1[renderHumanContextIndex\nfetchByIdSupported]
D --> D2[renderHumanTableRow\nobs, time, config]
D --> D3[renderHumanFullObservation\nobs, time, detail, config]
C1 --> E{fetchByIdSupported?}
D1 --> E
E -- true / default --> F["Show full ID\nLegend: get_observations([IDs])"]
E -- false --> G["Abbreviate UUID to 8-char\nLegend: mem-search by title/context"]
C2 & C3 & D2 & D3 --> H[formatContextReferenceId\nid, config]
H --> I{fetchByIdSupported === false\nAND UUID?}
I -- Yes --> J[id.slice 0 to 8]
I -- No --> K[String id unchanged]
C --> L[renderAgentFooter ⚠️\nNOT wired to fetchByIdSupported\nstill says get_observations IDs]
Reviews (2): Last reviewed commit: "feat(context): abbreviate UUID observati..." | Re-trigger Greptile |
…anel Full UUIDs are the worst case for the tokenizer in the inject panel — the hex + hyphen pattern fragments into ~17 tokens per ref for no practical gain. When fetch-by-id is unsupported (server-beta / Postgres UUID mode, where the inject ref isn't a fetch handle), abbreviate observation refs to their 8-char prefix and switch the legend to point at title/semantic search instead of get_observations([IDs]). These short refs are display-only — the full UUID still lives in search results where tokens aren't the bottleneck. Gated by a new optional ContextConfig.fetchByIdSupported (defaults to true → no behavior change; numeric SQLite ids are never abbreviated). Set it false in the server-beta context build to enable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
e062d4e to
ad300ad
Compare
Why
Full UUID observation refs are the worst case for the tokenizer in the inject panel — the hex + hyphen pattern fragments into ~17 tokens per ref, for no practical gain (the model retrieves by title/semantic search, not by pasting the ref). This came up on Discord re: server-beta where ids are Postgres UUIDs.
What
When fetch-by-id is unsupported — i.e. server-beta / Postgres UUID mode, where the inject ref isn't a fetch handle — observation refs are abbreviated to their 8-char prefix (
3c4b2513-…→3c4b2513), and the legend switches fromget_observations([IDs])to "mem-search by title/context (short refs are display-only)". The full UUID still lives inobservation_searchresults, where tokens aren't the bottleneck.Gated by a new optional
ContextConfig.fetchByIdSupported:true→ no behavior change for existing setups.falsein the server-beta context build to enable the short refs.Small helper
formatContextReferenceId(id, config)informatters/id-display.ts; wired into the Agent/Human formatters andHeaderRenderer.Notes
bun test tests/context/formatters/agent-formatter.test.ts→ 46 pass / 0 fail (added 6 tests: legend toggle + helper behavior).tsc --noEmitclean for the touched files.🤖 Co-authored with Claude Code