--- a/src/mac_laya/assistant.py +++ b/src/mac_laya/assistant.py @@ -349,28 +349,25 @@ effect_scope=str(TOOL_OWNERS[action["tool"]].validate(action["tool"],arguments,self.context(goal))) return effect_scope - def decide_step(self,goal,observation,action): - """MacJev's execute/inspect/ask decision with the observation shrunk to fit its 4096-token input.""" - from .model import InputBudgetError - question={"t":"choice","ins":"Choose the next step that best advances the original user goal with the available information.", - "crit":{"execute":"Execute the proposed registered action after deterministic scope and precondition checks", - "inspect":"Inspect the explicitly named app window or approved directory for more information before acting", - "ask":"Ask the user to resolve missing information or ambiguity"}} - history=observation.get("previous_results",[]) - variants=[observation,{**observation,"previous_results":history[-2:]},{**observation,"previous_results":history[-1:]}, - {k:v for k,v in {**observation,"previous_results":history[-1:]}.items() if k not in {"open_sessions","window_app_aliases","registered_app_ids"}}] - for variant in variants: - try:return self.engine.decide({"user_goal":goal,"observation":variant,"proposed_action":action},question) - except InputBudgetError:continue - return None + def decide_step(self,goal,observation,action,history=None): + """MacJev's execute/inspect/ask decision on the shared scope-relative view (macjev.mac.view). + The full history is sent within a ~20K-token budget with explicit truncation markers (smaller + budgets are tried on an input-budget error; nothing is cut silently), the static app registry is + replaced by the apps the goal/action/history name, and every call is logged to runs/macjev/gate_log/. + """ + from macjev.mac import runtime_adapter + if history is not None: + observation={**observation,"previous_results":runtime_adapter.stamped(history)} + return runtime_adapter.gate_call(self.engine,goal,observation,action) + def fast_path(self,goal,asr): """Single-step commands: deterministic parse + one MacJev decision, no 8B planner.""" from .fast_lane import decide as fast_decide from .inference import DecisionEngine if self.engine is None:self.engine=DecisionEngine() scope=Path(self.scope) - listing=sorted(p.name for p in scope.iterdir())[:200] if scope.is_dir() else [] + listing=FileScope(scope).execute("list_files",{"directory":str(scope)}) if scope.is_dir() else {"directory":str(scope),"entries":[],"truncated":False} fast=fast_decide(goal,scope,self.engine,listing) if fast is None:return None if "needs_user" in fast: @@ -393,7 +390,9 @@ if self.fast_lane and start_step==0 and not history: fast=self.fast_path(goal,asr) if fast is not None:return fast + from macjev.mac import runtime_adapter for step in range(start_step,self.max_steps): + runtime_adapter.stamped(history) # record receipt times now (before the planner's seconds-long call) observation={"approved_scope":str(self.scope),"registered_app_ids":sorted(set(APPS.values())), "window_app_aliases":WINDOW_APPS,"previous_results":history[-4:]} sessions=self.session_summary(goal) @@ -411,7 +410,7 @@ if action["tool"] not in {"ask_user","done"}: from .inference import DecisionEngine if self.engine is None:self.engine=DecisionEngine() - decision=self.decide_step(goal,observation,action) + decision=self.decide_step(goal,observation,action,history) if decision is None: return {"goal":goal,"asr":asr,"history":history,"needs_user":"The current observation is too large for the local decision model; please narrow the request."} if decision["answer"]!="execute" and decision["top_probability"]