Skip to content

fix(agents): rebuild discovered tools after cleanup - #298

Open
Gujiassh wants to merge 1 commit into
TencentCloudADP:mainfrom
Gujiassh:fix/rebuild-owned-tools
Open

Gujiassh wants to merge 1 commit into
TencentCloudADP:mainfrom
Gujiassh:fix/rebuild-owned-tools

Conversation

@Gujiassh

@Gujiassh Gujiassh commented Oct 2, 2026

Copy link
Copy Markdown

Summary

Closes #297.

After SimpleAgent.cleanup() closes configured toolkit resources, a later build() currently keeps the old discovered tool callbacks. A customized toolkit that opens a file reproduces a successful first tool invocation followed by an I/O-on-closed-file error after rebuilding.

Preserve the constructor-supplied tools reference and restore it after successful cleanup. Discovered tools are rebuilt from configuration on the next build; explicit caller-owned tools retain their list and tool identities.

Validation

  • Five new lifecycle cases cover three real file-resource cleanup/rebuild cycles, repeated build, caller-owned tool identity and mutation, and empty tools.
  • Eleven focused lifecycle/common/output-parser tests pass.
  • Actual configured toolkit loader and SDK FunctionTool calls succeed before and after cleanup.
  • Changed-file Ruff lint and format checks pass.

A broader offline selection has eight existing failures, reproduced with unchanged main source: missing generated configuration or required configuration values, and reasoning-converter tests calling an absent helper. The two new resource regressions fail on main and pass with this change. Target-file mypy diagnostics are unchanged (seven existing errors). Full-suite and live-provider validation are not claimed.

This branch has not been deployed

No deployments
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.

SimpleAgent cleanup followed by build reuses closed toolkit resources

1 participant