Summary
agentfield.Agent has no stop() method. The TypeScript SDK's Agent class exposes a symmetric serve()/shutdown() (or start()/stop()) lifecycle, and the documentation in several places implies the Python SDK has the same. Today it does not, which means external callers cannot programmatically stop a long-running agent without going through signal handling — a leaky abstraction.
Where
- File:
sdk/python/agentfield/agent.py
- Class:
Agent
- Discovered by:
sdk/python/tests/test_agent_graceful_shutdown.py::test_agent_stop_is_idempotent (skipped with pytest.skip("source bug: Agent.stop() is not implemented"))
Reproduction
agent = Agent(
node_id="shutdown-agent",
agentfield_server="http://agentfield",
auto_register=False,
enable_did=False,
)
hasattr(agent, "stop") # False
Expected behavior
Agent.stop() should:
- Mark the agent as shutting down (set
_shutdown_requested = True, transition _current_status to OFFLINE)
- Stop the heartbeat loop
- Notify the control plane via
client.notify_graceful_shutdown (best effort — failure should not block stop)
- Tear down async resources (the same path as
_cleanup_async_resources)
- Be idempotent — calling
stop() twice should be a no-op the second time, not raise
This pairs cleanly with whatever start/serve method the agent already exposes.
Acceptance criteria
Related
Discovered via
PR #352 (test coverage improvements). One of 5 source bugs surfaced while writing failure-mode tests for the Python SDK.
Summary
agentfield.Agenthas nostop()method. The TypeScript SDK'sAgentclass exposes a symmetricserve()/shutdown()(orstart()/stop()) lifecycle, and the documentation in several places implies the Python SDK has the same. Today it does not, which means external callers cannot programmatically stop a long-running agent without going through signal handling — a leaky abstraction.Where
sdk/python/agentfield/agent.pyAgentsdk/python/tests/test_agent_graceful_shutdown.py::test_agent_stop_is_idempotent(skipped withpytest.skip("source bug: Agent.stop() is not implemented"))Reproduction
Expected behavior
Agent.stop()should:_shutdown_requested = True, transition_current_statustoOFFLINE)client.notify_graceful_shutdown(best effort — failure should not block stop)_cleanup_async_resources)stop()twice should be a no-op the second time, not raiseThis pairs cleanly with whatever start/serve method the agent already exposes.
Acceptance criteria
Agent.stop()exists and isasynctest_agent_graceful_shutdown.py::test_agent_stop_is_idempotentis unskipped and passesRelated
_graceful_shutdownmachinery thatstop()should drive.Discovered via
PR #352 (test coverage improvements). One of 5 source bugs surfaced while writing failure-mode tests for the Python SDK.