diff --git a/src/pyra/chat/session.py b/src/pyra/chat/session.py index f378cab..0f61a87 100644 --- a/src/pyra/chat/session.py +++ b/src/pyra/chat/session.py @@ -176,6 +176,8 @@ def start_chat() -> None: "[dim]Type /help for commands, /quit to exit.[/dim]" ) + _flags: dict = {"use_tools": True} + while True: try: user_input = session.prompt("› ").strip() @@ -226,7 +228,7 @@ def start_chat() -> None: history.add_user(user_input) try: - response_text = _call_ai(cfg, history, registry, executor) + response_text = _call_ai(cfg, history, registry, executor, _flags) except Exception as exc: render_error(f"AI error: {exc}") history._messages.pop() @@ -244,6 +246,7 @@ def _call_ai( history: ConversationHistory, registry: PluginRegistry, executor: ToolExecutor, + flags: dict | None = None, ) -> str: from pyra.vault.reader import get_key @@ -272,8 +275,9 @@ def _call_ai( for t in tools ] - # No plugins active — use streaming (original behavior) - if not tools_spec: + # No tools active, or provider known not to support function calling + use_tools = flags is None or flags.get("use_tools", True) + if not tools_spec or not use_tools: stream = litellm.completion( **base_kwargs, messages=history.build_for_api(), @@ -304,6 +308,8 @@ def _call_ai( return render_text_response("Error: tool-use loop exceeded maximum iterations.") except litellm.BadRequestError: + if flags is not None: + flags["use_tools"] = False render_info("This model does not support function calling — tools disabled.") stream = litellm.completion( **base_kwargs,