Skip to content

Commit ad28393

Browse files
committed
fix: tests
1 parent 6a77248 commit ad28393

2 files changed

Lines changed: 8 additions & 50 deletions

File tree

packages/uipath-openai-agents/src/uipath_openai_agents/runtime/_serialize.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ def serialize_output(output: Any) -> Any:
1616
if output is None:
1717
return {}
1818

19-
# Handle Pydantic models
20-
if hasattr(output, "model_dump"):
19+
# Handle Pydantic models (but not Pydantic model classes)
20+
if hasattr(output, "model_dump") and not isinstance(output, type):
2121
return serialize_output(output.model_dump(by_alias=True))
22-
elif hasattr(output, "dict"):
22+
elif hasattr(output, "dict") and not isinstance(output, type):
2323
return serialize_output(output.dict())
24-
elif hasattr(output, "to_dict"):
24+
elif hasattr(output, "to_dict") and not isinstance(output, type):
2525
return serialize_output(output.to_dict())
2626

2727
# Handle dataclasses (but not dataclass types)

packages/uipath-openai-agents/src/uipath_openai_agents/runtime/runtime.py

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -219,52 +219,10 @@ def _convert_stream_event_to_runtime_event(
219219
return None
220220

221221
def _prepare_agent_input(self, input: dict[str, Any] | None) -> str | list[Any]:
222-
"""
223-
Prepare agent input from UiPath input dictionary.
224-
225-
Supports two input formats:
226-
- {"message": "text"} → returns string for Runner.run()
227-
- {"messages": [...]} → returns list of message dicts for Runner.run()
228-
229-
Note: When using sessions, string input is preferred as it doesn't
230-
require a session_input_callback.
231-
232-
Args:
233-
input: Input dictionary from UiPath
234-
235-
Returns:
236-
String or list for Runner.run() input parameter
237-
238-
Raises:
239-
ValueError: If input doesn't contain "message" or "messages" field
240-
"""
241-
if not input:
242-
raise ValueError(
243-
"Input is required. Provide either 'message' (string) or 'messages' (list of message dicts)"
244-
)
245-
246-
# Check for "messages" field (list of message dicts)
247-
if "messages" in input:
248-
messages = input["messages"]
249-
# Ensure it's a list
250-
if isinstance(messages, list):
251-
return messages
252-
else:
253-
raise ValueError(
254-
"'messages' field must be a list of message dictionaries"
255-
)
256-
257-
# Check for "message" field (simple string)
258-
if "message" in input:
259-
message = input["message"]
260-
# Return as string (OpenAI Agents SDK handles string → message conversion)
261-
return str(message)
262-
263-
# No valid field found
264-
raise ValueError(
265-
"Input must contain either 'message' (string) or 'messages' (list of message dicts). "
266-
f"Got keys: {list(input.keys())}"
267-
)
222+
"""Prepare agent input from UiPath input dictionary."""
223+
if input and "messages" in input and isinstance(input["messages"], list):
224+
return input.get("messages", [])
225+
return input.get("message", "") if input else ""
268226

269227
def _serialize_message(self, message: Any) -> dict[str, Any]:
270228
"""

0 commit comments

Comments
 (0)