MCPcopy Index your code
hub / github.com/openai/openai-agents-python / loaded_paths

Function loaded_paths

examples/tools/tool_search.py:121–160  ·  view source on GitHub ↗
(result: Any)

Source from the content-addressed store, hash-verified

119
120
121def loaded_paths(result: Any) -> list[str]:
122 paths: set[str] = set()
123
124 for item in result.new_items:
125 if item.type != "tool_search_output_item":
126 continue
127
128 raw_tools = (
129 item.raw_item.get("tools")
130 if isinstance(item.raw_item, Mapping)
131 else getattr(item.raw_item, "tools", None)
132 )
133 if not isinstance(raw_tools, list):
134 continue
135
136 for raw_tool in raw_tools:
137 tool_payload = (
138 raw_tool
139 if isinstance(raw_tool, Mapping)
140 else (
141 raw_tool.model_dump(exclude_unset=True)
142 if callable(getattr(raw_tool, "model_dump", None))
143 else None
144 )
145 )
146 if not isinstance(tool_payload, Mapping):
147 continue
148
149 tool_type = tool_payload.get("type")
150 if tool_type == "namespace":
151 path = tool_payload.get("name")
152 elif tool_type == "function":
153 path = tool_payload.get("name")
154 else:
155 path = tool_payload.get("server_label")
156
157 if isinstance(path, str) and path:
158 paths.add(path)
159
160 return sorted(paths)
161
162
163def print_result(title: str, result: Any, registered_paths: list[str]) -> None:

Callers 1

print_resultFunction · 0.85

Calls 3

getMethod · 0.45
model_dumpMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected