@@ -109,7 +109,8 @@ def _handle_local_files(
109109 Updated kwargs with file content in prompt/agent field
110110
111111 Raises:
112- HumanloopRuntimeError: On validation or file loading failures
112+ HumanloopRuntimeError: On validation or file loading failures.
113+ For example, an invalid path format (absolute paths, leading/trailing slashes, etc.) or a file not being found.
113114 """
114115 if "id" in kwargs :
115116 raise HumanloopRuntimeError ("Can only specify one of `id` or `path`" )
@@ -133,7 +134,7 @@ def _handle_local_files(
133134 # Always raise error when file extension is detected (based on the outer if condition)
134135 raise HumanloopRuntimeError (
135136 f"Path '{ path } ' includes a file extension which is not supported in API calls. "
136- f"When referencing files via the path parameter, use the format without extensions: '{ path_without_extension } '. "
137+ f"When referencing files via the ` path` parameter, use the path without extensions: '{ path_without_extension } '. "
137138 f"Note: File extensions are only used when pulling specific files via the CLI."
138139 )
139140
@@ -150,7 +151,8 @@ def _handle_local_files(
150151 if file_type not in FileSyncer .SERIALIZABLE_FILE_TYPES :
151152 raise HumanloopRuntimeError (f"Local files are not supported for `{ file_type .capitalize ()} ` files: '{ path } '." )
152153
153- # If file_type is already specified in kwargs (prompt or agent), it means user provided a Prompt- or AgentKernelRequestParams object
154+ # If file_type is already specified in kwargs (`prompt` or `agent`), it means user provided a Prompt- or AgentKernelRequestParams object
155+ # In this case, we should prioritize the user-provided value over the local file content.
154156 if file_type in kwargs and not isinstance (kwargs [file_type ], str ):
155157 logger .warning (
156158 f"Ignoring local file for `{ path } ` as { file_type } parameters were directly provided. "
@@ -189,7 +191,7 @@ def _overload_log(self: T, file_syncer: Optional[FileSyncer], use_local_files: b
189191
190192 kwargs = _handle_tracing_context (kwargs , self )
191193
192- # Handle loading files from local filesystem when using Prompts and Agents clients
194+ # Handle loading files from local filesystem when using Prompt and Agent clients
193195 # This enables users to define prompts/agents in local files rather than fetching from the Humanloop API
194196 if use_local_files and _get_file_type_from_client (self ) in FileSyncer .SERIALIZABLE_FILE_TYPES :
195197 # Developer note: file_syncer should always be provided during SDK initialization when
@@ -220,6 +222,7 @@ def _overload_log(self: T, file_syncer: Optional[FileSyncer], use_local_files: b
220222def _overload_call (self : T , file_syncer : Optional [FileSyncer ], use_local_files : bool , ** kwargs ) -> CallResponseType :
221223 try :
222224 kwargs = _handle_tracing_context (kwargs , self )
225+ # If `use_local_files` flag is True, we should use local file content for `call` operations on Prompt and Agent clients.
223226 if use_local_files and _get_file_type_from_client (self ) in FileSyncer .SERIALIZABLE_FILE_TYPES :
224227 # Same file_syncer requirement as in _overload_log - see developer note there
225228 if file_syncer is None :
0 commit comments