Skip to content

Conversation

Copy link

Copilot AI commented Jan 28, 2026

Thread tokens starting with "thread" followed by letters (e.g., "threading", "threads", "threadsafe") were incorrectly parsed as thread IDs instead of payload tokens.

Changes

  • Validation function: _is_valid_thread_id() enforces thread IDs must start with digit, underscore, or hyphen
  • Decode path: Validates extracted thread IDs before assignment; invalid tokens treated as payload
  • Encode path: Validates thread_id at message creation with clear error messages
  • Documentation: Wire format grammar, SlipMessage docstring, and examples updated

Thread ID Format

Valid (distinguished from English words):

slip("alice", "bob", "RequestReview", thread_id="42")       # thread42
slip("alice", "bob", "RequestReview", thread_id="_task")    # thread_task
slip("alice", "bob", "RequestReview", thread_id="-pr-123")  # thread-pr-123

Invalid (rejected at encode time):

slip("alice", "bob", "RequestReview", thread_id="task42")   # ValueError

Payload tokens correctly handled:

decode("SLIP v1 alice bob RequestReview threading data")
# thread_id=None, payload=["threading", "data"]

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 28, 2026 06:26
- Add validation to ensure extracted thread_id is valid before assignment
- Thread IDs must start with digit, underscore, or hyphen to distinguish from English words
- Prevents payload tokens like "threading", "threads", "threadsafe" from being parsed as thread IDs
- Add comprehensive tests verifying the fix handles edge cases correctly

Co-authored-by: anthony-maio <20600796+anthony-maio@users.noreply.github.com>
- Add validation during encoding to ensure encode/decode symmetry
- Update SlipMessage docstring to document thread_id constraints
- Update protocol module docstring with thread_id format examples
- Fix MessageBuilder example to use valid thread_id format
- Ensure invalid thread_ids are caught at encode time with clear error messages

Co-authored-by: anthony-maio <20600796+anthony-maio@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Address feedback on protocol token handling Fix thread token parsing to prevent misidentifying payload tokens Jan 28, 2026
Copilot AI requested a review from anthony-maio January 28, 2026 06:32
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