Private
Public Access
fix(app_controller): _offload_entry_payload unwraps Result from session_logger
Regression fix: session_logger.log_tool_call was partially migrated to return Result[data=str(ps1_path) | None] but the call site in _offload_entry_payload still did Path(ref_path).name on the Result object, raising TypeError. The fix wraps the call to log_tool_call in an isinstance(ref_result, Result) guard and unwraps .ok / .data to produce the [REF:filename] reference. On errors, a logging.debug is emitted (per Heuristic #19) and the payload is preserved unchanged. Also adds import logging to the module top and rom src.result_types import Result, ErrorInfo, ErrorKind to support the convention's 'AND over OR' pattern at this call site. The log_tool_output call site is unchanged because log_tool_output still returns Optional[str] (not Result); applying the unwrap pattern there would crash. The spec's illustrative code treated both functions as Result-based, but only log_tool_call was actually half-migrated. Refs: conductor/tracks/result_migration_app_controller_20260618 (FR5) Refs: tests/test_app_controller_offloading.py:test_offload_entry_payload_tool_call_unwraps_result Refs: tests/test_app_controller_offloading.py:test_offload_entry_payload_preserves_script_on_log_tool_call_error
This commit is contained in:
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import copy
|
||||
import inspect
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import signal
|
||||
@@ -37,6 +38,7 @@ from src import shell_runner
|
||||
from src import theme_2 as theme
|
||||
from src import thinking_parser
|
||||
from src import tool_presets
|
||||
from src.result_types import Result, ErrorInfo, ErrorKind
|
||||
|
||||
from src.context_presets import ContextPresetManager
|
||||
from src.file_cache import ASTParser
|
||||
@@ -3718,10 +3720,12 @@ class AppController:
|
||||
payload["output"] = f"[REF:{filename}]"
|
||||
if kind == "tool_call" and "script" in payload:
|
||||
script = payload["script"]
|
||||
ref_path = session_logger.log_tool_call(script, "LOG_ONLY", None)
|
||||
if ref_path:
|
||||
filename = Path(ref_path).name
|
||||
ref_result = session_logger.log_tool_call(script, "LOG_ONLY", None)
|
||||
if isinstance(ref_result, Result) and ref_result.ok and ref_result.data:
|
||||
filename = Path(ref_result.data).name
|
||||
payload["script"] = f"[REF:{filename}]"
|
||||
elif isinstance(ref_result, Result) and ref_result.errors:
|
||||
logging.getLogger(__name__).debug("offload tool_call failed: %s", ref_result.errors[0].ui_message())
|
||||
return optimized
|
||||
|
||||
def _on_api_event(self, event_name: str = "generic_event", **kwargs: Any) -> None:
|
||||
|
||||
Reference in New Issue
Block a user