sigh
This commit is contained in:
@@ -88,6 +88,7 @@ class GeminiCliAdapter:
|
||||
# Mock a JSON error result to bubble up
|
||||
stdout_final += '\n{"type": "result", "status": "error", "error": "subprocess timeout"}\n'
|
||||
|
||||
last_decode_error = None
|
||||
for line in stdout_final.splitlines():
|
||||
line = line.strip()
|
||||
if not line: continue
|
||||
@@ -108,6 +109,8 @@ class GeminiCliAdapter:
|
||||
stream_callback(content)
|
||||
elif msg_type == "result":
|
||||
self.last_usage = data.get("stats") or data.get("usage")
|
||||
if data.get("status") == "error":
|
||||
raise Exception(data.get("error", "Unknown CLI error"))
|
||||
if "session_id" in data:
|
||||
self.session_id = data.get("session_id")
|
||||
elif msg_type == "tool_use":
|
||||
@@ -118,10 +121,15 @@ class GeminiCliAdapter:
|
||||
}
|
||||
if tc["name"]:
|
||||
tool_calls.append(tc)
|
||||
except json.JSONDecodeError:
|
||||
except json.JSONDecodeError as e:
|
||||
last_decode_error = e
|
||||
continue
|
||||
|
||||
current_latency = time.time() - start_time
|
||||
if process.returncode != 0 and not accumulated_text and not tool_calls:
|
||||
if last_decode_error:
|
||||
raise Exception(f"Gemini CLI failed (exit {process.returncode}) with JSONDecodeError: {last_decode_error}\nOutput: {stdout_final}")
|
||||
raise Exception(f"Gemini CLI failed with exit {process.returncode}\nStderr: {stderr_final}")
|
||||
session_logger.open_session()
|
||||
session_logger.log_cli_call(
|
||||
command=command,
|
||||
|
||||
Reference in New Issue
Block a user