From 89e82f113416d3c81392591d2597c8d69159cbd0 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 2 Mar 2026 10:15:28 -0500 Subject: [PATCH] fix(infra): api_hook_client debug logging, gemini_cli_adapter streaming fixes, ai_client minor --- ai_client.py | 1 + api_hook_client.py | 7 ++++--- gemini_cli_adapter.py | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ai_client.py b/ai_client.py index 35f333b..f62e810 100644 --- a/ai_client.py +++ b/ai_client.py @@ -343,6 +343,7 @@ def _list_gemini_cli_models() -> list[str]: "gemini-3.1-pro-preview", "gemini-2.5-pro", "gemini-2.5-flash", + "gemini-2.0-flash", "gemini-2.5-flash-lite", ] diff --git a/api_hook_client.py b/api_hook_client.py index c5be753..79ef6e4 100644 --- a/api_hook_client.py +++ b/api_hook_client.py @@ -1,4 +1,4 @@ -from __future__ import annotations +from __future__ import annotations import requests import json import time @@ -73,7 +73,9 @@ class ApiHookClient: return self._make_request('POST', '/api/project', data={'project': project_data}) def get_session(self) -> dict | None: - return self._make_request('GET', '/api/session') + res = self._make_request('GET', '/api/session') + print(f"RAW SESSION RESPONSE: {res}") + return res def get_mma_status(self) -> dict | None: """Retrieves current MMA status (track, tickets, tier, etc.)""" @@ -242,4 +244,3 @@ class ApiHookClient: data={'type': 'tool_approval', 'tool': tool_name, 'args': args}, timeout=60.0) return res.get('response') - diff --git a/gemini_cli_adapter.py b/gemini_cli_adapter.py index d66b87e..7abab69 100644 --- a/gemini_cli_adapter.py +++ b/gemini_cli_adapter.py @@ -130,3 +130,11 @@ class GeminiCliAdapter: "tool_calls": tool_calls, "stderr": stderr_final } + + def count_tokens(self, contents: list[str]) -> int: + """ + Provides a character-based token estimation for the Gemini CLI. + Uses 4 chars/token as a conservative average. + """ + total_chars = len("\n".join(contents)) + return total_chars // 4