Skip to content

Conversation

@yjgoh28
Copy link
Contributor

@yjgoh28 yjgoh28 commented Dec 16, 2024

remove any sys.exit on business logic level for tools, and only raise exceptions. let cli/tools.py handle any errors and do sys.exit

📥 Pull Request

📘 Description
addreses #141 only for tools generation
remove any sys.exit on business logic level for tools, and only raise exceptions. let cli/tools.py handle any errors and do sys.exit

🧪 Testing
N/A

remove any sys.exit on business logic level for tools, and only raise exceptions. let cli/tools.py handle any errors and do sys.exit
@tcdent
Copy link
Collaborator

tcdent commented Dec 16, 2024

Thanks for your contribution @yjgoh28

We should also be catching the exceptions in agentstack.cli.* and printing friendly error messages. When this is complete, the user shouldn't get an exceptions or tracebacks when running cli commands.

@yjgoh28
Copy link
Contributor Author

yjgoh28 commented Dec 16, 2024

Got it 🫡

@tkrevh
Copy link
Contributor

tkrevh commented Dec 16, 2024

I was just browsing through the code today, and saw there were some unexpected sys.exits where I didn't expect to see them.
Especially if AgentStack was used as a library, and not through CLI. Good PR!

except ToolError:
print(term_color("Could not retrieve list of tools. The tools directory may be corrupted or missing.", 'red'))
sys.exit(1)
except ValidationError:
Copy link
Contributor

Choose a reason for hiding this comment

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

in only the case of a validation error, it'd be smart to log the exception because it will help them track down what's failing in the validation of their tool config.

tools_init.add_import_for_tool(tool, agentstack_config.framework)
except ValidationError as e:
print(term_color(f"Error adding tool:\n{e}", 'red'))
raise ToolError(f"Error adding tool:\n{e}")
Copy link
Contributor

Choose a reason for hiding this comment

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

if i'm not missing something, ValidationError will never be surfaced to tools.py for the proper logging because we're catching it here and re-raising it as a ToolError

addresses
in only the case of a validation error, it'd be smart to log the exception because it will help them track down what's failing in the validation of their tool config.
addresses " if i'm not missing something, ValidationError will never be surfaced to tools.py for the proper logging because we're catching it here and re-raising it as a ToolError"
@yjgoh28 yjgoh28 requested a review from bboynton97 December 23, 2024 06:03
@bboynton97
Copy link
Contributor

hey @yjgoh28! we're in the middle of some sizable repo changes and plan to come back to this after a few key decisions. thank you for the effort in this PR! :)

@bboynton97
Copy link
Contributor

these changes are not compatible with the new design for tools - im closing this but thank you for the contribution 🫶

@bboynton97 bboynton97 closed this Jan 15, 2025
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.

4 participants