Skip to content

fix(anthropic): omit unsupported temperature parameters - #210

Open
kecheng-lai wants to merge 1 commit into
lemony-ai:mainfrom
kecheng-lai:fix/anthropic-temperature-capabilities
Open

kecheng-lai wants to merge 1 commit into
lemony-ai:mainfrom
kecheng-lai:fix/anthropic-temperature-capabilities

Conversation

@kecheng-lai

Copy link
Copy Markdown

🎯 Description

Omit temperature for the Anthropic models listed in #209 that reject non-default sampling parameters. Add a model capability flag and apply it to Python completions, tool calls and streams, and TypeScript SDK/fetch generation and streams. Preserve configured temperatures (including zero) for older and unknown models.

🔗 Related Issues

Fixes #209.

🔄 Type of Change

  • Bug fix
  • Test additions/improvements
  • Tool calling / function support

🧪 Testing

  • Added 108 Python HTTP-boundary cases and 24 TypeScript cases covering SDK/fetch, generation/streaming, default/explicit temperatures and model-name variants.
  • Python focused provider/reasoning/retry tests: 200 passed, 1 skipped.
  • TypeScript core suite: 1135 passed, 21 skipped.
  • Python full-suite result: 1339 passed, 41 skipped, 59 deselected, 1 failed. The failure is test_alignment_parity[cases0]: Windows raises WinError 193 when it directly executes the extensionless node_modules/.bin/tsx script. The identical failure was reproduced from an unmodified 280ac97 archive using the same interpreter and node_modules.
  • Black and Ruff pass across cascadeflow, tests, and examples; mypy passes across 166 source files (with an existing Python-version configuration warning).
  • TypeScript ml/core builds, core typecheck and lint pass (lint reports existing warnings).
  • Inverting the new capability flag in memory makes the Python regression fail as expected.
  • No live provider calls. Tests inspect outgoing payloads against local simulated responses; coverage percentage changes were not separately measured.
pytest tests/test_anthropic.py tests/test_anthropic_temperature.py tests/test_reasoning_models.py tests/test_provider_tool_retry.py --no-cov
pytest tests/ -m "not integration and not requires_api and not requires_ollama and not requires_vllm"
pnpm --filter @cascadeflow/core test
pnpm --filter @cascadeflow/ml build
pnpm --filter @cascadeflow/core build
pnpm --filter @cascadeflow/core typecheck
pnpm --filter @cascadeflow/core lint
black --check cascadeflow tests examples
ruff check cascadeflow tests examples
mypy cascadeflow --ignore-missing-imports

📸 Screenshots/Examples (if applicable)

For claude-opus-4-7, the default request previously included "temperature": 0.7; it now omits the field. A local endpoint rejecting that field returns the expected completion after the fix. claude-opus-4-6 retains its default/custom temperature, including 0.

📋 Checklist

  • Focused change, reviewed implementation and regression tests
  • Formatting, lint and type checks run
  • Regression tests added and run before/after the fix
  • No new dependencies
  • All tests pass locally (see existing Windows baseline failure above)
  • Live provider testing

💥 Breaking Changes (if any)

Explicit temperature settings are omitted for the affected models, as required by their sampling restriction. Existing temperature behavior is preserved for the older/unknown models tested. Public method signatures are unchanged; capability metadata gains an optional TypeScript field and a defaulted Python constructor argument.

📊 Performance Impact (if applicable)

Only a short model-prefix capability check is added. No performance benchmark was run.

🔐 Security Considerations

No credentials or sensitive data are included, and no new external requests are introduced. Regression tests use dummy keys and simulated responses.

🚀 Deployment Notes (if applicable)

No dependency, environment variable or database changes.

📝 Additional Notes

Implementation, tests and this description were prepared with an AI coding assistant. The model restriction list follows #209 and its linked Anthropic documentation. This patch does not change verifier-error fallback behavior or other sampling parameters supplied through extra kwargs.

🙏 Reviewers

Maintainer review and CI are pending.


By submitting this PR, I confirm that:

  • I have read and followed CONTRIBUTING.md
  • AI assistance is disclosed above
  • The contribution is offered under the project's MIT license
  • The verification performed and its limitations are documented

This branch has not been deployed

No deployments
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.

[Bug]: Default temperature 0.7 gets a 400 on Claude Opus 4.7+ and Claude 5

1 participant