refactor(tools): add BaseTools class and use XML prompts #43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The tool classes had grown messy with duplicated helper methods across company, filings, financial, and insider modules. Each class had its own copy of _parse_date, _find_filing, and _build_sec_url doing the same thing.
Additionally, the LLM prompts used verbose CAPS formatting like "CRITICAL INSTRUCTIONS" and "NEVER DO THIS" which felt clunky and hard to read.
I've introduced a BaseTools class that all tool classes now inherit from, consolidating the shared utilities in one place. I also moved XBRL extraction logic out of financial.py into a dedicated xbrl.py module since financial.py had grown to 860+ lines and was difficult to navigate.
The LLM prompts now use XML tags like
<instructions>,<when-to-use>,<tip>, and<presentation>which are cleaner and easier to parse. The base financial instructions are defined once and interpolated where needed via f-strings.Note: types.py was removed since ToolResponse is now exported from base.py.