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

Function _build_capture_dict

uncommon_route/proxy.py:667–695  ·  view source on GitHub ↗
(
    body: dict, text: str, calls: list[dict[str, Any]], finish: str
)

Source from the content-addressed store, hash-verified

665
666
667def _build_capture_dict(
668 body: dict, text: str, calls: list[dict[str, Any]], finish: str
669) -> dict[str, Any]:
670 sys_field = body.get("system", "")
671 if isinstance(sys_field, list):
672 system_text = " ".join(
673 (b.get("text") or "")
674 for b in sys_field
675 if isinstance(b, dict) and b.get("type") == "text"
676 )
677 else:
678 system_text = str(sys_field) if sys_field else ""
679 raw_tools = body.get("tools") or body.get("customTools") or []
680 raw = {
681 "request_messages": list(body.get("messages") or []),
682 "request_system": system_text,
683 "request_tools_count": len(raw_tools) if isinstance(raw_tools, list) else 0,
684 "response_text": text,
685 "response_tool_calls": calls,
686 "response_finish_reason": finish,
687 "content_truncated": False,
688 }
689 cap_bytes = _content_cap_bytes()
690 if cap_bytes <= 0:
691 raw["content_truncated"] = False
692 return raw
693 truncated, was_trunc = truncate_content_payload(raw, cap_bytes=cap_bytes)
694 truncated["content_truncated"] = was_trunc
695 return truncated
696
697
698def _content_cap_bytes() -> int:

Callers 2

_capture_non_streamingFunction · 0.85
_capture_streamingFunction · 0.85

Calls 3

truncate_content_payloadFunction · 0.90
_content_cap_bytesFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected