Prompt vars
This pull request introduces significant updates to how agents manage and interact with storage, transitioning from a registry-based approach to passing store instances directly. It simplifies the API, enhances flexibility, and improves clarity in both documentation and implementation. The most important changes include removing the `set_stores` method, updating the `Agent` class to accept store instances directly, and modifying the documentation and examples accordingly.
### Agent Storage Management Updates:
* Removed the `set_stores` method and related registry-based store retrieval methods from the `Agent` class. The `Agent` now accepts `thread_store` and `file_store` instances directly, simplifying configuration. [[1]](diffhunk://#diff-9b0658e7a84220493b735adae2032da961dce2f52f7111ba2af4759c57e864fcL264-L328) [[2]](diffhunk://#diff-9b0658e7a84220493b735adae2032da961dce2f52f7111ba2af4759c57e864fcL486-R445)
* Added default in-memory store creation for `thread_store` and `file_store` if none are provided during `Agent` initialization.
### API Enhancements:
* Updated the `Agent` class to support `Union[str, Prompt]` for `purpose` and `notes` fields, allowing dynamic formatting. Added optional fields for custom API base URLs and extra headers for API requests. [[1]](diffhunk://#diff-9b0658e7a84220493b735adae2032da961dce2f52f7111ba2af4759c57e864fcL122-R122) [[2]](diffhunk://#diff-9b0658e7a84220493b735adae2032da961dce2f52f7111ba2af4759c57e864fcR134-L161) [[3]](diffhunk://#diff-9b0658e7a84220493b735adae2032da961dce2f52f7111ba2af4759c57e864fcR356-R363)
### Documentation Updates:
* Updated examples and documentation to reflect the new approach of passing store instances directly to the `Agent` constructor, replacing references to the `set_stores` method. [[1]](diffhunk://#diff-3ac997da6e24b69da69cbb5b25fd6f3cce2589cf093d0b3b857e2deeb1b34e10L18-R18) [[2]](diffhunk://#diff-3ac997da6e24b69da69cbb5b25fd6f3cce2589cf093d0b3b857e2deeb1b34e10L181-R205) [[3]](diffhunk://#diff-26a27f31b938efc2e2e661c3ee8a5b46ea02efaf7a89e9d38d892878da24e29dL145-L150) [[4]](diffhunk://#diff-bcaa514e7345db9c487347cc078f3ee0212329783fc03311aa39824990ba461aL648-R654)
* Removed references to the deprecated `set_stores` method in related documentation and examples. [[1]](diffhunk://#diff-3ac997da6e24b69da69cbb5b25fd6f3cce2589cf093d0b3b857e2deeb1b34e10L223-R242) [[2]](diffhunk://#diff-26a27f31b938efc2e2e661c3ee8a5b46ea02efaf7a89e9d38d892878da24e29dL232-L239)
### Codebase Simplification:
* Refactored agent methods to directly use `thread_store` and `file_store` attributes instead of fetching them dynamically, reducing complexity and improving performance. [[1]](diffhunk://#diff-9b0658e7a84220493b735adae2032da961dce2f52f7111ba2af4759c57e864fcL395-R344) [[2]](diffhunk://#diff-9b0658e7a84220493b735adae2032da961dce2f52f7111ba2af4759c57e864fcL628-R585) [[3]](diffhunk://#diff-9b0658e7a84220493b735adae2032da961dce2f52f7111ba2af4759c57e864fcL692-R648)
### Testing Updates:
* Updated tests to initialize agents with mock store instances directly, removing reliance on patched methods for store retrieval. [[1]](diffhunk://#diff-d27ae1c708b37ba4d72f4df5f6d8a8c0d8fb8c071c24f4bafd6856e8faad1215L645-R646) [[2]](diffhunk://#diff-d27ae1c708b37ba4d72f4df5f6d8a8c0d8fb8c071c24f4bafd6856e8faad1215L664-L669)
合并状态:已合并 合并于 2025-06-21 关闭于 2025-06-21 0 条评论