Skip to content

[FEATURE] Enable writable agent state and properties within hooks #1589

@nagabharann

Description

@nagabharann

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:

  1. Direct write access to agent state/properties via the event context
  2. A method on the event object to update state (e.g., event.update_state(...))
  3. 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:

  1. Rehydrate agent state from a persisted snapshot
  2. Modify agent properties to reflect the resumed context
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions