refactor: apply best practices across core SDK#259
Conversation
- Fix version inconsistency between .bumpversion.cfg (0.2.0) and pyproject.toml (0.4.0) - Modernize type hints to PEP 604/585 (Optional[X] -> X | None, List[X] -> list[X]) - Replace overly broad exception handling (Exception) with specific types (ImportError) - Downgrade noisy middleware warning to debug level - Clean up pyproject.toml placeholder metadata and inline comments - Add schema caching to ToolManager.to_params() to avoid re-serialization - Preserve custom prompts in SpoonReactAI when passed via constructor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f2ea9db38
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if self._params_cache is not None and self._params_cache_count == len(self.tools): | ||
| return self._params_cache |
There was a problem hiding this comment.
Invalidate tool schema cache when tool identities change
to_params() now treats the cache as valid whenever len(self.tools) is unchanged, but existing agent code mutates ToolManager.tools/tool_map directly (for example CustomAgent.add_tool replaces duplicate names via remove+append while keeping the same count). In that path, to_params() can return stale schemas for the previous tool objects, so subsequent LLM tool-calling runs use outdated names/parameters and may fail or call the wrong signature.
Useful? React with 👍 / 👎.
Summary
.bumpversion.cfg(0.2.0) andpyproject.toml(0.4.0)llm/manager.py,llm/config.py,llm/errors.py, andagents/base.py(Optional[X]->X | None,List[X]->list[X])except Exceptionwith specificexcept ImportErrorin__init__.pyWARNINGtoDEBUGlevel inagents/base.pypyproject.tomlplaceholder metadata and inline commentsToolManager.to_params()to avoid re-serialization every agent stepSpoonReactAIwhen passed via constructor (prevents_refresh_prompts()from overwriting caller-supplied values)Test plan
spoon_ai,llm.errors,llm.config,llm.manager,agents.base)