Co-Authored-By: Clément Drouin <clement.drouin@mistral.ai>
This commit is contained in:
Michel Thomazo 2025-12-11 09:39:20 +01:00
parent af43abea60
commit a340a721ea
13 changed files with 234 additions and 80 deletions

View file

@ -100,20 +100,30 @@ class VibeAcpAgent(AcpAgent):
script_name = sys.argv[0]
args = [script_name, "--setup"]
auth_methods = [
AuthMethod(
id="vibe-setup",
name="Register your API Key",
description="Register your API Key inside Mistral Vibe",
field_meta={
"terminal-auth": {
"command": command,
"args": args,
"label": "Mistral Vibe Setup",
}
},
)
]
supports_terminal_auth = (
self.client_capabilities
and self.client_capabilities.field_meta
and self.client_capabilities.field_meta.get("terminal-auth") is True
)
auth_methods = (
[
AuthMethod(
id="vibe-setup",
name="Register your API Key",
description="Register your API Key inside Mistral Vibe",
field_meta={
"terminal-auth": {
"command": command,
"args": args,
"label": "Mistral Vibe Setup",
}
},
)
]
if supports_terminal_auth
else []
)
response = InitializeResponse(
agentCapabilities=AgentCapabilities(

View file

@ -1,6 +1,6 @@
from __future__ import annotations
__all__ = ["__version__", "run_programmatic"]
__version__ = "1.1.1"
__version__ = "1.1.2"
from vibe.core.programmatic import run_programmatic

View file

@ -625,7 +625,7 @@ class Agent:
tools=available_tools,
tool_choice=tool_choice,
extra_headers={
"User-Agent": get_user_agent(),
"user-agent": get_user_agent(provider.backend),
"x-affinity": self.session_id,
},
max_tokens=max_tokens,
@ -682,7 +682,7 @@ class Agent:
tools=available_tools,
tool_choice=tool_choice,
extra_headers={
"User-Agent": get_user_agent(),
"user-agent": get_user_agent(provider.backend),
"x-affinity": self.session_id,
},
max_tokens=max_tokens,
@ -903,6 +903,7 @@ class Agent:
self.messages = [system_message, summary_message]
active_model = self.config.get_active_model()
provider = self.config.get_provider_for_model(active_model)
async with self.backend as backend:
actual_context_tokens = await backend.count_tokens(
@ -911,7 +912,7 @@ class Agent:
tools=self.format_handler.get_available_tools(
self.tool_manager, self.config
),
extra_headers={"User-Agent": get_user_agent()},
extra_headers={"user-agent": get_user_agent(provider.backend)},
)
self.stats.context_tokens = actual_context_tokens

View file

@ -14,7 +14,7 @@ from typing import Any
import httpx
from vibe.core import __version__
from vibe.core.config import CONFIG_DIR, CONFIG_FILE, GLOBAL_CONFIG_FILE
from vibe.core.config import CONFIG_DIR, CONFIG_FILE, GLOBAL_CONFIG_FILE, Backend
from vibe.core.types import BaseEvent, ToolResultEvent
@ -160,8 +160,12 @@ if CONFIG_FILE != GLOBAL_CONFIG_FILE and GLOBAL_CONFIG_FILE.is_file():
)
def get_user_agent() -> str:
return f"Mistral-Vibe/{__version__}"
def get_user_agent(backend: Backend) -> str:
user_agent = f"Mistral-Vibe/{__version__}"
if backend == Backend.MISTRAL:
mistral_sdk_prefix = "mistral-client-python/"
user_agent = f"{mistral_sdk_prefix}{user_agent}"
return user_agent
def _is_retryable_http_error(e: Exception) -> bool: