mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-03 22:19:27 +00:00
Avoid leaking output validation errors
This commit is contained in:
@@ -74,7 +74,8 @@ def _format_tool_output_for_agent(tool: Any, raw_result: Any) -> str:
|
||||
(
|
||||
f"Failed to validate or serialize output from tool "
|
||||
f"'{getattr(tool, 'name', '<unknown>')}' using output_schema "
|
||||
f"'{output_schema.__name__}': {exc}. Falling back to str(raw_result)."
|
||||
f"'{output_schema.__name__}': {exc.__class__.__name__}. "
|
||||
"Falling back to str(raw_result)."
|
||||
),
|
||||
RuntimeWarning,
|
||||
stacklevel=2,
|
||||
|
||||
@@ -188,11 +188,16 @@ def test_invalid_typed_output_warns_and_uses_string_agent_text():
|
||||
)
|
||||
raw_result = tool.invoke({"value": "crew"})
|
||||
|
||||
with pytest.warns(RuntimeWarning, match="Failed to validate or serialize"):
|
||||
with pytest.warns(
|
||||
RuntimeWarning, match="Failed to validate or serialize"
|
||||
) as warnings:
|
||||
agent_text = tool.format_output_for_agent(raw_result)
|
||||
|
||||
assert raw_result == {"value": "crew", "count": "wrong"}
|
||||
assert agent_text == str(raw_result)
|
||||
warning_message = str(warnings[0].message)
|
||||
assert "ValidationError" in warning_message
|
||||
assert "wrong" not in warning_message
|
||||
|
||||
|
||||
def test_validate_function_signature(basic_function, schema_class):
|
||||
|
||||
Reference in New Issue
Block a user