Skip to content

Conversation

@NicoV7
Copy link

@NicoV7 NicoV7 commented Sep 24, 2025

Closes #76

This PR adds input validation to the solve() method as requested in the issue:

  • Validates goal is not None or empty/whitespace
  • Raises appropriate ValueError exceptions
  • Includes comprehensive unit tests
  • All existing tests continue to pass (12/12 passing)

The implementation follows the existing code patterns and testing conventions.

- Validate goal parameter is not None or empty/whitespace
- Raise ValueError with descriptive messages for invalid inputs
- Add comprehensive unit tests for validation logic
- All existing tests continue to pass

Fixes jentic#76
@NicoV7 NicoV7 requested a review from a team as a code owner September 24, 2025 18:15
def solve(self, goal: str) -> ReasoningResult:
"""Solves a goal synchronously (library-style API)."""

if goal is None:
Copy link
Collaborator

@rishikesh-jentic rishikesh-jentic Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! I appreciate you thinking about input validation—it's definitely something we should handle better.
I'd like to suggest a small refinement to make the UX even better. Instead of raising a ValueError, what do you think about returning a graceful result like this?
if not goal or not goal.strip(): return ReasoningResult(success=False, final_answer="Goal cannot be empty, please provide a goal")
My reasoning: In user-facing scenarios (chat interfaces, APIs, etc.), raising an exception forces the caller to handle it with try/except. Returning a failed ReasoningResult keeps the flow consistent—the caller always gets a result object, whether the input was valid or not.

Would like to hear your thoughts on this.

Thanks again for taking the time to improve the codebase! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Good First Issue] [Enhancement] Add input validation to StandardAgent.solve()

2 participants