MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _tool_call_preview

Function _tool_call_preview

uncommon_route/signals/embedding.py:54–81  ·  view source on GitHub ↗
(tool_call: dict[str, Any], budget_chars: int = 320)

Source from the content-addressed store, hash-verified

52
53
54def _tool_call_preview(tool_call: dict[str, Any], budget_chars: int = 320) -> str:
55 fn = tool_call.get("function") or {}
56 if not isinstance(fn, dict):
57 return ""
58 name = str(fn.get("name") or tool_call.get("name") or "?").strip() or "?"
59 arguments = fn.get("arguments")
60 if isinstance(arguments, str):
61 try:
62 parsed = json.loads(arguments)
63 except json.JSONDecodeError:
64 arg_text = arguments
65 else:
66 if isinstance(parsed, dict):
67 command = parsed.get("command")
68 if isinstance(command, str):
69 arg_text = command
70 else:
71 arg_text = json.dumps(parsed, ensure_ascii=False, sort_keys=True)
72 else:
73 arg_text = str(parsed)
74 elif arguments is None:
75 arg_text = ""
76 else:
77 arg_text = str(arguments)
78 arg_text = " ".join(arg_text.split())
79 if len(arg_text) > budget_chars:
80 arg_text = arg_text[:budget_chars] + "..."
81 return f"{name}({arg_text})" if arg_text else name
82
83
84def _extract_agent_state(messages: list[dict[str, Any]], budget_chars: int = 2400) -> str:

Callers 1

_extract_agent_stateFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected