Skip to content

Conversation

@jxnl
Copy link
Collaborator

@jxnl jxnl commented Nov 12, 2025

No description provided.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 12, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

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

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
instructor 609f3a9 Nov 12 2025, 05:35 AM

Copy link
Collaborator Author

jxnl commented Nov 12, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added enhancement New feature or request python Pull requests that update python code size:L This PR changes 100-499 lines, ignoring generated files. labels Nov 12, 2025
@jxnl jxnl force-pushed the feat/v2-core-infrastructure branch from 01dd834 to 702eb7c Compare November 12, 2025 05:21
jxnl and others added 11 commits November 12, 2025 00:23
…ng parameter support

- Update v2 core registry & patch to use instructor.core.exceptions (fix import paths)
- Enhance AnthropicToolsHandler to auto-detect thinking parameter
- Add AnthropicReasoningToolsHandler as deprecated wrapper that delegates to TOOLS
- Automatically use auto tool_choice when thinking is enabled (API requirement)
- Handle ThinkingBlock content in parse_response
- Respect user-provided tool_choice parameter (pass through kwargs)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…h thinking parameter

- Add warn_anthropic_reasoning_tools_deprecation() method
- Shows deprecation warning once per session
- Directs users to use Mode.TOOLS with thinking={'type': 'enabled'} instead

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Use instructor.v2.from_anthropic instead of v1 implementation
- Use Mode.TOOLS instead of deprecated Mode.ANTHROPIC_TOOLS
- Remove max_tokens parameter (passes through kwargs if needed)
- Add comprehensive tests for thinking parameter detection
- Test deprecation warning, tool_choice respecting, and reasoning mode

Tests verify:
- ANTHROPIC_REASONING_TOOLS mode registration
- Deprecation warning on mode usage
- TOOLS mode auto-detects thinking parameter
- TOOLS mode uses auto tool_choice when thinking enabled
- TOOLS mode respects user-provided tool_choice
- Mode count updated to 3 (TOOLS, JSON, REASONING_TOOLS)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Replace all Mode.ANTHROPIC_TOOLS with Mode.TOOLS throughout
- Replace Mode.ANTHROPIC_JSON with Mode.JSON
- Replace Mode.ANTHROPIC_PARALLEL_TOOLS with Mode.PARALLEL_TOOLS
- Update all claude-3-5-haiku-latest to claude-4-5-haiku-latest
- Rewrite thinking/extended thinking section with new approach
- Explain automatic mode detection when thinking parameter is used
- Add deprecation notice for Mode.ANTHROPIC_REASONING_TOOLS
- Fix syntax errors in caching examples (missing parenthesis)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…on[...]] response models

- Detect parallel mode automatically when response_model is Iterable[Union[...]]
- Use auto tool_choice for parallel mode (required by API)
- Generate multiple tool schemas from union members
- Update parse_response to handle both single and parallel responses
- Returns single model for regular tools, generator for parallel tools
- No need to explicitly specify Mode.ANTHROPIC_PARALLEL_TOOLS or Mode.PARALLEL_TOOLS

Example:
  response = client.chat.completions.create(
      response_model=Iterable[Weather | GoogleSearch],
      messages=[...]
  )
  for result in response:
      print(result)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Add tests/v2/conftest.py to auto-skip if ANTHROPIC_API_KEY not set
- Create test_anthropic_llm.py with 4 passing LLM tests:
  * Basic TOOLS mode with model injection
  * Async TOOLS mode
  * Parallel tools with auto-detection from Iterable[Union[...]]
  * JSON mode
- Fix auto_client to pass model_name to from_anthropic
- Add default max_tokens=4096 to auto_client (like v1)
- Fix parallel mode handling in v2 handlers:
  * Return proper generator (not relying on v1 parallel wrapper)
  * Extract tool names from union members
  * Validate against correct model class per tool call

Tests now hit real Anthropic API and verify:
- Single tool extraction works
- Parallel tools auto-detected from response model shape
- Mode auto-detects when response is Iterable[Union[...]]

Skipped tests:
- Thinking mode (requires Claude 3.7 Sonnet paid API)
- Async parallel (needs async generator wrapper implementation)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Update parallel tools section to explain auto-detection from Iterable[Union[...]]
- No longer need Mode.PARALLEL_TOOLS - just use Iterable response model
- Add mode auto-detection table showing all combinations:
  * Single tool (forced choice)
  * Thinking mode (auto choice)
  * Parallel tools (auto choice)
  * Parallel + thinking
- Mark Mode.PARALLEL_TOOLS as deprecated
- Clarify Mode.TOOLS is all-in-one solution

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…dling

- Add comprehensive README.md for v2 core architecture detailing registry-based design, exception handling, and component interactions.
- Implement centralized exception handling with new exception classes: RegistryError and ValidationContextError.
- Introduce RegistryValidationMixin for validating mode registration and context parameters.
- Update patch and retry logic to utilize new exception handling mechanisms.

This commit lays the groundwork for the v2 architecture, enhancing modularity and error management.
@jxnl jxnl force-pushed the feat/v2-core-infrastructure branch from 702eb7c to fce90d2 Compare November 12, 2025 05:25
@jxnl jxnl force-pushed the feat/v2-anthropic-provider branch from 9e3f360 to 267282f Compare November 12, 2025 05:25
…pdate tests

- Remove deprecated usage of from_anthropic() in favor of instructor.v2.from_anthropic() with Mode.TOOLS.
- Update AnthropicToolsHandler to streamline request preparation and response parsing.
- Adjust tests to reflect the removal of ANTHROPIC_REASONING_TOOLS and ensure correct mode registration.
- Ensure deprecation warnings are correctly emitted for old usage patterns.

This commit enhances clarity and maintains alignment with the v2 architecture.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request 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.

2 participants