resolve_reference_target tool #97
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PRD: resolve_reference_target
Summary
Implement a deterministic tool that resolves ambiguous user references such as “this”, “that file”, “the last poll”, “the reminder”, “the image above”, or their equivalents in any language, without relying on language-specific hardcoded words. The tool must work primarily from message metadata, recent bot/user actions, object type hints, topic scope, reply chain, and recency scoring. LLM use is out of scope for this tool and should remain an optional higher-level fallback outside the tool.
Goal
Return the most likely referenced object(s) from the current conversational scope so the bot can safely continue a follow-up flow without guessing.
Non-goals
Why
The bot will increasingly support follow-up actions around links, media, polls, reminders, summaries, and other objects. Users will naturally refer to prior objects indirectly. The bot needs a fast, compact, deterministic resolver to avoid hallucinating which object is being discussed.
Supported object kinds
Scope rules
The resolver must search in this priority order:
The resolver must never inspect other chats.
Inputs
The tool should accept a structured request like this conceptually:
Notes on multilingual support
Do not rely on fixed English or Russian tokens like “this” or “that”.
Instead, the caller may pass optional normalized_reference_hints extracted upstream from the user message, for example:
If normalized_reference_hints are missing, the tool must still work using metadata and state only.
State sources
Read only from existing in-memory indexed state and lightweight metadata:
Output
Return either:
Suggested output shape
Each object descriptor should include only compact safe fields:
Resolution algorithm
Recommended scoring features
Reason codes
Examples:
API behavior requirements
Edge cases
Observability
Log compactly:
Do not log raw full user text by default if existing logging policy avoids prompt-sized blobs.
Tests
Must include focused tests for:
Acceptance criteria
Caused by #92 and #95, related to #98