Skip to content

docs(v2): PR 2/7 - Mode migration guide and normalization tests#2019

Closed
jxnl wants to merge 2 commits intofeat/v2-pr1-core-infrastructurefrom
feat/v2-pr2-mode-normalization
Closed

docs(v2): PR 2/7 - Mode migration guide and normalization tests#2019
jxnl wants to merge 2 commits intofeat/v2-pr1-core-infrastructurefrom
feat/v2-pr2-mode-normalization

Conversation

@jxnl
Copy link
Collaborator

@jxnl jxnl commented Jan 18, 2026

Description

This is PR 2 of 7 in the stacked PR series implementing Instructor V2 registry-based architecture.

Base: PR 1 (feat/v2-pr1-core-infrastructure)

Changes

Documentation

  • Mode Migration Guide (docs/concepts/mode-migration.md)
    • Explains legacy mode deprecation (e.g., ANTHROPIC_TOOLS -> TOOLS)
    • Provides migration examples for all providers
    • Documents deprecation timeline (v3.0 removal)
    • Updated mkdocs.yml with navigation link

Tests

  • Mode Normalization Tests (tests/v2/test_mode_normalization.py)
    • Tests normalize_mode() function for all legacy modes
    • Tests deprecation warnings are emitted correctly
    • Tests warnings are shown only once per mode
    • Tests generic modes don't emit warnings
    • Tests DEPRECATED_MODE_MAPPING is complete
    • Handler-dependent tests skip gracefully until providers are added

Testing

uv run pytest tests/v2/test_mode_normalization.py -v

Stacked PRs

  • PR 1: Core infrastructure
  • PR 2 (this): Mode normalization docs + tests
  • PR 3: Anthropic + OpenAI providers
  • PR 4: GenAI + Cohere + Mistral providers
  • PR 5: Remaining providers
  • PR 6: Unified test infrastructure
  • PR 7: Documentation + cleanup

This PR was written by Cursor


Note

Introduces guidance and validation for moving from provider-specific modes to core modes.

  • Adds docs/concepts/mode-migration.md with legacy→core mapping, provider examples (e.g., ANTHROPIC_TOOLSTOOLS), notes on deprecation warnings and v3.0 removal
  • Updates mkdocs.yml to include "Mode Migration" in Concepts navigation
  • Adds tests/v2/test_mode_normalization.py covering normalize_mode() across providers, deprecation warnings (including once-per-mode behavior), no-warn on generic modes, and completeness of DEPRECATED_MODE_MAPPING; handler-dependent tests skip until providers are registered

Written by Cursor Bugbot for commit 370e3cf. Configure here.

@github-actions github-actions bot added documentation Improvements or additions to documentation python Pull requests that update python code size:L This PR changes 100-499 lines, ignoring generated files. labels Jan 18, 2026
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 18, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
instructor 9bb9d7b Commit Preview URL

Branch Preview URL
Jan 18 2026, 06:50 PM

Copy link

@cursor cursor bot left a comment

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 and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


for mode in expected_modes:
if mode in registered_modes:
assert mode_registry.is_registered(provider, mode)
Copy link

Choose a reason for hiding this comment

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

Test assertion is tautological and ineffective

Low Severity

The conditional if mode in registered_modes: followed by assert mode_registry.is_registered(provider, mode) creates a tautology. If a mode exists in registered_modes, then is_registered will inherently return true. This test won't catch missing mode registrations when providers are added in future PRs—it only asserts for modes already registered, silently passing when expected modes are missing.

Fix in Cursor Fix in Web


# Different mode should warn
normalize_mode(provider, Mode.TOOLS_STRICT)
assert len(w) == 2
Copy link

Choose a reason for hiding this comment

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

Test uses wrong provider-mode combinations for Anthropic

Medium Severity

The test_deprecated_mode_warning_only_once test is parameterized with both Provider.OPENAI and Provider.ANTHROPIC, but it only tests Mode.FUNCTIONS and Mode.TOOLS_STRICT which are OpenAI-specific legacy modes. When run with Provider.ANTHROPIC, the test calls normalize_mode(Provider.ANTHROPIC, Mode.FUNCTIONS) which is semantically incorrect. The test should use Anthropic-appropriate modes like ANTHROPIC_TOOLS and ANTHROPIC_JSON when testing with Provider.ANTHROPIC, similar to how test_deprecated_mode_emits_warning correctly pairs providers with their respective modes.

Fix in Cursor Fix in Web

@jxnl jxnl force-pushed the feat/v2-pr1-core-infrastructure branch from 8b77563 to d0a96e2 Compare January 18, 2026 18:41
@jxnl jxnl force-pushed the feat/v2-pr2-mode-normalization branch from 370e3cf to 921fec0 Compare January 18, 2026 18:41
Copy link
Collaborator Author

jxnl commented Jan 18, 2026

- Add docs/concepts/mode-migration.md explaining legacy mode deprecation
- Add tests/v2/test_mode_normalization.py for mode normalization logic
- Update mkdocs.yml with mode migration guide link
- Tests skip gracefully when handlers not yet registered

This PR was written by [Cursor](https://cursor.com)
@jxnl jxnl force-pushed the feat/v2-pr2-mode-normalization branch from 921fec0 to 26e1795 Compare January 18, 2026 18:47
- Fix tautological test assertion to verify handler exists
- Use provider-specific deprecated modes in warning test
@jxnl jxnl closed this Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python Pull requests that update python code size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant