WIP: PAIN
This commit is contained in:
@@ -129,6 +129,7 @@ _comms_log: list[dict[str, Any]] = []
|
||||
COMMS_CLAMP_CHARS: int = 300
|
||||
|
||||
def _append_comms(direction: str, kind: str, payload: dict[str, Any]) -> None:
|
||||
global current_tier
|
||||
entry: dict[str, Any] = {
|
||||
"ts": datetime.datetime.now().strftime("%H:%M:%S"),
|
||||
"direction": direction,
|
||||
@@ -1585,13 +1586,28 @@ def _add_bleed_derived(d: dict[str, Any], sys_tok: int = 0, tool_tok: int = 0) -
|
||||
d["estimated_prompt_tokens"] = cur
|
||||
d["max_prompt_tokens"] = lim
|
||||
d["utilization_pct"] = d.get("percentage", 0.0)
|
||||
d["headroom_tokens"] = max(0, lim - cur)
|
||||
d["would_trim"] = (lim - cur) < 20000
|
||||
d["system_tokens"] = sys_tok
|
||||
d["tools_tokens"] = tool_tok
|
||||
d["headroom"] = max(0, lim - cur)
|
||||
d["would_trim"] = cur >= lim
|
||||
d["sys_tokens"] = sys_tok
|
||||
d["tool_tokens"] = tool_tok
|
||||
d["history_tokens"] = max(0, cur - sys_tok - tool_tok)
|
||||
return d
|
||||
|
||||
def _is_mutating_tool(name: str) -> bool:
|
||||
"""Returns True if the tool name is considered a mutating tool."""
|
||||
return name in mcp_client.MUTATING_TOOLS or name == TOOL_NAME
|
||||
|
||||
def _confirm_and_run(script: str, base_dir: str, qa_callback: Optional[Callable[[str], str]] = None) -> Optional[str]:
|
||||
"""
|
||||
Wrapper for the confirm_and_run_callback.
|
||||
This is what the providers call to trigger HITL approval.
|
||||
"""
|
||||
if confirm_and_run_callback:
|
||||
return confirm_and_run_callback(script, base_dir, qa_callback)
|
||||
# Fallback to direct execution if no callback registered (headless default)
|
||||
from src import shell_runner
|
||||
return shell_runner.run_powershell(script, base_dir, qa_callback=qa_callback)
|
||||
|
||||
def get_history_bleed_stats(md_content: Optional[str] = None) -> dict[str, Any]:
|
||||
if _provider == "anthropic":
|
||||
with _anthropic_history_lock:
|
||||
|
||||
Reference in New Issue
Block a user