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:
@@ -27,7 +27,7 @@ phase_5 = { status = "pending", checkpointsha = "", name = "Verify, document, en
|
||||
# Phase 1: Setup + Fix the regression
|
||||
t1_1 = { status = "pending", commit_sha = "", description = "Create sub-track folder (spec.md exists; plan.md, metadata.json, state.toml)" }
|
||||
t1_2 = { status = "pending", commit_sha = "", description = "Update conductor/tracks.md with the new sub-track row" }
|
||||
t1_3 = { status = "pending", commit_sha = "", description = "Fix _offload_entry_payload call site in src/app_controller.py:3709-3725 (unwrap Result from log_tool_output/log_tool_call)" }
|
||||
t1_3 = { status = "completed", commit_sha = "", description = "Fix _offload_entry_payload call site in src/app_controller.py:3709-3725 (unwrap Result from log_tool_call; log_tool_output already returns Optional[str])" }
|
||||
t1_4 = { status = "pending", commit_sha = "", description = "Add 2 unwrap-path tests in tests/test_app_controller_offloading.py" }
|
||||
t1_5 = { status = "pending", commit_sha = "", description = "Run targeted regression test (test_tool_ask_approval + test_execution_sim_live); verify both pass" }
|
||||
t1_6 = { status = "pending", commit_sha = "", description = "Phase 1 checkpoint commit" }
|
||||
|
||||
@@ -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