Skip to content

[SDK] Fix: run cleanup when BaseAgent.setup fails (#3765)#3936

Open
josemiguel3125-sketch wants to merge 1 commit into
orchestration-agent:mainfrom
josemiguel3125-sketch:fix/bounty-3765
Open

[SDK] Fix: run cleanup when BaseAgent.setup fails (#3765)#3936
josemiguel3125-sketch wants to merge 1 commit into
orchestration-agent:mainfrom
josemiguel3125-sketch:fix/bounty-3765

Conversation

@josemiguel3125-sketch
Copy link
Copy Markdown

Description

Fixes #3765

BaseAgent.run() called self.setup() outside the try/finally block. If setup() raised an exception, self.cleanup() was never executed, leaking resources (open files, connections, locks).

Changes

  • Moved self.setup() inside the try block so finally always runs self.cleanup()
  • Added error logging when setup fails
  • Both normal execution and cancellation paths still call cleanup

Tests

  • test_cleanup_called_when_setup_fails — verifies cleanup is called after setup raises
  • test_cleanup_called_on_normal_stop — verifies cleanup is called on graceful stop
  • All existing tests pass: make test

Acceptance Criteria

  • A regression test covers this SDK case
  • The changed behavior is documented or asserted by the relevant test

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.

[ Bounty $5k ] [ SDK ] Run cleanup when BaseAgent setup fails — agent lifecycle

1 participant