Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d0a96e2
feat(v2): implement core infrastructure with registry-based architecture
jxnl Jan 18, 2026
64b7a3e
fix(v2): address PR review comments
jxnl Jan 18, 2026
26e1795
docs(v2): add mode migration guide and normalization tests
jxnl Jan 18, 2026
9bb9d7b
fix(v2): address PR review comments
jxnl Jan 18, 2026
26bcb47
feat(v2): add Anthropic and OpenAI providers
jxnl Jan 18, 2026
bfac9c8
fix(v2): address PR review comments
jxnl Jan 18, 2026
9e715eb
feat(v2): add GenAI, Cohere, and Mistral providers
jxnl Jan 18, 2026
bf8f011
fix(v2): address PR review comments
jxnl Jan 18, 2026
d2ef4cc
feat(v2): add remaining providers (xAI, Groq, Fireworks, Cerebras, Wr…
jxnl Jan 18, 2026
0134fcd
fix(v2): address PR review comments
jxnl Jan 18, 2026
f6feed5
refactor(tests): reorganize tests and add unified test infrastructure
jxnl Jan 18, 2026
09cfa9a
fix(v2): skip deprecation warning test until implemented
jxnl Jan 18, 2026
bdb8f3a
docs(v2): documentation updates and cleanup
jxnl Jan 18, 2026
8ebb42e
fix(v2): remove debug logging in iterable.py
jxnl Jan 18, 2026
5cf915b
fix(tests): sort providers for deterministic pytest-xdist ordering
jxnl Jan 18, 2026
90a7002
fix(v2): remove remaining debug logging in OpenAI handlers
jxnl Jan 18, 2026
742644f
feat(v2): unify mode registry and add protocol support
jxnl Jan 18, 2026
21b823f
Fix v2 provider handling and compatibility
jxnl Jan 19, 2026
c30854f
fix(processing): align streaming + improve schema errors
cursoragent Jan 22, 2026
dc7994d
docs: gate example execution and format code blocks (#2028)
jxnl Jan 24, 2026
e7ec94e
merge(main): sync main into feat/pr7-unify-mode-registry
jxnl Jan 24, 2026
0ea6752
refactor(v2): parameterize handlers for groq, fireworks, cerebras
jxnl Jan 24, 2026
ec94cf9
refactor(v2): drop deprecated modes
jxnl Jan 24, 2026
040db2d
fix: normalize deprecated modes for v2 registry
jxnl Jan 24, 2026
8bab6e5
chore: format response streaming handlers
jxnl Jan 24, 2026
efd6c14
feat(v2): switch from_provider to v2 preview
jxnl Jan 24, 2026
1c1a22e
docs: add citation section to navigation in mkdocs.yml
jxnl Jan 24, 2026
e3e53be
refactor: deprecate legacy parsing methods in ResponseSchema
jxnl Jan 24, 2026
b2dad92
Merge remote-tracking branch 'origin/main' into feat/pr7-unify-mode-r…
jxnl Jan 26, 2026
c69496e
refactor: remove old provider implementations and process_response mo…
jxnl Jan 26, 2026
e29437d
refactor(core): unify mode registry and update core modules
jxnl Jan 26, 2026
c514136
feat(v2): add provider utils modules for unified mode registry
jxnl Jan 26, 2026
de53c92
refactor(v2): update handlers and core to use unified mode registry
jxnl Jan 26, 2026
c618bd0
test: update tests for unified mode registry refactoring
jxnl Jan 26, 2026
92d8fe9
docs: update migration and from_provider documentation
jxnl Jan 26, 2026
c39f24b
docs(v2): clarify v1 provider locations (#2040)
jxnl Jan 26, 2026
0b2851e
refactor(providers): add missing providers, centralize URL detection,…
jxnl Jan 26, 2026
2397ed6
refactor(v2): inline provider utils into handlers
jxnl Jan 26, 2026
0a65bcd
chore: remove docs and examples from runtime PR
jxnl Feb 6, 2026
c8689a0
Merge remote-tracking branch 'origin/main' into codex/pr7-runtime-only
jxnl Feb 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .cursor/rules/followups.mdc

This file was deleted.

45 changes: 0 additions & 45 deletions .cursor/rules/new-features-planning.mdc

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/scheduled-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ jobs:

- name: Run type checking
run: |
uv run pyright
uv run ty check instructor/
uv run ty check --config-file ty-tests.toml tests

- name: Run core tests (no LLM)
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}

# Core provider tests for OpenAI
core-openai:
Expand Down
Binary file added .instructor_cache/cache.db
Binary file not shown.
67 changes: 57 additions & 10 deletions AGENT.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# AGENT.md

## Commands
- Install: `uv pip install -e ".[dev]"` or `poetry install --with dev`

- Install: `uv sync --all-extras --group dev` or `uv pip install -e ".[dev]"` or `poetry install --with dev`
- Run tests: `uv run pytest tests/`
- Run single test: `uv run pytest tests/path_to_test.py::test_name`
- Skip LLM tests: `uv run pytest tests/ -k 'not llm and not openai'`
Expand All @@ -12,22 +13,66 @@
- Build docs: `uv run mkdocs serve` (local) or `./build_mkdocs.sh` (production)
- Waiting: use `sleep <seconds>` for explicit pauses (e.g., CI waits) or to let external processes finish

## Documentation Examples and Doc Tests

All code examples in documentation must be executable and pass doc tests. The `pytest-examples` plugin validates that examples run correctly and match expected output.

### Doc Test Requirements

- All code examples in documentation must be executable
- Examples must pass when run via pytest doc tests
- Examples should include print statements with expected output (using `#>` prefix)

### Writing Doc Examples

- **Self-contained blocks**: Each code block runs isolated, so shared variables like `client` and `logger` must be defined within each block or skipped. Making all blocks self-contained is essential to avoid test failures.
- **Valid Python syntax**: Invalid Python code (like ellipsis `...` after keyword arguments) causes syntax errors and must be fixed by removing or replacing placeholders.
- **Skip problematic examples**: If an example cannot be made executable, consider using skip markers (verify pytest-examples support) or exclude the file from testing (see `test_examples.py` exclusions).

### Running Doc Tests

- **Standard check**: `uv run pytest tests/docs/` (lints and runs examples)
- **Update mode**: `uv run pytest tests/docs/ --update-examples` (formats code and updates expected output/logs)
- **Warning**: `--update-examples` modifies files in place

### What Doc Tests Do

- Format code examples using ruff
- Run examples to verify they execute correctly
- Check that printed output matches expected results
- Update examples in-place when using `--update-examples`

### Doc Test Files

Doc test files are located in `tests/docs/`:

- **test_examples.py**: Tests examples in `docs/examples/*.md` (formats and runs/updates print output)
- **test_concepts.py**: Tests examples in `docs/concepts/` (formats, runs, and updates print output)
- **test_docs.py**: Tests examples in `README.md` and `docs/index.md` (formats only, no execution)
- **test_posts.py**: Tests examples in `docs/blog/posts/` (formats and runs/updates print output)

Always run doc tests before submitting documentation changes to ensure examples remain executable and up-to-date.

## Architecture

- **Core**: `instructor/` - Pydantic-based structured outputs for LLMs
- **Base classes**: `Instructor` and `AsyncInstructor` in `client.py`
- **Providers**: Client files (`client_*.py`) for OpenAI, Anthropic, Gemini, Cohere, etc.
- **Factory pattern**: `from_provider()` for automatic provider detection
- **Base classes**: `Instructor` and `AsyncInstructor` in `core/client.py`
- **Providers**: Provider implementations in `providers/` directory (v1) and `v2/providers/` directory (v2)
- Each provider has a `client.py` with factory functions (e.g., `from_openai`, `from_anthropic`)
- V2 providers also have `handlers.py` for mode-specific response handling
- **Factory pattern**: `from_provider()` in `auto_client.py` for automatic provider detection (recommended)
- **DSL**: `dsl/` directory with Partial, Iterable, Maybe, Citation extensions
- **Key modules**: `patch.py` (patching), `process_response.py` (parsing), `function_calls.py` (schemas)

## Code Style

- **Typing**: Strict type annotations, use `BaseModel` for structured outputs
- **Imports**: Standard lib → third-party → local
- **Formatting**: Ruff with Black conventions
- **Error handling**: Custom exceptions from `exceptions.py`, Pydantic validation
- **Naming**: `snake_case` functions/variables, `PascalCase` classes
- **No mocking**: Tests use real API calls
- **Client creation**: Always use `instructor.from_provider("provider_name/model_name")` instead of provider-specific methods like `from_openai()`, `from_anthropic()`, etc.
- **Testing**: Most tests use real API calls; unit tests for handlers may use mocks for isolated testing
- **Client creation**: Prefer `instructor.from_provider("provider_name/model_name")` for new code; provider-specific methods like `from_openai()`, `from_anthropic()` are still available for direct client control

## Pull Request (PR) Formatting

Expand All @@ -40,19 +85,22 @@ Use:
`<type>(<scope>): <short summary>`

Rules:

- Keep it under ~70 characters when you can.
- Use the imperative mood (for example, add”, “fix”, “update).
- Use the imperative mood (for example, "add", "fix", "update").
- Do not end with a period.
- If it includes a breaking change, add `!` after the type or scope (for example, `feat(api)!:`).

Good examples:

- `fix(openai): handle empty tool_calls in streaming`
- `feat(retry): add backoff for JSON parse failures`
- `docs(agents): add conventional commit PR title guidelines`
- `test(schema): cover nested union edge cases`
- `ci(ruff): enforce formatting in pre-commit`

Common types:

- `feat`: new feature
- `fix`: bug fix
- `docs`: documentation-only changes
Expand All @@ -64,17 +112,16 @@ Common types:
- `chore`: maintenance work

Suggested scopes (pick the closest match):

- Providers: `openai`, `anthropic`, `gemini`, `vertexai`, `bedrock`, `mistral`, `groq`, `writer`
- Core: `core`, `patch`, `process_response`, `function_calls`, `retry`, `dsl`
- Repo: `docs`, `examples`, `tests`, `ci`, `build`

### PR Description Guidelines

Keep PR descriptions short and easy to review:

- **What**: What changed, in 1–3 sentences.
- **Why**: Why this change is needed (link issues when possible).
- **Changes**: 3–7 bullet points with the main edits.
- **Testing**: What you ran (or why you did not run anything).

If the PR was authored by Cursor, include:
- `This PR was written by [Cursor](https://cursor.com)`
Loading
Loading