Disable DeepSeek thinking when a tool is forced.
Auto-resolve of passives was 400ing because thinking mode cannot be combined with named tool_choice. Also strip BOM descriptions after an em dash before DigiKey search. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -39,8 +39,8 @@ def test_mpn_catalog_match_orderable_suffix():
|
||||
def test_mpn_query_variants_underscore_and_reel():
|
||||
variants = mpn_query_variants("25AA1024-I_SM")
|
||||
assert "25AA1024-I/SM" in variants
|
||||
variants = mpn_query_variants("ADAU1467WBCPZ300R")
|
||||
assert "ADAU1467WBCPZ300" in variants
|
||||
variants = mpn_query_variants("RC0805FR-0733RL — 33 Ω — 1% — 0805")
|
||||
assert "RC0805FR-0733RL" in variants
|
||||
|
||||
|
||||
def test_pick_lcsc_family_orderable():
|
||||
|
||||
@@ -95,6 +95,49 @@ def test_messages_to_openai_tool_roundtrip():
|
||||
assert out[2]["role"] == "user"
|
||||
|
||||
|
||||
def test_forced_tool_choice_disables_thinking():
|
||||
captured: dict = {}
|
||||
|
||||
class FakeCompletions:
|
||||
async def create(self, **kwargs):
|
||||
captured.update(kwargs)
|
||||
fn = SimpleNamespace(name="save_resolved_specs", arguments="{}")
|
||||
tc = SimpleNamespace(id="c1", function=fn)
|
||||
msg = SimpleNamespace(content=None, reasoning_content=None, tool_calls=[tc])
|
||||
usage = SimpleNamespace(
|
||||
prompt_tokens=10, completion_tokens=5,
|
||||
prompt_cache_hit_tokens=0, prompt_tokens_details=None,
|
||||
)
|
||||
return SimpleNamespace(
|
||||
choices=[SimpleNamespace(message=msg, finish_reason="tool_calls")],
|
||||
usage=usage,
|
||||
)
|
||||
|
||||
class FakeClient:
|
||||
def __init__(self):
|
||||
self.chat = SimpleNamespace(completions=FakeCompletions())
|
||||
|
||||
from backend.services.llm.deepseek_provider import DeepSeekSession
|
||||
session = DeepSeekSession(
|
||||
client=FakeClient(),
|
||||
model="deepseek-v4-flash",
|
||||
system="sys",
|
||||
max_tokens=256,
|
||||
thinking=True,
|
||||
reasoning_effort="medium",
|
||||
)
|
||||
import asyncio
|
||||
from backend.services.llm.types import Message, TextBlock, ToolSchema
|
||||
asyncio.run(session.complete(
|
||||
messages=[Message("user", [TextBlock("resolve")])],
|
||||
tools=[ToolSchema(name="save_resolved_specs", description="x", input_schema={"type": "object"})],
|
||||
tool_choice={"name": "save_resolved_specs"},
|
||||
))
|
||||
assert captured["extra_body"]["thinking"]["type"] == "disabled"
|
||||
assert "reasoning_effort" not in captured["extra_body"]
|
||||
assert captured["tool_choice"]["function"]["name"] == "save_resolved_specs"
|
||||
|
||||
|
||||
def test_tool_schema_and_choice():
|
||||
schema = ToolSchema(
|
||||
name="save_pintable",
|
||||
|
||||
Reference in New Issue
Block a user