A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: disable thinking for inline autocomplete (#10890)
Shahmir Varqhab3c010464fb9
diff --git a/marimo/_server/ai/providers.py b/marimo/_server/ai/providers.pyindex 01bd0924c5..e6ddcb85ed 100644--- a/marimo/_server/ai/providers.py+++ b/marimo/_server/ai/providers.py@@ -407,6 +407,7 @@ class PydanticProvider(ABC, Generic[ProviderT_co]):additional_tools: list[ToolDefinition],span_info: SpanInfo,enable_capabilities: bool = True,+ thinking: ThinkingLevel | None = None,) -> str:"""Return a string response from the given messages."""@@ -428,6 +429,9 @@ class PydanticProvider(ABC, Generic[ProviderT_co]):result = await agent.run(user_prompt=None,message_history=VercelAIAdapter.load_messages(messages),+ model_settings={"thinking": thinking}+ if thinking is not None+ else None,)return str(result.output)diff --git a/marimo/_server/api/endpoints/ai.py b/marimo/_server/api/endpoints/ai.pyindex 7d4c96c60d..1ed4241398 100644--- a/marimo/_server/api/endpoints/ai.py+++ b/marimo/_server/api/endpoints/ai.py@@ -345,6 +345,7 @@ async def ai_inline_completion(messages=[create_simple_prompt(prompt)],system_prompt=system_prompt,max_tokens=INLINE_COMPLETION_MAX_TOKENS,+ thinking=False,additional_tools=[],enable_capabilities=False,span_info=SpanInfo(diff --git a/tests/_server/ai/test_providers.py b/tests/_server/ai/test_providers.pyindex 2988171c52..a9f79bfa6d 100644--- a/tests/_server/ai/test_providers.py+++ b/tests/_server/ai/test_providers.py@@ -860,6 +860,42 @@ async def test_completion_does_not_pass_redundant_instructions() -> None:assert instructions == "Test prompt"[email protected]("pydantic_ai")[email protected]("thinking", [None, False])+async def test_completion_thinking_override(thinking: bool | None) -> None:+ from pydantic_ai.messages import ModelResponse, TextPart+ from pydantic_ai.models.openai import OpenAIResponsesModel++ config = AnyProviderConfig(api_key="test-key", base_url=None)+ provider = OpenAIProvider("gpt-5.1", config)++ with patch.object(+ OpenAIResponsesModel, "request", new_callable=AsyncMock+ ) as mock_request:+ mock_request.return_value = ModelResponse(+ parts=[TextPart(content="print(1)")]+ )+ result = await provider.completion(+ messages=[],+ system_prompt="Complete the code.",+ max_tokens=1024,+ additional_tools=[],+ enable_capabilities=False,+ thinking=thinking,+ span_info=SpanInfo(+ endpoint="inline_completion", model="openai/gpt-5.1"+ ),+ )++ assert result == "print(1)"+ mock_request.assert_called_once()+ assert mock_request.call_args.args[1] == {+ "max_tokens": 1024,+ "thinking": True if thinking is None else thinking,+ "openai_reasoning_summary": "auto",+ }++@pytest.mark.requires("pydantic_ai")async def test_completion_tool_count_includes_capabilities() -> None:"""`completion` reports tools plus the agent's native capabilities, so itsdiff --git a/tests/_server/api/endpoints/test_ai.py b/tests/_server/api/endpoints/test_ai.pyindex 0a46038ff1..0e20c4ed02 100644--- a/tests/_server/api/endpoints/test_ai.py+++ b/tests/_server/api/endpoints/test_ai.py@@ -402,6 +402,7 @@ class TestOpenAiEndpoints:mock_completion.assert_called_once()# Assert the messages contain FIM formatcall_kwargs = mock_completion.call_args.kwargs+ assert call_kwargs["thinking"] is Falsemessages = call_kwargs["messages"]assert len(messages) == 1# Verify FIM format is used