sdk-python
sdk-python copied to clipboard
[FEATURE] Enable writable agent state and properties within hooks
Problem Statement
Agent state can only be modified outside of hooks (before agent.prompt()). Properties are also read-only within hooks. This prevents us from implementing pause/resume functionality and dynamic agent behavior modification from within hook handlers.
Proposed Solution
Provide a mechanism to modify agent state and properties from within hook handlers. This could be through:
- Direct write access to agent state/properties via the event context
- A method on the event object to update state (e.g., event.update_state(...))
- A callback mechanism to safely modify agent internals
Use Case
We are building pause/resume functionality for long-running agents. When resuming a paused agent, we need to:
- Rehydrate agent state from a persisted snapshot
- Modify agent properties to reflect the resumed context
- Update conversation history before continuing execution
Without writable state in hooks, we cannot implement this pattern cleanly.
Alternatives Solutions
We currently recreate agents from scratch when resuming, which is inefficient and loses runtime context that isn't serialized.
Additional Context
No response