feat: implement Agent.stop() in python sdk#446
feat: implement Agent.stop() in python sdk#446shuaixr wants to merge 1 commit intoAgent-Field:mainfrom
Conversation
c853bf8 to
7e64515
Compare
Performance
✓ No regressions detected |
📊 Coverage gateThresholds from
✅ Gate passedNo surface regressed past the allowed threshold and the aggregate stayed above the floor. |
📐 Patch coverage gateThreshold: 80% on lines this PR touches vs
✅ Patch gate passedEvery surface whose lines were touched by this PR has patch coverage at or above the threshold. |
AbirAbbas
left a comment
There was a problem hiding this comment.
Nice addition — the try/except isolation around each cleanup step is the right call, and the idempotency guard works. A couple things worth addressing:
| if self.dev_mode: | ||
| from agentfield.logger import log_error | ||
|
|
||
| log_error(f"Registry clear error during stop(): {e}") |
There was a problem hiding this comment.
This calls clear_current_agent() but doesn't clear Agent._current_agent (the class-level attr). The existing _clear_current() method right above does both — it deletes the class attr and calls clear_current_agent().
After stop(), Agent.get_current() will still return the stopped agent. Should probably just call self._clear_current() here instead.
Summary
Implements
Agent.stop()method that performs a clean async shutdown of an agent instance:Closes: #355
Testing
./scripts/test-all.shChecklist
CHANGELOG.md(or this change does not warrant a changelog entry).Screenshots (if UI-related)
Related issues